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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // Returns true if any device of |type| is scanning. | 114 // Returns true if any device of |type| is scanning. |
115 bool GetScanningByType(const NetworkTypePattern& type) const; | 115 bool GetScanningByType(const NetworkTypePattern& type) const; |
116 | 116 |
117 // Finds and returns a network state by |service_path| or NULL if not found. | 117 // Finds and returns a network state by |service_path| or NULL if not found. |
118 // Note: NetworkState is frequently updated asynchronously, i.e. properties | 118 // Note: NetworkState is frequently updated asynchronously, i.e. properties |
119 // are not always updated all at once. This will contain the most recent | 119 // are not always updated all at once. This will contain the most recent |
120 // value for each property. To receive notifications when a property changes, | 120 // value for each property. To receive notifications when a property changes, |
121 // observe this class and implement NetworkPropertyChanged(). | 121 // observe this class and implement NetworkPropertyChanged(). |
122 const NetworkState* GetNetworkState(const std::string& service_path) const; | 122 const NetworkState* GetNetworkState(const std::string& service_path) const; |
123 | 123 |
124 // Returns the default connected network (which includes VPNs) or NULL. | 124 // Returns the default network (which includes VPNs) based on the |
125 // This is equivalent to ConnectedNetworkByType(kMatchTypeDefault). | 125 // Shill Manager.DefaultNetwork property. Normally this is the same as |
| 126 // ConnectedNetworkByType(kMatchTypeDefault), but the timing might differ. |
126 const NetworkState* DefaultNetwork() const; | 127 const NetworkState* DefaultNetwork() const; |
127 | 128 |
128 // Returns the FavoriteState associated to DefaultNetwork. Returns NULL if, | 129 // Returns the FavoriteState associated to DefaultNetwork. Returns NULL if, |
129 // and only if, DefaultNetwork returns NULL. | 130 // and only if, DefaultNetwork returns NULL. |
130 const FavoriteState* DefaultFavoriteNetwork() const; | 131 const FavoriteState* DefaultFavoriteNetwork() const; |
131 | 132 |
132 // Returns the primary connected network of matching |type|, otherwise NULL. | 133 // Returns the primary connected network of matching |type|, otherwise NULL. |
133 const NetworkState* ConnectedNetworkByType( | 134 const NetworkState* ConnectedNetworkByType( |
134 const NetworkTypePattern& type) const; | 135 const NetworkTypePattern& type) const; |
135 | 136 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // Called by ShillPropertyHandler when a technology list changes. | 275 // Called by ShillPropertyHandler when a technology list changes. |
275 virtual void TechnologyListChanged() OVERRIDE; | 276 virtual void TechnologyListChanged() OVERRIDE; |
276 | 277 |
277 // Called by |shill_property_handler_| when the service or device list has | 278 // Called by |shill_property_handler_| when the service or device list has |
278 // changed and all entries have been updated. This updates the list and | 279 // changed and all entries have been updated. This updates the list and |
279 // notifies observers. If |type| == TYPE_NETWORK this also calls | 280 // notifies observers. If |type| == TYPE_NETWORK this also calls |
280 // CheckDefaultNetworkChanged(). | 281 // CheckDefaultNetworkChanged(). |
281 virtual void ManagedStateListChanged( | 282 virtual void ManagedStateListChanged( |
282 ManagedState::ManagedType type) OVERRIDE; | 283 ManagedState::ManagedType type) OVERRIDE; |
283 | 284 |
| 285 // Called when the default network service changes. Sets default_network_path_ |
| 286 // and notifies listeners. |
| 287 virtual void DefaultNetworkServiceChanged( |
| 288 const std::string& service_path) OVERRIDE; |
| 289 |
284 // Called after construction. Called explicitly by tests after adding | 290 // Called after construction. Called explicitly by tests after adding |
285 // test observers. | 291 // test observers. |
286 void InitShillPropertyHandler(); | 292 void InitShillPropertyHandler(); |
287 | 293 |
288 private: | 294 private: |
289 typedef std::list<base::Closure> ScanCallbackList; | 295 typedef std::list<base::Closure> ScanCallbackList; |
290 typedef std::map<std::string, ScanCallbackList> ScanCompleteCallbackMap; | 296 typedef std::map<std::string, ScanCallbackList> ScanCompleteCallbackMap; |
291 friend class NetworkStateHandlerTest; | 297 friend class NetworkStateHandlerTest; |
292 FRIEND_TEST_ALL_PREFIXES(NetworkStateHandlerTest, NetworkStateHandlerStub); | 298 FRIEND_TEST_ALL_PREFIXES(NetworkStateHandlerTest, NetworkStateHandlerStub); |
293 | 299 |
(...skipping 13 matching lines...) Expand all Loading... |
307 const std::string& service_path) const; | 313 const std::string& service_path) const; |
308 ManagedState* GetModifiableManagedState(const ManagedStateList* managed_list, | 314 ManagedState* GetModifiableManagedState(const ManagedStateList* managed_list, |
309 const std::string& path) const; | 315 const std::string& path) const; |
310 | 316 |
311 // Gets the list specified by |type|. | 317 // Gets the list specified by |type|. |
312 ManagedStateList* GetManagedList(ManagedState::ManagedType type); | 318 ManagedStateList* GetManagedList(ManagedState::ManagedType type); |
313 | 319 |
314 // Helper function to notify observers. Calls CheckDefaultNetworkChanged(). | 320 // Helper function to notify observers. Calls CheckDefaultNetworkChanged(). |
315 void OnNetworkConnectionStateChanged(NetworkState* network); | 321 void OnNetworkConnectionStateChanged(NetworkState* network); |
316 | 322 |
317 // If the default network changed returns true and sets | 323 // Notifies observers when the default network or its properties change. |
318 // |default_network_path_|. | 324 void NotifyDefaultNetworkChanged(const NetworkState* default_network); |
319 bool CheckDefaultNetworkChanged(); | |
320 | |
321 // Logs an event and notifies observers. | |
322 void OnDefaultNetworkChanged(); | |
323 | 325 |
324 // Notifies observers about changes to |network|. | 326 // Notifies observers about changes to |network|. |
325 void NetworkPropertiesUpdated(const NetworkState* network); | 327 void NotifyNetworkPropertiesUpdated(const NetworkState* network); |
326 | 328 |
327 // Called whenever Device.Scanning state transitions to false. | 329 // Called whenever Device.Scanning state transitions to false. |
328 void ScanCompleted(const std::string& type); | 330 void ScanCompleted(const std::string& type); |
329 | 331 |
330 // Returns the technology type for |type|. | 332 // Returns the technology type for |type|. |
331 std::string GetTechnologyForType(const NetworkTypePattern& type) const; | 333 std::string GetTechnologyForType(const NetworkTypePattern& type) const; |
332 | 334 |
333 // Shill property handler instance, owned by this class. | 335 // Shill property handler instance, owned by this class. |
334 scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_; | 336 scoped_ptr<internal::ShillPropertyHandler> shill_property_handler_; |
335 | 337 |
(...skipping 19 matching lines...) Expand all Loading... |
355 | 357 |
356 // Callbacks to run when a scan for the technology type completes. | 358 // Callbacks to run when a scan for the technology type completes. |
357 ScanCompleteCallbackMap scan_complete_callbacks_; | 359 ScanCompleteCallbackMap scan_complete_callbacks_; |
358 | 360 |
359 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); | 361 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); |
360 }; | 362 }; |
361 | 363 |
362 } // namespace chromeos | 364 } // namespace chromeos |
363 | 365 |
364 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ | 366 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
OLD | NEW |