1424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// found in the LICENSE file.
4424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
5424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#ifndef CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_H_
6424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#define CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_H_
7424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
8424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include <set>
9424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
10424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "base/basictypes.h"
11424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "base/strings/string16.h"
12424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "content/common/content_export.h"
13424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
14424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace content {
15424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
16424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Wifi data relating to a single access point.
17424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)struct CONTENT_EXPORT AccessPointData {
18424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  AccessPointData();
19424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  ~AccessPointData();
20424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
21424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // MAC address, formatted as per MacAddressAsString16.
22a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 mac_address;
23424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  int radio_signal_strength;  // Measured in dBm
24424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  int channel;
25424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  int signal_to_noise;  // Ratio in dB
26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 ssid;   // Network identifier
27424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)};
28424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
29424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// This is to allow AccessPointData to be used in std::set. We order
30424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// lexicographically by MAC address.
31424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)struct AccessPointDataLess {
32424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  bool operator()(const AccessPointData& data1,
33424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)                  const AccessPointData& data2) const {
34424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    return data1.mac_address < data2.mac_address;
35424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  }
36424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)};
37424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
38424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// All data for wifi.
39424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)struct CONTENT_EXPORT WifiData {
40424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  WifiData();
41424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  ~WifiData();
42424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
43424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // Determines whether a new set of WiFi data differs significantly from this.
44424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  bool DiffersSignificantly(const WifiData& other) const;
45424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
46424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // Store access points as a set, sorted by MAC address. This allows quick
47424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // comparison of sets for detecting changes and for caching.
48424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  typedef std::set<AccessPointData, AccessPointDataLess> AccessPointDataSet;
49424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  AccessPointDataSet access_point_data;
50424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)};
51424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
52424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}  // namespace content
53424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
54424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#endif  // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_H_
55