| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // favorite is visible and retrieve the complete properties (and vice-versa). | 168 // favorite is visible and retrieve the complete properties (and vice-versa). |
| 169 void GetFavoriteList(FavoriteStateList* list) const; | 169 void GetFavoriteList(FavoriteStateList* list) const; |
| 170 | 170 |
| 171 // Like GetFavoriteList() but only returns favorites with matching |type|. | 171 // Like GetFavoriteList() but only returns favorites with matching |type|. |
| 172 void GetFavoriteListByType(const NetworkTypePattern& type, | 172 void GetFavoriteListByType(const NetworkTypePattern& type, |
| 173 FavoriteStateList* list) const; | 173 FavoriteStateList* list) const; |
| 174 | 174 |
| 175 // Finds and returns a favorite state by |service_path| or NULL if not found. | 175 // Finds and returns a favorite state by |service_path| or NULL if not found. |
| 176 const FavoriteState* GetFavoriteState(const std::string& service_path) const; | 176 const FavoriteState* GetFavoriteState(const std::string& service_path) const; |
| 177 | 177 |
| 178 // Finds the FavoriteState associated with |guid|. Note: The FavoriteState |
| 179 // may or may not be in a profile (IsProfile() may be false), and may or may |
| 180 // not be visible. |
| 181 const FavoriteState* GetFavoriteStateFromGuid(const std::string& guid) const; |
| 182 |
| 178 // Requests a network scan. This may trigger updates to the network | 183 // Requests a network scan. This may trigger updates to the network |
| 179 // list, which will trigger the appropriate observer calls. | 184 // list, which will trigger the appropriate observer calls. |
| 180 void RequestScan() const; | 185 void RequestScan() const; |
| 181 | 186 |
| 182 // Request a scan if not scanning and run |callback| when the Scanning state | 187 // Request a scan if not scanning and run |callback| when the Scanning state |
| 183 // for any Device of network type |type| completes. | 188 // for any Device of network type |type| completes. |
| 184 void WaitForScan(const std::string& type, const base::Closure& callback); | 189 void WaitForScan(const std::string& type, const base::Closure& callback); |
| 185 | 190 |
| 186 // Request a network scan then signal Shill to connect to the best available | 191 // Request a network scan then signal Shill to connect to the best available |
| 187 // networks when completed. | 192 // networks when completed. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 virtual void DefaultNetworkServiceChanged( | 286 virtual void DefaultNetworkServiceChanged( |
| 282 const std::string& service_path) OVERRIDE; | 287 const std::string& service_path) OVERRIDE; |
| 283 | 288 |
| 284 // Called after construction. Called explicitly by tests after adding | 289 // Called after construction. Called explicitly by tests after adding |
| 285 // test observers. | 290 // test observers. |
| 286 void InitShillPropertyHandler(); | 291 void InitShillPropertyHandler(); |
| 287 | 292 |
| 288 private: | 293 private: |
| 289 typedef std::list<base::Closure> ScanCallbackList; | 294 typedef std::list<base::Closure> ScanCallbackList; |
| 290 typedef std::map<std::string, ScanCallbackList> ScanCompleteCallbackMap; | 295 typedef std::map<std::string, ScanCallbackList> ScanCompleteCallbackMap; |
| 296 typedef std::map<std::string, std::string> SpecifierGuidMap; |
| 291 friend class NetworkStateHandlerTest; | 297 friend class NetworkStateHandlerTest; |
| 292 FRIEND_TEST_ALL_PREFIXES(NetworkStateHandlerTest, NetworkStateHandlerStub); | 298 FRIEND_TEST_ALL_PREFIXES(NetworkStateHandlerTest, NetworkStateHandlerStub); |
| 293 | 299 |
| 294 // NetworkState specific method for UpdateManagedStateProperties which | 300 // NetworkState specific method for UpdateManagedStateProperties which |
| 295 // notifies observers. | 301 // notifies observers. |
| 296 void UpdateNetworkStateProperties(NetworkState* network, | 302 void UpdateNetworkStateProperties(NetworkState* network, |
| 297 const base::DictionaryValue& properties); | 303 const base::DictionaryValue& properties); |
| 298 | 304 |
| 305 // Ensure a valid GUID for FavoriteState and update the NetworkState GUID from |
| 306 // the corresponding FavoriteState if necessary. |
| 307 void UpdateGuid(ManagedState* managed); |
| 308 |
| 299 // Sends DeviceListChanged() to observers and logs an event. | 309 // Sends DeviceListChanged() to observers and logs an event. |
| 300 void NotifyDeviceListChanged(); | 310 void NotifyDeviceListChanged(); |
| 301 | 311 |
| 302 // Non-const getters for managed entries. These are const so that they can | 312 // Non-const getters for managed entries. These are const so that they can |
| 303 // be called by Get[Network|Device]State, even though they return non-const | 313 // be called by Get[Network|Device]State, even though they return non-const |
| 304 // pointers. | 314 // pointers. |
| 305 DeviceState* GetModifiableDeviceState(const std::string& device_path) const; | 315 DeviceState* GetModifiableDeviceState(const std::string& device_path) const; |
| 306 NetworkState* GetModifiableNetworkState( | 316 NetworkState* GetModifiableNetworkState( |
| 307 const std::string& service_path) const; | 317 const std::string& service_path) const; |
| 318 FavoriteState* GetModifiableFavoriteState( |
| 319 const std::string& service_path) const; |
| 308 ManagedState* GetModifiableManagedState(const ManagedStateList* managed_list, | 320 ManagedState* GetModifiableManagedState(const ManagedStateList* managed_list, |
| 309 const std::string& path) const; | 321 const std::string& path) const; |
| 310 | 322 |
| 311 // Gets the list specified by |type|. | 323 // Gets the list specified by |type|. |
| 312 ManagedStateList* GetManagedList(ManagedState::ManagedType type); | 324 ManagedStateList* GetManagedList(ManagedState::ManagedType type); |
| 313 | 325 |
| 314 // Helper function to notify observers. Calls CheckDefaultNetworkChanged(). | 326 // Helper function to notify observers. Calls CheckDefaultNetworkChanged(). |
| 315 void OnNetworkConnectionStateChanged(NetworkState* network); | 327 void OnNetworkConnectionStateChanged(NetworkState* network); |
| 316 | 328 |
| 317 // Notifies observers when the default network or its properties change. | 329 // Notifies observers when the default network or its properties change. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 362 |
| 351 // Keeps track of the default network for notifying observers when it changes. | 363 // Keeps track of the default network for notifying observers when it changes. |
| 352 std::string default_network_path_; | 364 std::string default_network_path_; |
| 353 | 365 |
| 354 // List of interfaces on which portal check is enabled. | 366 // List of interfaces on which portal check is enabled. |
| 355 std::string check_portal_list_; | 367 std::string check_portal_list_; |
| 356 | 368 |
| 357 // Callbacks to run when a scan for the technology type completes. | 369 // Callbacks to run when a scan for the technology type completes. |
| 358 ScanCompleteCallbackMap scan_complete_callbacks_; | 370 ScanCompleteCallbackMap scan_complete_callbacks_; |
| 359 | 371 |
| 372 // Map of network specifiers to guids. |
| 373 SpecifierGuidMap specifier_guid_map_; |
| 374 |
| 360 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); | 375 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); |
| 361 }; | 376 }; |
| 362 | 377 |
| 363 } // namespace chromeos | 378 } // namespace chromeos |
| 364 | 379 |
| 365 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ | 380 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
| OLD | NEW |