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_NETWORK_STATE_HANDLER_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
6 #define CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 30 matching lines...) Expand all Loading... |
41 // | 41 // |
42 // This class maps essential properties from the connection manager (Shill) for | 42 // This class maps essential properties from the connection manager (Shill) for |
43 // each visible network. It is not used to change the properties of services or | 43 // each visible network. It is not used to change the properties of services or |
44 // devices, only global (manager) properties. | 44 // devices, only global (manager) properties. |
45 // | 45 // |
46 // All getters return the currently cached properties. This class is expected to | 46 // All getters return the currently cached properties. This class is expected to |
47 // keep properties up to date by managing the appropriate Shill observers. | 47 // keep properties up to date by managing the appropriate Shill observers. |
48 // It will invoke its own more specific observer methods when the specified | 48 // It will invoke its own more specific observer methods when the specified |
49 // changes occur. | 49 // changes occur. |
50 // | 50 // |
51 // Most *ByType or *ForType methods will accept any of the following for | 51 // Most *ByType or *ForType methods will accept any of the following for |type|. |
52 // |type|. See individual methods for specific notes. | 52 // See individual methods for specific notes. |
53 // * Any type defined in service_constants.h (e.g. flimflam::kTypeWifi) | 53 // * Any type defined in service_constants.h (e.g. flimflam::kTypeWifi) |
54 // * kMatchTypeDefault returns the default (active) network | 54 // * kMatchTypeDefault returns the default (active) network |
55 // * kMatchTypeNonVirtual returns the primary non virtual network | 55 // * kMatchTypeNonVirtual returns the primary non virtual network |
| 56 // * kMatchTypeWired returns the primary wired network |
56 // * kMatchTypeWireless returns the primary wireless network | 57 // * kMatchTypeWireless returns the primary wireless network |
57 // * kMatchTypeMobile returns the primary cellular or wimax network | 58 // * kMatchTypeMobile returns the primary cellular or wimax network |
58 | 59 |
59 class CHROMEOS_EXPORT NetworkStateHandler | 60 class CHROMEOS_EXPORT NetworkStateHandler |
60 : public internal::ShillPropertyHandler::Listener { | 61 : public internal::ShillPropertyHandler::Listener { |
61 public: | 62 public: |
62 typedef std::vector<ManagedState*> ManagedStateList; | 63 typedef std::vector<ManagedState*> ManagedStateList; |
63 typedef std::vector<const NetworkState*> NetworkStateList; | 64 typedef std::vector<const NetworkState*> NetworkStateList; |
64 typedef std::vector<const DeviceState*> DeviceStateList; | 65 typedef std::vector<const DeviceState*> DeviceStateList; |
65 typedef std::vector<const FavoriteState*> FavoriteStateList; | 66 typedef std::vector<const FavoriteState*> FavoriteStateList; |
(...skipping 12 matching lines...) Expand all Loading... |
78 void AddObserver(NetworkStateHandlerObserver* observer, | 79 void AddObserver(NetworkStateHandlerObserver* observer, |
79 const tracked_objects::Location& from_here); | 80 const tracked_objects::Location& from_here); |
80 void RemoveObserver(NetworkStateHandlerObserver* observer, | 81 void RemoveObserver(NetworkStateHandlerObserver* observer, |
81 const tracked_objects::Location& from_here); | 82 const tracked_objects::Location& from_here); |
82 | 83 |
83 // Requests all Manager properties, specifically to update the complete | 84 // Requests all Manager properties, specifically to update the complete |
84 // list of services which determines the list of Favorites. This should be | 85 // list of services which determines the list of Favorites. This should be |
85 // called any time a new service is configured or a Profile is loaded. | 86 // called any time a new service is configured or a Profile is loaded. |
86 void UpdateManagerProperties(); | 87 void UpdateManagerProperties(); |
87 | 88 |
88 // Returns the state for technology |type|. kMatchTypeMobile (only) is | 89 // Returns the state for technology |type|. kMatchTypeMobile and |
89 // also supported. | 90 // kMatchTypeWired (and no other kMatchType*) are also supported. |
90 TechnologyState GetTechnologyState(const std::string& type) const; | 91 TechnologyState GetTechnologyState(const std::string& type) const; |
91 bool IsTechnologyAvailable(const std::string& type) const { | 92 bool IsTechnologyAvailable(const std::string& type) const { |
92 return GetTechnologyState(type) != TECHNOLOGY_UNAVAILABLE; | 93 return GetTechnologyState(type) != TECHNOLOGY_UNAVAILABLE; |
93 } | 94 } |
94 bool IsTechnologyEnabled(const std::string& type) const { | 95 bool IsTechnologyEnabled(const std::string& type) const { |
95 return GetTechnologyState(type) == TECHNOLOGY_ENABLED; | 96 return GetTechnologyState(type) == TECHNOLOGY_ENABLED; |
96 } | 97 } |
97 | 98 |
98 // Asynchronously sets the technology enabled property for |type|. | 99 // Asynchronously sets the technology enabled property for |type|. |
99 // kMatchTypeMobile (only) is also supported. | 100 // kMatchTypeMobile and kMatchTypeWired (and no other kMatchType*) are also |
| 101 // supported. |
100 // Note: Modifies Manager state. Calls |error_callback| on failure. | 102 // Note: Modifies Manager state. Calls |error_callback| on failure. |
101 void SetTechnologyEnabled( | 103 void SetTechnologyEnabled( |
102 const std::string& type, | 104 const std::string& type, |
103 bool enabled, | 105 bool enabled, |
104 const network_handler::ErrorCallback& error_callback); | 106 const network_handler::ErrorCallback& error_callback); |
105 | 107 |
106 // Finds and returns a device state by |device_path| or NULL if not found. | 108 // Finds and returns a device state by |device_path| or NULL if not found. |
107 const DeviceState* GetDeviceState(const std::string& device_path) const; | 109 const DeviceState* GetDeviceState(const std::string& device_path) const; |
108 | 110 |
109 // Finds and returns a device state by |type|. Returns NULL if not found. | 111 // Finds and returns a device state by |type|. Returns NULL if not found. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 201 |
200 // Generates a DictionaryValue of all NetworkState properties. Currently | 202 // Generates a DictionaryValue of all NetworkState properties. Currently |
201 // provided for debugging purposes only. | 203 // provided for debugging purposes only. |
202 void GetNetworkStatePropertiesForTest( | 204 void GetNetworkStatePropertiesForTest( |
203 base::DictionaryValue* dictionary) const; | 205 base::DictionaryValue* dictionary) const; |
204 | 206 |
205 // Construct and initialize an instance for testing. | 207 // Construct and initialize an instance for testing. |
206 static NetworkStateHandler* InitializeForTest(); | 208 static NetworkStateHandler* InitializeForTest(); |
207 | 209 |
208 static const char kMatchTypeDefault[]; | 210 static const char kMatchTypeDefault[]; |
| 211 static const char kMatchTypeWired[]; |
209 static const char kMatchTypeWireless[]; | 212 static const char kMatchTypeWireless[]; |
210 static const char kMatchTypeMobile[]; | 213 static const char kMatchTypeMobile[]; |
211 static const char kMatchTypeNonVirtual[]; | 214 static const char kMatchTypeNonVirtual[]; |
212 | 215 |
213 // Default set of comma separated interfaces on which to enable | 216 // Default set of comma separated interfaces on which to enable |
214 // portal checking. | 217 // portal checking. |
215 static const char kDefaultCheckPortalList[]; | 218 static const char kDefaultCheckPortalList[]; |
216 | 219 |
217 protected: | 220 protected: |
218 friend class NetworkHandler; | 221 friend class NetworkHandler; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 337 |
335 // Callbacks to run when a scan for the technology type completes. | 338 // Callbacks to run when a scan for the technology type completes. |
336 ScanCompleteCallbackMap scan_complete_callbacks_; | 339 ScanCompleteCallbackMap scan_complete_callbacks_; |
337 | 340 |
338 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); | 341 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); |
339 }; | 342 }; |
340 | 343 |
341 } // namespace chromeos | 344 } // namespace chromeos |
342 | 345 |
343 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ | 346 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
OLD | NEW |