OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_SHILL_PROPERTY_HANDLER_H_ | 5 #ifndef CHROMEOS_NETWORK_SHILL_PROPERTY_HANDLER_H_ |
6 #define CHROMEOS_NETWORK_SHILL_PROPERTY_HANDLER_H_ | 6 #define CHROMEOS_NETWORK_SHILL_PROPERTY_HANDLER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 20 matching lines...) Expand all Loading... |
31 class ShillPropertyObserver; | 31 class ShillPropertyObserver; |
32 | 32 |
33 // This class handles Shill calls and observers to reflect the state of the | 33 // This class handles Shill calls and observers to reflect the state of the |
34 // Shill Manager and its services and devices. It observes Shill.Manager and | 34 // Shill Manager and its services and devices. It observes Shill.Manager and |
35 // requests properties for new devices/networks. It takes a Listener in its | 35 // requests properties for new devices/networks. It takes a Listener in its |
36 // constructor (e.g. NetworkStateHandler) that it calls when properties change | 36 // constructor (e.g. NetworkStateHandler) that it calls when properties change |
37 // (including once to set their initial state after Init() gets called). | 37 // (including once to set their initial state after Init() gets called). |
38 // It also observes Shill.Service for all services in Manager.ServiceWatchList. | 38 // It also observes Shill.Service for all services in Manager.ServiceWatchList. |
39 // This class must not outlive the ShillManagerClient instance. | 39 // This class must not outlive the ShillManagerClient instance. |
40 class CHROMEOS_EXPORT ShillPropertyHandler | 40 class CHROMEOS_EXPORT ShillPropertyHandler |
41 : public ShillPropertyChangedObserver { | 41 : public ShillPropertyChangedObserver, |
| 42 public base::SupportsWeakPtr<ShillPropertyHandler> { |
42 public: | 43 public: |
43 typedef std::map<std::string, ShillPropertyObserver*> | 44 typedef std::map<std::string, ShillPropertyObserver*> |
44 ShillPropertyObserverMap; | 45 ShillPropertyObserverMap; |
45 | 46 |
46 class CHROMEOS_EXPORT Listener { | 47 class CHROMEOS_EXPORT Listener { |
47 public: | 48 public: |
48 // Called when the entries in a managed list have changed. | 49 // Called when the entries in a managed list have changed. |
49 virtual void UpdateManagedList(ManagedState::ManagedType type, | 50 virtual void UpdateManagedList(ManagedState::ManagedType type, |
50 const base::ListValue& entries) = 0; | 51 const base::ListValue& entries) = 0; |
51 | 52 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Asynchronously sets the enabled state for |technology|. | 101 // Asynchronously sets the enabled state for |technology|. |
101 // Note: Modifes Manager state. Calls |error_callback| on failure. | 102 // Note: Modifes Manager state. Calls |error_callback| on failure. |
102 void SetTechnologyEnabled( | 103 void SetTechnologyEnabled( |
103 const std::string& technology, | 104 const std::string& technology, |
104 bool enabled, | 105 bool enabled, |
105 const network_handler::ErrorCallback& error_callback); | 106 const network_handler::ErrorCallback& error_callback); |
106 | 107 |
107 // Requests an immediate network scan. | 108 // Requests an immediate network scan. |
108 void RequestScan() const; | 109 void RequestScan() const; |
109 | 110 |
| 111 // Calls Manager.ConnectToBestServices(). |
| 112 void ConnectToBestServices() const; |
| 113 |
110 // Requests all properties for the service or device (called for new items). | 114 // Requests all properties for the service or device (called for new items). |
111 void RequestProperties(ManagedState::ManagedType type, | 115 void RequestProperties(ManagedState::ManagedType type, |
112 const std::string& path); | 116 const std::string& path); |
113 | 117 |
114 // Returns true if |service_path| is being observed. | 118 // Returns true if |service_path| is being observed. |
115 bool IsObservingNetwork(const std::string& service_path) { | 119 bool IsObservingNetwork(const std::string& service_path) { |
116 return observed_networks_.count(service_path) != 0; | 120 return observed_networks_.count(service_path) != 0; |
117 } | 121 } |
118 | 122 |
119 // ShillPropertyChangedObserver overrides | 123 // ShillPropertyChangedObserver overrides |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 ShillPropertyObserverMap observed_networks_; | 181 ShillPropertyObserverMap observed_networks_; |
178 | 182 |
179 // List of network devices with Shill property changed observers | 183 // List of network devices with Shill property changed observers |
180 ShillPropertyObserverMap observed_devices_; | 184 ShillPropertyObserverMap observed_devices_; |
181 | 185 |
182 // Lists of available / enabled / uninitialized technologies | 186 // Lists of available / enabled / uninitialized technologies |
183 std::set<std::string> available_technologies_; | 187 std::set<std::string> available_technologies_; |
184 std::set<std::string> enabled_technologies_; | 188 std::set<std::string> enabled_technologies_; |
185 std::set<std::string> uninitialized_technologies_; | 189 std::set<std::string> uninitialized_technologies_; |
186 | 190 |
187 // For Shill client callbacks | |
188 base::WeakPtrFactory<ShillPropertyHandler> weak_ptr_factory_; | |
189 | |
190 DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandler); | 191 DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandler); |
191 }; | 192 }; |
192 | 193 |
193 } // namespace internal | 194 } // namespace internal |
194 } // namespace chromeos | 195 } // namespace chromeos |
195 | 196 |
196 #endif // CHROMEOS_NETWORK_SHILL_PROPERTY_HANDLER_H_ | 197 #endif // CHROMEOS_NETWORK_SHILL_PROPERTY_HANDLER_H_ |
OLD | NEW |