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. | |
stevenjb
2017/06/22 00:25:20
This isn't really necessary/helpful, the name is c
Kyle Horimoto
2017/06/22 02:08:01
Done.
| |
74 class TetherSortDelegate { | |
75 public: | |
76 // Sorts the list so that the highest-priority networks are in the front of | |
77 // the list. | |
stevenjb
2017/06/22 00:25:20
This should be more generic::
// Sorts |tether_ne
Kyle Horimoto
2017/06/22 02:08:01
Done.
| |
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. | |
stevenjb
2017/06/22 00:25:20
No need for a comment for a trivial setter.
Kyle Horimoto
2017/06/22 02:08:01
Done.
| |
281 void set_tether_sort_delegate( | |
282 const TetherSortDelegate* tether_sort_delegate) { | |
283 tether_sort_delegate_ = tether_sort_delegate; | |
284 } | |
285 | |
270 // Sets |list| to contain the list of devices. The returned list contains | 286 // 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 | 287 // 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 | 288 // the scope of the calling function (i.e. they may later become invalid, but |
273 // only on the UI thread). | 289 // only on the UI thread). |
274 void GetDeviceList(DeviceStateList* list) const; | 290 void GetDeviceList(DeviceStateList* list) const; |
275 | 291 |
276 // Like GetDeviceList() but only returns networks with matching |type|. | 292 // Like GetDeviceList() but only returns networks with matching |type|. |
277 void GetDeviceListByType(const NetworkTypePattern& type, | 293 void GetDeviceListByType(const NetworkTypePattern& type, |
278 DeviceStateList* list) const; | 294 DeviceStateList* list) const; |
279 | 295 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |