| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 NET_LOG_EVENT("RequestUpdateForAllNetworks", ""); | 361 NET_LOG_EVENT("RequestUpdateForAllNetworks", ""); |
| 362 for (ManagedStateList::iterator iter = network_list_.begin(); | 362 for (ManagedStateList::iterator iter = network_list_.begin(); |
| 363 iter != network_list_.end(); ++iter) { | 363 iter != network_list_.end(); ++iter) { |
| 364 ManagedState* network = *iter; | 364 ManagedState* network = *iter; |
| 365 network->set_update_requested(true); | 365 network->set_update_requested(true); |
| 366 shill_property_handler_->RequestProperties( | 366 shill_property_handler_->RequestProperties( |
| 367 ManagedState::MANAGED_TYPE_NETWORK, network->path()); | 367 ManagedState::MANAGED_TYPE_NETWORK, network->path()); |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 | 370 |
| 371 void NetworkStateHandler::SetConnectingNetwork( | |
| 372 const std::string& service_path) { | |
| 373 connecting_network_ = service_path; | |
| 374 const NetworkState* network = GetNetworkState(service_path); | |
| 375 if (network) | |
| 376 NET_LOG_EVENT("SetConnectingNetwork", GetManagedStateLogName(network)); | |
| 377 else | |
| 378 NET_LOG_ERROR("SetConnectingNetwork to unknown network", service_path); | |
| 379 } | |
| 380 | |
| 381 void NetworkStateHandler::SetCheckPortalList( | 371 void NetworkStateHandler::SetCheckPortalList( |
| 382 const std::string& check_portal_list) { | 372 const std::string& check_portal_list) { |
| 383 NET_LOG_EVENT("SetCheckPortalList", check_portal_list); | 373 NET_LOG_EVENT("SetCheckPortalList", check_portal_list); |
| 384 shill_property_handler_->SetCheckPortalList(check_portal_list); | 374 shill_property_handler_->SetCheckPortalList(check_portal_list); |
| 385 } | 375 } |
| 386 | 376 |
| 387 void NetworkStateHandler::GetNetworkStatePropertiesForTest( | 377 void NetworkStateHandler::GetNetworkStatePropertiesForTest( |
| 388 base::DictionaryValue* dictionary) const { | 378 base::DictionaryValue* dictionary) const { |
| 389 for (ManagedStateList::const_iterator iter = network_list_.begin(); | 379 for (ManagedStateList::const_iterator iter = network_list_.begin(); |
| 390 iter != network_list_.end(); ++iter) { | 380 iter != network_list_.end(); ++iter) { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 NET_LOG_EVENT("DefaultNetworkChanged", | 686 NET_LOG_EVENT("DefaultNetworkChanged", |
| 697 GetManagedStateLogName(default_network)); | 687 GetManagedStateLogName(default_network)); |
| 698 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | 688 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, |
| 699 DefaultNetworkChanged(default_network)); | 689 DefaultNetworkChanged(default_network)); |
| 700 } | 690 } |
| 701 | 691 |
| 702 void NetworkStateHandler::NetworkPropertiesUpdated( | 692 void NetworkStateHandler::NetworkPropertiesUpdated( |
| 703 const NetworkState* network) { | 693 const NetworkState* network) { |
| 704 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | 694 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, |
| 705 NetworkPropertiesUpdated(network)); | 695 NetworkPropertiesUpdated(network)); |
| 706 // If |connecting_network_| transitions to a non-idle, non-connecting state, | |
| 707 // clear it *after* signaling observers. | |
| 708 if (network->path() == connecting_network_ && | |
| 709 !network->IsConnectingState() && | |
| 710 network->connection_state() != flimflam::kStateIdle) { | |
| 711 connecting_network_.clear(); | |
| 712 NET_LOG_EVENT("ClearConnectingNetwork", base::StringPrintf( | |
| 713 "%s:%s", GetManagedStateLogName(network).c_str(), | |
| 714 network->connection_state().c_str())); | |
| 715 } | |
| 716 } | 696 } |
| 717 | 697 |
| 718 void NetworkStateHandler::ScanCompleted(const std::string& type) { | 698 void NetworkStateHandler::ScanCompleted(const std::string& type) { |
| 719 size_t num_callbacks = scan_complete_callbacks_.count(type); | 699 size_t num_callbacks = scan_complete_callbacks_.count(type); |
| 720 NET_LOG_EVENT("ScanCompleted", | 700 NET_LOG_EVENT("ScanCompleted", |
| 721 base::StringPrintf("%s:%" PRIuS, type.c_str(), num_callbacks)); | 701 base::StringPrintf("%s:%" PRIuS, type.c_str(), num_callbacks)); |
| 722 if (num_callbacks == 0) | 702 if (num_callbacks == 0) |
| 723 return; | 703 return; |
| 724 ScanCallbackList& callback_list = scan_complete_callbacks_[type]; | 704 ScanCallbackList& callback_list = scan_complete_callbacks_[type]; |
| 725 for (ScanCallbackList::iterator iter = callback_list.begin(); | 705 for (ScanCallbackList::iterator iter = callback_list.begin(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 739 } | 719 } |
| 740 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || | 720 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || |
| 741 type == kMatchTypeWireless) { | 721 type == kMatchTypeWireless) { |
| 742 NOTREACHED(); | 722 NOTREACHED(); |
| 743 return flimflam::kTypeWifi; | 723 return flimflam::kTypeWifi; |
| 744 } | 724 } |
| 745 return type; | 725 return type; |
| 746 } | 726 } |
| 747 | 727 |
| 748 } // namespace chromeos | 728 } // namespace chromeos |
| OLD | NEW |