Chromium Code Reviews| Index: chromeos/network/geolocation_handler.h |
| diff --git a/chromeos/network/geolocation_handler.h b/chromeos/network/geolocation_handler.h |
| index f962328511ff802fd717a44abd5ad385493c08f8..ad7d194447c4d310ecd76687715952e5499aeaff 100644 |
| --- a/chromeos/network/geolocation_handler.h |
| +++ b/chromeos/network/geolocation_handler.h |
| @@ -21,10 +21,11 @@ class DictionaryValue; |
| namespace chromeos { |
| -// This class provices Shill Wifi Access Point data. It currently relies on |
| -// polling because that is the usage model in content::WifiDataProvider. This |
| -// class requests data asynchronously, returning the most recent available data. |
| -// A typical usage pattern, assuming a wifi device is enabled, is: |
| +// This class provices Shill Wifi Access Point and Cell Tower data. It |
| +// currently relies on polling because that is the usage model in |
| +// content::WifiDataProvider. This class requests data asynchronously, |
| +// returning the most recent available data. A typical usage pattern, |
| +// assuming a wifi device is enabled, is: |
| // Initialize(); // Makes an initial request |
| // GetWifiAccessPoints(); // returns true + inital data, requests update |
| // (Delay some amount of time, ~10s) |
| @@ -37,12 +38,22 @@ class CHROMEOS_EXPORT GeolocationHandler : public ShillPropertyChangedObserver { |
| public: |
| ~GeolocationHandler() override; |
| - // This sends a request for wifi access point data. If data is already |
| - // available, returns |true|, fills |access_points| with the latest access |
| - // point data, and sets |age_ms| to the time since the last update in MS. |
| + // This sends a request for geolocation (both wifi AP and cell tower) data. |
| + // If AP data is already available, fills |access_points| with the latest |
| + // access point data, and similarly for cell tower data and |cell_towers|. |
| + // Returns |true| if either type of data is already available upon call. |
| + bool GetNetworkInformation(WifiAccessPointVector* access_points, |
| + CellTowerVector* cell_towers); |
| + |
| + // This sends a request for geolocation (both wifi AP and cell tower) data. |
| + // If wifi data is already available, returns |true|, fills |access_points| |
| + // with the latest access point data, and sets |age_ms| to the time |
| + // since the last update in MS. |
| bool GetWifiAccessPoints(WifiAccessPointVector* access_points, |
| int64_t* age_ms); |
| + bool cellular_enabled() const { return cellular_enabled_; } |
|
stevenjb
2017/02/07 23:54:29
Is this used now?
can Skylar cook
2017/02/08 21:15:49
Done.
|
| + |
| bool wifi_enabled() const { return wifi_enabled_; } |
| // ShillPropertyChangedObserver overrides |
| @@ -52,7 +63,7 @@ class CHROMEOS_EXPORT GeolocationHandler : public ShillPropertyChangedObserver { |
| private: |
| friend class NetworkHandler; |
| friend class GeolocationHandlerTest; |
| - friend class SimpleGeolocationWiFiTest; |
| + friend class SimpleGeolocationWirelessTest; |
| GeolocationHandler(); |
| @@ -65,19 +76,27 @@ class CHROMEOS_EXPORT GeolocationHandler : public ShillPropertyChangedObserver { |
| // Called from OnPropertyChanged or ManagerPropertiesCallback. |
| void HandlePropertyChanged(const std::string& key, const base::Value& value); |
| - // Asynchronously request wifi access points from Shill.Manager. |
| - void RequestWifiAccessPoints(); |
| + // Asynchronously request geolocation objects (wifi access points and |
| + // cell towers) from Shill.Manager. |
| + void RequestGeolocationObjects(); |
| // Callback for receiving Geolocation data. |
| void GeolocationCallback(DBusMethodCallStatus call_status, |
| const base::DictionaryValue& properties); |
| - // Wifi enabled state |
| + bool cellular_enabled_; |
| bool wifi_enabled_; |
| + void AddCellTowerFromDict(const base::DictionaryValue* entry); |
| + void AddAccessPointFromDict(const base::DictionaryValue* entry); |
| + |
| // Cached wifi access points and update time |
| WifiAccessPointVector wifi_access_points_; |
| - base::Time geolocation_received_time_; |
| + base::Time access_point_received_time_; |
| + |
| + // Cached cell towers and update time |
| + CellTowerVector cell_towers_; |
| + base::Time cell_towers_received_time_; |
| // For Shill client callbacks |
| base::WeakPtrFactory<GeolocationHandler> weak_ptr_factory_; |