| 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 <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // the initial properties are received. The GUID will be consistent for | 62 // the initial properties are received. The GUID will be consistent for |
| 63 // the duration of a session, even if the network drops out and returns. | 63 // the duration of a session, even if the network drops out and returns. |
| 64 | 64 |
| 65 class CHROMEOS_EXPORT NetworkStateHandler | 65 class CHROMEOS_EXPORT NetworkStateHandler |
| 66 : public internal::ShillPropertyHandler::Listener { | 66 : public internal::ShillPropertyHandler::Listener { |
| 67 public: | 67 public: |
| 68 typedef std::vector<std::unique_ptr<ManagedState>> ManagedStateList; | 68 typedef std::vector<std::unique_ptr<ManagedState>> ManagedStateList; |
| 69 typedef std::vector<const NetworkState*> NetworkStateList; | 69 typedef std::vector<const NetworkState*> NetworkStateList; |
| 70 typedef std::vector<const DeviceState*> DeviceStateList; | 70 typedef std::vector<const DeviceState*> DeviceStateList; |
| 71 | 71 |
| 72 class TetherSortDelegate { |
| 73 public: |
| 74 // Sorts |tether_networks| according to the Tether component rules. |
| 75 // |tether_networks| contains only networks of type Tether. |
| 76 virtual void SortTetherNetworkList( |
| 77 ManagedStateList* tether_networks) const = 0; |
| 78 }; |
| 79 |
| 72 enum TechnologyState { | 80 enum TechnologyState { |
| 73 TECHNOLOGY_UNAVAILABLE, | 81 TECHNOLOGY_UNAVAILABLE, |
| 74 TECHNOLOGY_AVAILABLE, | 82 TECHNOLOGY_AVAILABLE, |
| 75 TECHNOLOGY_UNINITIALIZED, | 83 TECHNOLOGY_UNINITIALIZED, |
| 76 TECHNOLOGY_ENABLING, | 84 TECHNOLOGY_ENABLING, |
| 77 TECHNOLOGY_ENABLED, | 85 TECHNOLOGY_ENABLED, |
| 78 TECHNOLOGY_PROHIBITED | 86 TECHNOLOGY_PROHIBITED |
| 79 }; | 87 }; |
| 80 | 88 |
| 81 ~NetworkStateHandler() override; | 89 ~NetworkStateHandler() override; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // |visible_only| - if true only include networks in the visible Services list | 191 // |visible_only| - if true only include networks in the visible Services list |
| 184 // |limit| - if > 0 limits the number of results. | 192 // |limit| - if > 0 limits the number of results. |
| 185 // The returned list contains a copy of NetworkState pointers which should not | 193 // The returned list contains a copy of NetworkState pointers which should not |
| 186 // be stored or used beyond the scope of the calling function (i.e. they may | 194 // be stored or used beyond the scope of the calling function (i.e. they may |
| 187 // later become invalid, but only on the UI thread). SortNetworkList() will be | 195 // later become invalid, but only on the UI thread). SortNetworkList() will be |
| 188 // called if necessary to provide the states in a convenient order (see | 196 // called if necessary to provide the states in a convenient order (see |
| 189 // SortNetworkList for details). | 197 // SortNetworkList for details). |
| 190 void GetNetworkListByType(const NetworkTypePattern& type, | 198 void GetNetworkListByType(const NetworkTypePattern& type, |
| 191 bool configured_only, | 199 bool configured_only, |
| 192 bool visible_only, | 200 bool visible_only, |
| 193 int limit, | 201 size_t limit, |
| 194 NetworkStateList* list); | 202 NetworkStateList* list); |
| 195 | 203 |
| 196 // Finds and returns the NetworkState associated with |service_path| or NULL | 204 // Finds and returns the NetworkState associated with |service_path| or NULL |
| 197 // if not found. If |configured_only| is true, only returns saved entries | 205 // if not found. If |configured_only| is true, only returns saved entries |
| 198 // (IsInProfile is true). | 206 // (IsInProfile is true). |
| 199 const NetworkState* GetNetworkStateFromServicePath( | 207 const NetworkState* GetNetworkStateFromServicePath( |
| 200 const std::string& service_path, | 208 const std::string& service_path, |
| 201 bool configured_only) const; | 209 bool configured_only) const; |
| 202 | 210 |
| 203 // Finds and returns the NetworkState associated with |guid| or NULL if not | 211 // Finds and returns the NetworkState associated with |guid| or NULL if not |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 void SetTetherNetworkStateDisconnected(const std::string& guid); | 268 void SetTetherNetworkStateDisconnected(const std::string& guid); |
| 261 | 269 |
| 262 // Set the connection_state of the Tether NetworkState corresponding to the | 270 // Set the connection_state of the Tether NetworkState corresponding to the |
| 263 // provided |guid| to "Connecting". This will be reflected in the UI. | 271 // provided |guid| to "Connecting". This will be reflected in the UI. |
| 264 void SetTetherNetworkStateConnecting(const std::string& guid); | 272 void SetTetherNetworkStateConnecting(const std::string& guid); |
| 265 | 273 |
| 266 // Set the connection_state of the Tether NetworkState corresponding to the | 274 // Set the connection_state of the Tether NetworkState corresponding to the |
| 267 // provided |guid| to "Connected". This will be reflected in the UI. | 275 // provided |guid| to "Connected". This will be reflected in the UI. |
| 268 void SetTetherNetworkStateConnected(const std::string& guid); | 276 void SetTetherNetworkStateConnected(const std::string& guid); |
| 269 | 277 |
| 278 void set_tether_sort_delegate( |
| 279 const TetherSortDelegate* tether_sort_delegate) { |
| 280 tether_sort_delegate_ = tether_sort_delegate; |
| 281 } |
| 282 |
| 270 // Sets |list| to contain the list of devices. The returned list contains | 283 // Sets |list| to contain the list of devices. The returned list contains |
| 271 // a copy of DeviceState pointers which should not be stored or used beyond | 284 // a copy of DeviceState pointers which should not be stored or used beyond |
| 272 // the scope of the calling function (i.e. they may later become invalid, but | 285 // the scope of the calling function (i.e. they may later become invalid, but |
| 273 // only on the UI thread). | 286 // only on the UI thread). |
| 274 void GetDeviceList(DeviceStateList* list) const; | 287 void GetDeviceList(DeviceStateList* list) const; |
| 275 | 288 |
| 276 // Like GetDeviceList() but only returns networks with matching |type|. | 289 // Like GetDeviceList() but only returns networks with matching |type|. |
| 277 void GetDeviceListByType(const NetworkTypePattern& type, | 290 void GetDeviceListByType(const NetworkTypePattern& type, |
| 278 DeviceStateList* list) const; | 291 DeviceStateList* list) const; |
| 279 | 292 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 void NotifyScanCompleted(const DeviceState* device); | 475 void NotifyScanCompleted(const DeviceState* device); |
| 463 | 476 |
| 464 // Returns one technology type for |type|. This technology will be the | 477 // Returns one technology type for |type|. This technology will be the |
| 465 // highest priority technology in the type pattern. | 478 // highest priority technology in the type pattern. |
| 466 std::string GetTechnologyForType(const NetworkTypePattern& type) const; | 479 std::string GetTechnologyForType(const NetworkTypePattern& type) const; |
| 467 | 480 |
| 468 // Returns all the technology types for |type|. | 481 // Returns all the technology types for |type|. |
| 469 std::vector<std::string> GetTechnologiesForType( | 482 std::vector<std::string> GetTechnologiesForType( |
| 470 const NetworkTypePattern& type) const; | 483 const NetworkTypePattern& type) const; |
| 471 | 484 |
| 472 // Sets |list| to contain the list of Tether networks. If |limit| > 0, that | 485 // Adds Tether networks to |list|, limiting the maximum size of |list| to be |
| 473 // will determine the number of results; pass 0 for no limit. The returned | 486 // |limit|. If |get_active| is true, only active (i.e., connecting/connected) |
| 474 // list contains a copy of NetworkState pointers which should not be stored or | 487 // networks will be added; otherwise, only inactive networks will be added. |
| 475 // used beyond the scope of the calling function (i.e. they may later become | 488 // The returned list contains a copy of NetworkState pointers which |
| 476 // invalid, but only on the UI thread). | 489 // should not be stored or used beyond the scope of the calling |
| 477 // NOTE: See AddTetherNetworkState for more information about Tether networks. | 490 // function (i.e., they may later become invalid, but only on the UI thread). |
| 478 void GetTetherNetworkList(int limit, NetworkStateList* list); | 491 // See AddTetherNetworkState() for more information about Tether networks. |
| 492 void AppendTetherNetworksToList(bool get_active, |
| 493 size_t limit, |
| 494 NetworkStateList* list); |
| 479 | 495 |
| 480 // Set the connection_state of a Tether NetworkState corresponding to the | 496 // Set the connection_state of a Tether NetworkState corresponding to the |
| 481 // provided |guid|. | 497 // provided |guid|. |
| 482 void SetTetherNetworkStateConnectionState( | 498 void SetTetherNetworkStateConnectionState( |
| 483 const std::string& guid, | 499 const std::string& guid, |
| 484 const std::string& connection_state); | 500 const std::string& connection_state); |
| 485 | 501 |
| 486 // Ensures that the Tether DeviceState is present in |device_list_| if | 502 // Ensures that the Tether DeviceState is present in |device_list_| if |
| 487 // |tether_technology_state_| is not TECHNOLOGY_UNAVAILABLE and ensures that | 503 // |tether_technology_state_| is not TECHNOLOGY_UNAVAILABLE and ensures that |
| 488 // it is not present in |device_list_| if it is TECHNOLOGY_UNAVAILABLE. | 504 // it is not present in |device_list_| if it is TECHNOLOGY_UNAVAILABLE. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 516 | 532 |
| 517 // Map of network specifiers to guids. Contains an entry for each | 533 // Map of network specifiers to guids. Contains an entry for each |
| 518 // NetworkState that is not saved in a profile. | 534 // NetworkState that is not saved in a profile. |
| 519 SpecifierGuidMap specifier_guid_map_; | 535 SpecifierGuidMap specifier_guid_map_; |
| 520 | 536 |
| 521 // The state corresponding to the Tether device type. This value is managed by | 537 // The state corresponding to the Tether device type. This value is managed by |
| 522 // the Tether component. | 538 // the Tether component. |
| 523 TechnologyState tether_technology_state_ = | 539 TechnologyState tether_technology_state_ = |
| 524 TechnologyState::TECHNOLOGY_UNAVAILABLE; | 540 TechnologyState::TECHNOLOGY_UNAVAILABLE; |
| 525 | 541 |
| 542 // Not owned by this instance. |
| 543 const TetherSortDelegate* tether_sort_delegate_ = nullptr; |
| 544 |
| 526 // Ensure that Shutdown() gets called exactly once. | 545 // Ensure that Shutdown() gets called exactly once. |
| 527 bool did_shutdown_ = false; | 546 bool did_shutdown_ = false; |
| 528 | 547 |
| 529 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); | 548 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); |
| 530 }; | 549 }; |
| 531 | 550 |
| 532 } // namespace chromeos | 551 } // namespace chromeos |
| 533 | 552 |
| 534 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ | 553 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
| OLD | NEW |