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

Side by Side Diff: chromeos/network/geolocation_handler.h

Issue 11887008: Deprecate ShillNetworkClient and add GeolocationHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unittest Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_NETWORK_GEOLOCATION_HANDLER_H_
6 #define CHROMEOS_NETWORK_GEOLOCATION_HANDLER_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "base/time.h"
10 #include "chromeos/dbus/dbus_method_call_status.h"
11 #include "chromeos/dbus/shill_property_changed_observer.h"
12 #include "chromeos/network/network_util.h"
13
14 namespace base {
15 class DictionaryValue;
16 }
17
18 namespace chromeos {
19
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
22 // class requests data asynchronously, returning the most recent available data.
23 // A typical usage pattern, assuming a wifi device is enabeld, is:
gauravsh 2013/01/15 03:19:00 enabled
24 // Initialize(); // Makes an initial request
25 // GetWifiAccessPoints(); // returns true + inital data, requests update
26 // (Delay some amount of time, ~10s)
27 // GetWifiAccessPoints(); // returns true + updated data, requests update
28 // (Delay some amount of time after data changed, ~10s)
29 // GetWifiAccessPoints(); // returns true + same data, requests update
30 // (Delay some amount of time after data did not change, ~2 mins)
31
32 class CHROMEOS_EXPORT GeolocationHandler : public ShillPropertyChangedObserver {
33 public:
34 ~GeolocationHandler();
35
36 // Manage the global instance. Must be initialized before any calls to Get().
37 static void Initialize();
38 static void Shutdown();
39 static GeolocationHandler* Get();
40
41 // This sends a request for wifi access point data. If data is already
42 // available, returns |true|, fills |access_points| with the latest access
43 // point data, and sets |age_ms| to the time since the last update in MS.
44 bool GetWifiAccessPoints(WifiAccessPointVector* access_points, int64* age_ms);
45
46 bool wifi_enabled() const { return wifi_enabled_; }
47
48 // ShillPropertyChangedObserver overrides
49 virtual void OnPropertyChanged(const std::string& key,
50 const base::Value& value) OVERRIDE;
51
52 private:
53 friend class GeolocationHandlerTest;
54 GeolocationHandler();
55 void Init();
56
57 // ShillManagerClient callback
58 void ManagerPropertiesCallback(DBusMethodCallStatus call_status,
59 const base::DictionaryValue& properties);
60
61 // Called from OnPropertyChanged or ManagerPropertiesCallback.
62 void HandlePropertyChanged(const std::string& key, const base::Value& value);
63
64 // Asynchronously request wifi access points from Shill.Manager.
65 void RequestWifiAccessPoints();
66
67 // Callback for receiving Geolocation data.
68 void GeolocationCallback(DBusMethodCallStatus call_status,
69 const base::DictionaryValue& properties);
70
71 // Wimax enabled state
gauravsh 2013/01/15 03:19:00 Wifi
72 bool wifi_enabled_;
73
74 // Cached wifi access points and update time
75 WifiAccessPointVector wifi_access_points_;
76 base::Time geolocation_received_time_;
77
78 // For Shill client callbacks
79 base::WeakPtrFactory<GeolocationHandler> weak_ptr_factory_;
80
81 DISALLOW_COPY_AND_ASSIGN(GeolocationHandler);
82 };
83
84 } // namespace chromeos
85
86 #endif // CHROMEOS_NETWORK_GEOLOCATION_HANDLER_H_
OLDNEW
« no previous file with comments | « chromeos/network/cros_network_functions_unittest.cc ('k') | chromeos/network/geolocation_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698