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

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

Issue 14137017: Add TechnologyState to NetworkStateHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 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
« no previous file with comments | « chromeos/network/device_state.cc ('k') | chromeos/network/network_state_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // * kMatchTypeNonVirtual returns the primary non virtual network 50 // * kMatchTypeNonVirtual returns the primary non virtual network
51 // * kMatchTypeWireless returns the primary wireless network 51 // * kMatchTypeWireless returns the primary wireless network
52 // * kMatchTypeMobile returns the primary cellular or wimax network 52 // * kMatchTypeMobile returns the primary cellular or wimax network
53 53
54 class CHROMEOS_EXPORT NetworkStateHandler 54 class CHROMEOS_EXPORT NetworkStateHandler
55 : public internal::ShillPropertyHandler::Listener { 55 : public internal::ShillPropertyHandler::Listener {
56 public: 56 public:
57 typedef std::vector<ManagedState*> ManagedStateList; 57 typedef std::vector<ManagedState*> ManagedStateList;
58 typedef std::vector<const NetworkState*> NetworkStateList; 58 typedef std::vector<const NetworkState*> NetworkStateList;
59 59
60 enum TechnologyState {
61 TECHNOLOGY_UNAVAILABLE,
62 TECHNOLOGY_AVAILABLE,
63 TECHNOLOGY_UNINITIALIZED,
64 TECHNOLOGY_ENABLING,
65 TECHNOLOGY_ENABLED
66 };
67
60 virtual ~NetworkStateHandler(); 68 virtual ~NetworkStateHandler();
61 69
62 // Sets the global instance. Must be called before any calls to Get(). 70 // Sets the global instance. Must be called before any calls to Get().
63 static void Initialize(); 71 static void Initialize();
64 72
65 // Returns true if the global instance has been initialized. 73 // Returns true if the global instance has been initialized.
66 static bool IsInitialized(); 74 static bool IsInitialized();
67 75
68 // Destroys the global instance. 76 // Destroys the global instance.
69 static void Shutdown(); 77 static void Shutdown();
70 78
71 // Gets the global instance. Initialize() must be called first. 79 // Gets the global instance. Initialize() must be called first.
72 static NetworkStateHandler* Get(); 80 static NetworkStateHandler* Get();
73 81
74 // Add/remove observers. 82 // Add/remove observers.
75 void AddObserver(NetworkStateHandlerObserver* observer); 83 void AddObserver(NetworkStateHandlerObserver* observer);
76 void RemoveObserver(NetworkStateHandlerObserver* observer); 84 void RemoveObserver(NetworkStateHandlerObserver* observer);
77 85
78 // Returns true if technology for |type| is available/ enabled/uninitialized. 86 // Returns the state for technology |type|. kMatchTypeMobile (only) is
79 // kMatchTypeMobile (only) is also supported. 87 // also supported.
80 bool TechnologyAvailable(const std::string& type) const; 88 TechnologyState GetTechnologyState(const std::string& type) const;
81 bool TechnologyEnabled(const std::string& type) const; 89 bool IsTechnologyEnabled(const std::string& type) const {
82 bool TechnologyUninitialized(const std::string& type) const; 90 return GetTechnologyState(type) == TECHNOLOGY_ENABLED;
91 }
83 92
84 // Asynchronously sets the technology enabled property for |type|. 93 // Asynchronously sets the technology enabled property for |type|.
85 // kMatchTypeMobile (only) is also supported. 94 // kMatchTypeMobile (only) is also supported.
86 // Note: Modifies Manager state. Calls |error_callback| on failure. 95 // Note: Modifies Manager state. Calls |error_callback| on failure.
87 void SetTechnologyEnabled( 96 void SetTechnologyEnabled(
88 const std::string& type, 97 const std::string& type,
89 bool enabled, 98 bool enabled,
90 const network_handler::ErrorCallback& error_callback); 99 const network_handler::ErrorCallback& error_callback);
91 100
92 // Finds and returns a device state by |device_path| or NULL if not found. 101 // Finds and returns a device state by |device_path| or NULL if not found.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 246
238 // Logs an event and notifies observers. 247 // Logs an event and notifies observers.
239 void OnDefaultNetworkChanged(); 248 void OnDefaultNetworkChanged();
240 249
241 // Notifies observers and updates connecting_network_. 250 // Notifies observers and updates connecting_network_.
242 void NetworkPropertiesUpdated(const NetworkState* network); 251 void NetworkPropertiesUpdated(const NetworkState* network);
243 252
244 // Called whenever Device.Scanning state transitions to false. 253 // Called whenever Device.Scanning state transitions to false.
245 void ScanCompleted(const std::string& type); 254 void ScanCompleted(const std::string& type);
246 255
256 // Returns the technology type for |type|.
257 std::string GetTechnologyForType(const std::string& type) const;
258
247 // Shill property handler instance, owned by this class. 259 // Shill property handler instance, owned by this class.
248 scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_; 260 scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_;
249 261
250 // Observer list 262 // Observer list
251 ObserverList<NetworkStateHandlerObserver> observers_; 263 ObserverList<NetworkStateHandlerObserver> observers_;
252 264
253 // Lists of managed states 265 // Lists of managed states
254 ManagedStateList network_list_; 266 ManagedStateList network_list_;
255 ManagedStateList device_list_; 267 ManagedStateList device_list_;
256 268
257 // Keeps track of the default network for notifying observers when it changes. 269 // Keeps track of the default network for notifying observers when it changes.
258 std::string default_network_path_; 270 std::string default_network_path_;
259 271
260 // Convenience member to track the user initiated connecting network. Set 272 // Convenience member to track the user initiated connecting network. Set
261 // externally when a connection is requested and cleared here when the state 273 // externally when a connection is requested and cleared here when the state
262 // changes to something other than Connecting (after observers are notified). 274 // changes to something other than Connecting (after observers are notified).
263 // TODO(stevenjb): Move this to NetworkConfigurationHandler. 275 // TODO(stevenjb): Move this to NetworkConfigurationHandler.
264 std::string connecting_network_; 276 std::string connecting_network_;
265 277
266 // Callbacks to run when a scan for the technology type completes. 278 // Callbacks to run when a scan for the technology type completes.
267 ScanCompleteCallbackMap scan_complete_callbacks_; 279 ScanCompleteCallbackMap scan_complete_callbacks_;
268 280
269 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); 281 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler);
270 }; 282 };
271 283
272 } // namespace chromeos 284 } // namespace chromeos
273 285
274 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ 286 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_
OLDNEW
« no previous file with comments | « chromeos/network/device_state.cc ('k') | chromeos/network/network_state_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698