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

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

Issue 11192024: Add chromeos::NetworkStateManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Separate out NetworkStateHandlerImpl, address feedback Created 8 years, 1 month 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) 2012 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_NETWORK_STATE_HANDLER_IMPL_H_
6 #define CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_IMPL_H_
7
8 #include <list>
9 #include <map>
10 #include <set>
11 #include <string>
12
13 #include "base/memory/weak_ptr.h"
14 #include "chromeos/dbus/dbus_method_call_status.h"
15 #include "chromeos/dbus/shill_property_changed_observer.h"
16 #include "chromeos/network/managed_state.h"
17
18 namespace base {
19 class DictionaryValue;
20 class ListValue;
21 class Value;
22 }
23
24 namespace chromeos {
25
26 class NetworkStateHandler;
27 class ShillServiceObserver;
28 class ShillManagerClient;
29
30 namespace internal {
31
32 // Implementation class for NetworkStateHandler. This class handles all Shill
33 // calls and observers. This class must not outlive the ShillManagerClient
34 // instance.
35 class NetworkStateHandlerImpl : public ShillPropertyChangedObserver {
gauravsh 2012/10/27 00:26:33 Please think of a better name for this class. It's
stevenjb 2012/10/29 18:34:07 Fair enough. How about ShillPropertyHandler?
gauravsh 2012/10/29 18:37:05 SGTM
36 public:
37 typedef std::map<std::string, ShillServiceObserver*> ShillServiceObserverMap;
38
39 explicit NetworkStateHandlerImpl(NetworkStateHandler* base);
40 ~NetworkStateHandlerImpl();
41
42 // Initialize NetworkStateHandler. Sends an initial property request.
43 void Init();
44
45 // Asynchronously sets the enabled state for |technology|.
46 // Note: Modifes Manager state. TODO(stevenjb): Add a completion callback.
47 void SetTechnologyEnabled(const std::string& technology, bool enabled);
48
49 // Requests an immediate network scan.
50 void RequestScan() const;
51
52 // Requests all properties for the service or device (called for new items).
53 void RequestProperties(ManagedState::ManagedType type,
54 const std::string& path);
55
56 // Requests the IP config specified by |ip_config_path| for |service_path|.
57 void RequestIPConfig(const std::string& service_path,
58 const std::string& ip_config_path);
59
60 // ShillPropertyChangedObserver overrides
61 virtual void OnPropertyChanged(const std::string& key,
62 const base::Value& value) OVERRIDE;
63
64 const ShillServiceObserverMap& observed_networks() {
65 return observed_networks_;
66 }
67
68 private:
69 // Callback for dbus method fetching properties.
70 void ManagerPropertiesCallback(DBusMethodCallStatus call_status,
71 const base::DictionaryValue& properties);
72 // Called form OnPropertyChanged() and ManagerPropertiesCallback().
73 // Returns true if observers should be notified.
74 bool ManagerPropertyChanged(const std::string& key, const base::Value& value);
75
76 // Updates the Shill service property observers to observe any entries
77 // in the service watch list.
78 void UpdateObservedNetworkServices(const base::ListValue& entries);
79
80 // Called when Shill returns the properties for a service or device.
81 void GetPropertiesCallback(ManagedState::ManagedType type,
82 const std::string& path,
83 DBusMethodCallStatus call_status,
84 const base::DictionaryValue& properties);
85
86 // Callback invoked when a watched service property changes. Calls
87 // network->PropertyChanged(key, value) and signals observers.
88 void NetworkServicePropertyChangedCallback(const std::string& path,
89 const std::string& key,
90 const base::Value& value);
91
92 // Callback for getting the IPConfig property of a Network. Handled here
93 // instead of in NetworkState so that all asynchronous requests are done
94 // in a single place (also simplifies NetworkState considerably).
95 void GetIPConfigCallback(const std::string& service_path,
96 DBusMethodCallStatus call_status,
97 const base::DictionaryValue& properties);
98
99 // Pointer to containing class (owns this)
100 NetworkStateHandler* base_;
101
102 // Convenience pointer for ShillManagerClient
103 ShillManagerClient* shill_manager_;
104
105 // Pending update count for each managed state type
106 std::map<ManagedState::ManagedType, int> pending_updates_;
107
108 // List of network services with Shill property changed observers
109 ShillServiceObserverMap observed_networks_;
110
111 // For Shill client callbacks
112 base::WeakPtrFactory<NetworkStateHandlerImpl> weak_ptr_factory_;
113
114 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandlerImpl);
115 };
116
117 } // namespace internal
118 } // namespace chromeos
119
120 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698