Chromium Code Reviews| 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 // Sorts Tether networks. Because sorting rules are determined by the Tether | |
| 73 // component, a delegate is required to sort the list. | |
| 74 class TetherNetworkListSorter { | |
|
stevenjb
2017/06/21 20:59:04
This should probably have Delegate in the name, ma
Kyle Horimoto
2017/06/21 22:17:07
Done.
| |
| 75 public: | |
| 76 // Sorts the list so that the highest-priority networks are in the front of | |
| 77 // the list. | |
| 78 virtual void SortTetherNetworkList( | |
| 79 ManagedStateList* tether_networks) const = 0; | |
| 80 }; | |
| 81 | |
| 72 enum TechnologyState { | 82 enum TechnologyState { |
| 73 TECHNOLOGY_UNAVAILABLE, | 83 TECHNOLOGY_UNAVAILABLE, |
| 74 TECHNOLOGY_AVAILABLE, | 84 TECHNOLOGY_AVAILABLE, |
| 75 TECHNOLOGY_UNINITIALIZED, | 85 TECHNOLOGY_UNINITIALIZED, |
| 76 TECHNOLOGY_ENABLING, | 86 TECHNOLOGY_ENABLING, |
| 77 TECHNOLOGY_ENABLED, | 87 TECHNOLOGY_ENABLED, |
| 78 TECHNOLOGY_PROHIBITED | 88 TECHNOLOGY_PROHIBITED |
| 79 }; | 89 }; |
| 80 | 90 |
| 81 ~NetworkStateHandler() override; | 91 ~NetworkStateHandler() override; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 void SetTetherNetworkStateDisconnected(const std::string& guid); | 270 void SetTetherNetworkStateDisconnected(const std::string& guid); |
| 261 | 271 |
| 262 // Set the connection_state of the Tether NetworkState corresponding to the | 272 // Set the connection_state of the Tether NetworkState corresponding to the |
| 263 // provided |guid| to "Connecting". This will be reflected in the UI. | 273 // provided |guid| to "Connecting". This will be reflected in the UI. |
| 264 void SetTetherNetworkStateConnecting(const std::string& guid); | 274 void SetTetherNetworkStateConnecting(const std::string& guid); |
| 265 | 275 |
| 266 // Set the connection_state of the Tether NetworkState corresponding to the | 276 // Set the connection_state of the Tether NetworkState corresponding to the |
| 267 // provided |guid| to "Connected". This will be reflected in the UI. | 277 // provided |guid| to "Connected". This will be reflected in the UI. |
| 268 void SetTetherNetworkStateConnected(const std::string& guid); | 278 void SetTetherNetworkStateConnected(const std::string& guid); |
| 269 | 279 |
| 280 // Sets the sorting delegate for Tether networks. | |
| 281 void SetTetherNetworkListSorter( | |
| 282 const TetherNetworkListSorter* tether_network_list_sorter); | |
|
stevenjb
2017/06/21 20:59:04
I wouldn't bother to check the tether technology s
Kyle Horimoto
2017/06/21 22:17:07
Done.
| |
| 283 | |
| 270 // Sets |list| to contain the list of devices. The returned list contains | 284 // 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 | 285 // 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 | 286 // the scope of the calling function (i.e. they may later become invalid, but |
| 273 // only on the UI thread). | 287 // only on the UI thread). |
| 274 void GetDeviceList(DeviceStateList* list) const; | 288 void GetDeviceList(DeviceStateList* list) const; |
| 275 | 289 |
| 276 // Like GetDeviceList() but only returns networks with matching |type|. | 290 // Like GetDeviceList() but only returns networks with matching |type|. |
| 277 void GetDeviceListByType(const NetworkTypePattern& type, | 291 void GetDeviceListByType(const NetworkTypePattern& type, |
| 278 DeviceStateList* list) const; | 292 DeviceStateList* list) const; |
| 279 | 293 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 | 530 |
| 517 // Map of network specifiers to guids. Contains an entry for each | 531 // Map of network specifiers to guids. Contains an entry for each |
| 518 // NetworkState that is not saved in a profile. | 532 // NetworkState that is not saved in a profile. |
| 519 SpecifierGuidMap specifier_guid_map_; | 533 SpecifierGuidMap specifier_guid_map_; |
| 520 | 534 |
| 521 // The state corresponding to the Tether device type. This value is managed by | 535 // The state corresponding to the Tether device type. This value is managed by |
| 522 // the Tether component. | 536 // the Tether component. |
| 523 TechnologyState tether_technology_state_ = | 537 TechnologyState tether_technology_state_ = |
| 524 TechnologyState::TECHNOLOGY_UNAVAILABLE; | 538 TechnologyState::TECHNOLOGY_UNAVAILABLE; |
| 525 | 539 |
| 540 // Not owned by this instance. | |
| 541 const TetherNetworkListSorter* tether_network_list_sorter_ = nullptr; | |
| 542 | |
| 526 // Ensure that Shutdown() gets called exactly once. | 543 // Ensure that Shutdown() gets called exactly once. |
| 527 bool did_shutdown_ = false; | 544 bool did_shutdown_ = false; |
| 528 | 545 |
| 529 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); | 546 DISALLOW_COPY_AND_ASSIGN(NetworkStateHandler); |
| 530 }; | 547 }; |
| 531 | 548 |
| 532 } // namespace chromeos | 549 } // namespace chromeos |
| 533 | 550 |
| 534 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ | 551 #endif // CHROMEOS_NETWORK_NETWORK_STATE_HANDLER_H_ |
| OLD | NEW |