| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_NETWORK_GEOLOCATION_HANDLER_H_ | 5 #ifndef CHROMEOS_NETWORK_GEOLOCATION_HANDLER_H_ |
| 6 #define CHROMEOS_NETWORK_GEOLOCATION_HANDLER_H_ | 6 #define CHROMEOS_NETWORK_GEOLOCATION_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chromeos/dbus/dbus_method_call_status.h" | 10 #include "chromeos/dbus/dbus_method_call_status.h" |
| 11 #include "chromeos/dbus/shill_property_changed_observer.h" | 11 #include "chromeos/dbus/shill_property_changed_observer.h" |
| 12 #include "chromeos/network/network_util.h" | 12 #include "chromeos/network/network_util.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class DictionaryValue; | 15 class DictionaryValue; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 // This class provices Shill Wifi Access Point data. It currently relies on | 20 // This class provices Shill Wifi Access Point data. It currently relies on |
| 21 // polling because that is the usage model in content::WifiDataProvider. This | 21 // polling because that is the usage model in content::WifiDataProvider. This |
| 22 // class requests data asynchronously, returning the most recent available data. | 22 // class requests data asynchronously, returning the most recent available data. |
| 23 // A typical usage pattern, assuming a wifi device is enabeld, is: | 23 // A typical usage pattern, assuming a wifi device is enabled, is: |
| 24 // Initialize(); // Makes an initial request | 24 // Initialize(); // Makes an initial request |
| 25 // GetWifiAccessPoints(); // returns true + inital data, requests update | 25 // GetWifiAccessPoints(); // returns true + inital data, requests update |
| 26 // (Delay some amount of time, ~10s) | 26 // (Delay some amount of time, ~10s) |
| 27 // GetWifiAccessPoints(); // returns true + updated data, requests update | 27 // GetWifiAccessPoints(); // returns true + updated data, requests update |
| 28 // (Delay some amount of time after data changed, ~10s) | 28 // (Delay some amount of time after data changed, ~10s) |
| 29 // GetWifiAccessPoints(); // returns true + same data, requests update | 29 // GetWifiAccessPoints(); // returns true + same data, requests update |
| 30 // (Delay some amount of time after data did not change, ~2 mins) | 30 // (Delay some amount of time after data did not change, ~2 mins) |
| 31 | 31 |
| 32 class CHROMEOS_EXPORT GeolocationHandler : public ShillPropertyChangedObserver { | 32 class CHROMEOS_EXPORT GeolocationHandler : public ShillPropertyChangedObserver { |
| 33 public: | 33 public: |
| (...skipping 27 matching lines...) Expand all Loading... |
| 61 // Called from OnPropertyChanged or ManagerPropertiesCallback. | 61 // Called from OnPropertyChanged or ManagerPropertiesCallback. |
| 62 void HandlePropertyChanged(const std::string& key, const base::Value& value); | 62 void HandlePropertyChanged(const std::string& key, const base::Value& value); |
| 63 | 63 |
| 64 // Asynchronously request wifi access points from Shill.Manager. | 64 // Asynchronously request wifi access points from Shill.Manager. |
| 65 void RequestWifiAccessPoints(); | 65 void RequestWifiAccessPoints(); |
| 66 | 66 |
| 67 // Callback for receiving Geolocation data. | 67 // Callback for receiving Geolocation data. |
| 68 void GeolocationCallback(DBusMethodCallStatus call_status, | 68 void GeolocationCallback(DBusMethodCallStatus call_status, |
| 69 const base::DictionaryValue& properties); | 69 const base::DictionaryValue& properties); |
| 70 | 70 |
| 71 // Wimax enabled state | 71 // Wifi enabled state |
| 72 bool wifi_enabled_; | 72 bool wifi_enabled_; |
| 73 | 73 |
| 74 // Cached wifi access points and update time | 74 // Cached wifi access points and update time |
| 75 WifiAccessPointVector wifi_access_points_; | 75 WifiAccessPointVector wifi_access_points_; |
| 76 base::Time geolocation_received_time_; | 76 base::Time geolocation_received_time_; |
| 77 | 77 |
| 78 // For Shill client callbacks | 78 // For Shill client callbacks |
| 79 base::WeakPtrFactory<GeolocationHandler> weak_ptr_factory_; | 79 base::WeakPtrFactory<GeolocationHandler> weak_ptr_factory_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(GeolocationHandler); | 81 DISALLOW_COPY_AND_ASSIGN(GeolocationHandler); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace chromeos | 84 } // namespace chromeos |
| 85 | 85 |
| 86 #endif // CHROMEOS_NETWORK_GEOLOCATION_HANDLER_H_ | 86 #endif // CHROMEOS_NETWORK_GEOLOCATION_HANDLER_H_ |
| OLD | NEW |