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 #include "chromeos/network/network_state_handler.h" | 5 #include "chromeos/network/network_state_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 | 557 |
558 tether_network_state->set_carrier(carrier); | 558 tether_network_state->set_carrier(carrier); |
559 tether_network_state->set_battery_percentage(battery_percentage); | 559 tether_network_state->set_battery_percentage(battery_percentage); |
560 tether_network_state->set_signal_strength(signal_strength); | 560 tether_network_state->set_signal_strength(signal_strength); |
561 | 561 |
562 NotifyNetworkListChanged(); | 562 NotifyNetworkListChanged(); |
563 return true; | 563 return true; |
564 } | 564 } |
565 | 565 |
566 void NetworkStateHandler::RemoveTetherNetworkState(const std::string& guid) { | 566 void NetworkStateHandler::RemoveTetherNetworkState(const std::string& guid) { |
567 for (auto iter = tether_network_list_.begin(); | 567 auto iter = DisassociateTetherNetworkStateWithWifiNetwork(guid); |
568 iter != tether_network_list_.end(); ++iter) { | 568 if (iter != tether_network_list_.end()) { |
569 tether_network_list_.erase(iter); | |
570 NotifyNetworkListChanged(); | |
571 } | |
572 return; | |
573 } | |
574 | |
575 NetworkStateHandler::ManagedStateList::iterator | |
576 NetworkStateHandler::DisassociateTetherNetworkStateWithWifiNetwork( | |
577 const std::string& guid) { | |
578 ManagedStateList::iterator iter = tether_network_list_.begin(); | |
Kyle Horimoto
2017/05/01 17:09:26
Use this:
for (const auto& tether_network : tethe
lesliewatkins
2017/05/03 01:23:23
I just reverted back to the old RemoveTetherNetwor
| |
579 for (; iter != tether_network_list_.end(); ++iter) { | |
569 if (iter->get()->AsNetworkState()->guid() == guid) { | 580 if (iter->get()->AsNetworkState()->guid() == guid) { |
570 NetworkState* wifi_network = GetModifiableNetworkStateFromGuid( | 581 NetworkState* tether_network = iter->get()->AsNetworkState(); |
571 iter->get()->AsNetworkState()->tether_guid()); | 582 NetworkState* wifi_network = |
583 GetModifiableNetworkStateFromGuid(tether_network->tether_guid()); | |
572 if (wifi_network) | 584 if (wifi_network) |
573 wifi_network->set_tether_guid(std::string()); | 585 wifi_network->set_tether_guid(std::string()); |
574 | 586 tether_network->set_tether_guid(std::string()); |
575 tether_network_list_.erase(iter); | 587 return iter; |
576 NotifyNetworkListChanged(); | |
577 return; | |
578 } | 588 } |
579 } | 589 } |
590 return iter; | |
580 } | 591 } |
581 | 592 |
582 bool NetworkStateHandler::AssociateTetherNetworkStateWithWifiNetwork( | 593 bool NetworkStateHandler::AssociateTetherNetworkStateWithWifiNetwork( |
583 const std::string& tether_network_guid, | 594 const std::string& tether_network_guid, |
584 const std::string& wifi_network_guid) { | 595 const std::string& wifi_network_guid) { |
585 if (tether_technology_state_ != TECHNOLOGY_ENABLED) { | 596 if (tether_technology_state_ != TECHNOLOGY_ENABLED) { |
586 NET_LOG(ERROR) << "AssociateTetherNetworkStateWithWifiNetwork() called " | 597 NET_LOG(ERROR) << "AssociateTetherNetworkStateWithWifiNetwork() called " |
587 << "when Tether networks are not enabled. Cannot " | 598 << "when Tether networks are not enabled. Cannot " |
588 << "associate."; | 599 << "associate."; |
589 return false; | 600 return false; |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1421 if (type.MatchesType(shill::kTypeVPN)) | 1432 if (type.MatchesType(shill::kTypeVPN)) |
1422 technologies.emplace_back(shill::kTypeVPN); | 1433 technologies.emplace_back(shill::kTypeVPN); |
1423 if (type.MatchesType(kTypeTether)) | 1434 if (type.MatchesType(kTypeTether)) |
1424 technologies.emplace_back(kTypeTether); | 1435 technologies.emplace_back(kTypeTether); |
1425 | 1436 |
1426 CHECK_GT(technologies.size(), 0ul); | 1437 CHECK_GT(technologies.size(), 0ul); |
1427 return technologies; | 1438 return technologies; |
1428 } | 1439 } |
1429 | 1440 |
1430 } // namespace chromeos | 1441 } // namespace chromeos |
OLD | NEW |