Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: chromeos/network/geolocation_handler.h

Issue 2624843003: Add support for cellular geolocation (Closed)
Patch Set: Add SEND_ALL_NETWORK_INFO option for timezone detection Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/network/geolocation_handler.h
diff --git a/chromeos/network/geolocation_handler.h b/chromeos/network/geolocation_handler.h
index f962328511ff802fd717a44abd5ad385493c08f8..03ca9ee45990bffa26e34b77880e4af16db7409c 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,28 @@ 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);
+ // 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);
Alexander Alekseev 2017/02/07 22:15:38 It looks like GetWifiAccessPoints()/GetCellTowers(
can Skylar cook 2017/02/07 22:29:59 GetWifiAccessPoints() is used in a few locations,
Alexander Alekseev 2017/02/08 22:10:32 WifiDataProviderChromeOs is a completely different
+
+ bool cellular_enabled() const { return cellular_enabled_; }
+
bool wifi_enabled() const { return wifi_enabled_; }
// ShillPropertyChangedObserver overrides
@@ -52,7 +69,7 @@ class CHROMEOS_EXPORT GeolocationHandler : public ShillPropertyChangedObserver {
private:
friend class NetworkHandler;
friend class GeolocationHandlerTest;
- friend class SimpleGeolocationWiFiTest;
+ friend class SimpleGeolocationWirelessTest;
GeolocationHandler();
@@ -65,19 +82,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_;

Powered by Google App Engine
This is Rietveld 408576698