| Index: chromeos/network/geolocation_handler.h
|
| diff --git a/chromeos/network/geolocation_handler.h b/chromeos/network/geolocation_handler.h
|
| index f962328511ff802fd717a44abd5ad385493c08f8..12efe5bc30f535fe921664d3f0a300197404ce52 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,14 +38,23 @@ 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 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 wifi_enabled() const { return wifi_enabled_; }
|
|
|
| + // This sends a request for geolocation (both wifi AP and cell tower) data.
|
| + // If cell data is already available, returns |true|, fills |cell_towers|
|
| + // with the latest cell tower data, and sets |age_ms| to the time
|
| + // since the last update in MS.
|
| + bool GetCellTowers(CellTowerVector* cell_towers, int64_t* age_ms);
|
| +
|
| + bool cellular_enabled() const { return cellular_enabled_; }
|
| +
|
| // ShillPropertyChangedObserver overrides
|
| void OnPropertyChanged(const std::string& key,
|
| const base::Value& value) override;
|
| @@ -52,7 +62,7 @@ class CHROMEOS_EXPORT GeolocationHandler : public ShillPropertyChangedObserver {
|
| private:
|
| friend class NetworkHandler;
|
| friend class GeolocationHandlerTest;
|
| - friend class SimpleGeolocationWiFiTest;
|
| + friend class SimpleGeolocationWirelessTest;
|
|
|
| GeolocationHandler();
|
|
|
| @@ -65,19 +75,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_;
|
|
|