wifi_data.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_DEVICE_GEOLOCATION_WIFI_DATA_H_
  5. #define SERVICES_DEVICE_GEOLOCATION_WIFI_DATA_H_
  6. #include <set>
  7. #include <string>
  8. namespace device {
  9. // Wifi data relating to a single access point.
  10. struct AccessPointData {
  11. AccessPointData();
  12. ~AccessPointData();
  13. // MAC address, formatted as per MacAddressAsString16.
  14. std::u16string mac_address;
  15. int radio_signal_strength; // Measured in dBm
  16. int channel;
  17. int signal_to_noise; // Ratio in dB
  18. std::u16string ssid; // Network identifier
  19. };
  20. // This is to allow AccessPointData to be used in std::set. We order
  21. // lexicographically by MAC address.
  22. struct AccessPointDataLess {
  23. bool operator()(const AccessPointData& data1,
  24. const AccessPointData& data2) const {
  25. return data1.mac_address < data2.mac_address;
  26. }
  27. };
  28. // All data for wifi.
  29. struct WifiData {
  30. WifiData();
  31. WifiData(const WifiData& other);
  32. ~WifiData();
  33. // Determines whether a new set of WiFi data differs significantly from this.
  34. bool DiffersSignificantly(const WifiData& other) const;
  35. // Store access points as a set, sorted by MAC address. This allows quick
  36. // comparison of sets for detecting changes and for caching.
  37. typedef std::set<AccessPointData, AccessPointDataLess> AccessPointDataSet;
  38. AccessPointDataSet access_point_data;
  39. };
  40. } // namespace device
  41. #endif // SERVICES_DEVICE_GEOLOCATION_WIFI_DATA_H_