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 #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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 for (auto iter = tether_network_list_.begin(); | 587 for (auto iter = tether_network_list_.begin(); |
| 588 iter != tether_network_list_.end(); ++iter) { | 588 iter != tether_network_list_.end(); ++iter) { |
| 589 if (iter->get()->AsNetworkState()->guid() == guid) { | 589 if (iter->get()->AsNetworkState()->guid() == guid) { |
| 590 NetworkState* wifi_network = GetModifiableNetworkStateFromGuid( | 590 NetworkState* wifi_network = GetModifiableNetworkStateFromGuid( |
| 591 iter->get()->AsNetworkState()->tether_guid()); | 591 iter->get()->AsNetworkState()->tether_guid()); |
| 592 if (wifi_network) | 592 if (wifi_network) |
| 593 wifi_network->set_tether_guid(std::string()); | 593 wifi_network->set_tether_guid(std::string()); |
| 594 | 594 |
| 595 tether_network_list_.erase(iter); | 595 tether_network_list_.erase(iter); |
| 596 NotifyNetworkListChanged(); | 596 NotifyNetworkListChanged(); |
| 597 | |
| 597 return true; | 598 return true; |
| 598 } | 599 } |
| 599 } | 600 } |
| 601 return false; | |
| 602 } | |
| 600 | 603 |
| 601 return false; | 604 bool NetworkStateHandler::DisassociateTetherNetworkStateFromWifiNetwork( |
| 605 const std::string& tether_network_guid, | |
| 606 const std::string& wifi_network_guid) { | |
|
stevenjb
2017/05/03 23:02:21
We shouldn't need wifi_network_guid here? This sho
lesliewatkins
2017/05/04 01:40:16
I didn't do the DCHECK part because I'm not exactl
| |
| 607 bool success = true; | |
| 608 bool tether_network_changed = false; | |
| 609 bool wifi_network_changed = false; | |
| 610 | |
| 611 NetworkState* tether_network = | |
| 612 GetModifiableNetworkStateFromGuid(tether_network_guid); | |
| 613 NetworkState* wifi_network = | |
| 614 GetModifiableNetworkStateFromGuid(wifi_network_guid); | |
| 615 | |
| 616 if (!tether_network) { | |
| 617 NET_LOG(ERROR) << "DisassociateTetherNetworkStateWithWifiNetwork(): Tether " | |
| 618 << "network with ID " << tether_network_guid | |
|
Kyle Horimoto
2017/05/03 22:47:28
super nit: I usually append a << " " at the end of
lesliewatkins
2017/05/04 01:40:16
Done.
| |
| 619 << " not registered; could not remove association."; | |
| 620 success = false; | |
| 621 } else { | |
| 622 tether_network->set_tether_guid(std::string()); | |
| 623 tether_network_changed = true; | |
| 624 } | |
| 625 | |
| 626 if (!wifi_network) { | |
| 627 NET_LOG(ERROR) << "DisassociateTetherNetworkStateWithWifiNetwork(): Wi-Fi " | |
| 628 << "network with ID " << wifi_network_guid | |
| 629 << " not registered; could not remove association."; | |
| 630 success = false; | |
| 631 } else { | |
| 632 wifi_network->set_tether_guid(std::string()); | |
| 633 wifi_network_changed = true; | |
| 634 } | |
| 635 | |
| 636 if (tether_network_changed || wifi_network_changed) | |
| 637 NotifyNetworkListChanged(); | |
| 638 | |
| 639 return success; | |
|
Kyle Horimoto
2017/05/03 22:47:28
You no longer need a success boolean. Just return
lesliewatkins
2017/05/04 01:40:16
Done.
| |
| 602 } | 640 } |
| 603 | 641 |
| 604 bool NetworkStateHandler::AssociateTetherNetworkStateWithWifiNetwork( | 642 bool NetworkStateHandler::AssociateTetherNetworkStateWithWifiNetwork( |
| 605 const std::string& tether_network_guid, | 643 const std::string& tether_network_guid, |
| 606 const std::string& wifi_network_guid) { | 644 const std::string& wifi_network_guid) { |
| 607 if (tether_technology_state_ != TECHNOLOGY_ENABLED) { | 645 if (tether_technology_state_ != TECHNOLOGY_ENABLED) { |
| 608 NET_LOG(ERROR) << "AssociateTetherNetworkStateWithWifiNetwork() called " | 646 NET_LOG(ERROR) << "AssociateTetherNetworkStateWithWifiNetwork() called " |
| 609 << "when Tether networks are not enabled. Cannot " | 647 << "when Tether networks are not enabled. Cannot " |
| 610 << "associate."; | 648 << "associate."; |
| 611 return false; | 649 return false; |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1443 if (type.MatchesType(shill::kTypeVPN)) | 1481 if (type.MatchesType(shill::kTypeVPN)) |
| 1444 technologies.emplace_back(shill::kTypeVPN); | 1482 technologies.emplace_back(shill::kTypeVPN); |
| 1445 if (type.MatchesType(kTypeTether)) | 1483 if (type.MatchesType(kTypeTether)) |
| 1446 technologies.emplace_back(kTypeTether); | 1484 technologies.emplace_back(kTypeTether); |
| 1447 | 1485 |
| 1448 CHECK_GT(technologies.size(), 0ul); | 1486 CHECK_GT(technologies.size(), 0ul); |
| 1449 return technologies; | 1487 return technologies; |
| 1450 } | 1488 } |
| 1451 | 1489 |
| 1452 } // namespace chromeos | 1490 } // namespace chromeos |
| OLD | NEW |