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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 RequestScan(); | 303 RequestScan(); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void NetworkStateHandler::ConnectToBestWifiNetwork() { | 306 void NetworkStateHandler::ConnectToBestWifiNetwork() { |
| 307 network_event_log::AddEntry(kLogModule, "ConnectToBestWifiNetwork", ""); | 307 network_event_log::AddEntry(kLogModule, "ConnectToBestWifiNetwork", ""); |
| 308 WaitForScan(flimflam::kTypeWifi, | 308 WaitForScan(flimflam::kTypeWifi, |
| 309 base::Bind(&internal::ShillPropertyHandler::ConnectToBestServices, | 309 base::Bind(&internal::ShillPropertyHandler::ConnectToBestServices, |
| 310 shill_property_handler_->AsWeakPtr())); | 310 shill_property_handler_->AsWeakPtr())); |
| 311 } | 311 } |
| 312 | 312 |
| 313 bool NetworkStateHandler::RequestUpdateForNetwork( | |
| 314 const std::string& service_path) { | |
| 315 NetworkState* network = GetModifiableNetworkState(service_path); | |
| 316 if (!network) | |
| 317 return false; // Only request an update for known networks. | |
| 318 network->set_update_requested(true); | |
| 319 network_event_log::AddEntry(kLogModule, "RequestUpdate", service_path); | |
| 320 shill_property_handler_->RequestProperties( | |
| 321 ManagedState::MANAGED_TYPE_NETWORK, service_path); | |
| 322 return true; | |
| 323 } | |
| 324 | |
| 325 void NetworkStateHandler::RequestUpdateForAllNetworks() { | |
| 326 network_event_log::AddEntry(kLogModule, "RequestUpdateForAllNetworks", ""); | |
| 327 for (ManagedStateList::iterator iter = network_list_.begin(); | |
| 328 iter != network_list_.end(); ++iter) { | |
| 329 ManagedState* network = *iter; | |
| 330 network->set_update_requested(true); | |
| 331 shill_property_handler_->RequestProperties( | |
| 332 ManagedState::MANAGED_TYPE_NETWORK, network->path()); | |
| 333 } | |
| 334 } | |
| 335 | |
| 313 void NetworkStateHandler::SetConnectingNetwork( | 336 void NetworkStateHandler::SetConnectingNetwork( |
| 314 const std::string& service_path) { | 337 const std::string& service_path) { |
| 315 connecting_network_ = service_path; | 338 connecting_network_ = service_path; |
| 316 network_event_log::AddEntry( | 339 network_event_log::AddEntry( |
| 317 kLogModule, "SetConnectingNetwork", service_path); | 340 kLogModule, "SetConnectingNetwork", service_path); |
| 318 } | 341 } |
| 319 | 342 |
| 320 void NetworkStateHandler::GetNetworkStatePropertiesForTest( | 343 void NetworkStateHandler::GetNetworkStatePropertiesForTest( |
| 321 base::DictionaryValue* dictionary) const { | 344 base::DictionaryValue* dictionary) const { |
| 322 for (ManagedStateList::const_iterator iter = network_list_.begin(); | 345 for (ManagedStateList::const_iterator iter = network_list_.begin(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 404 network_property_updated = true; | 427 network_property_updated = true; |
| 405 } else { | 428 } else { |
| 406 managed->PropertyChanged(iter.key(), iter.value()); | 429 managed->PropertyChanged(iter.key(), iter.value()); |
| 407 } | 430 } |
| 408 } | 431 } |
| 409 managed->InitialPropertiesReceived(); | 432 managed->InitialPropertiesReceived(); |
| 410 network_event_log::AddEntry( | 433 network_event_log::AddEntry( |
| 411 kLogModule, "PropertiesReceived", | 434 kLogModule, "PropertiesReceived", |
| 412 base::StringPrintf("%s (%s)", path.c_str(), managed->name().c_str())); | 435 base::StringPrintf("%s (%s)", path.c_str(), managed->name().c_str())); |
| 413 // Notify observers. | 436 // Notify observers. |
| 414 if (network_property_updated) { | 437 if (network_property_updated || managed->update_requested()) { |
|
pneubeck (no reviews)
2013/05/22 08:42:40
a comment about your intent (guaranteed notificati
stevenjb
2013/05/22 16:08:23
Good thought, comment added.
| |
| 415 NetworkState* network = managed->AsNetworkState(); | 438 NetworkState* network = managed->AsNetworkState(); |
| 416 DCHECK(network); | 439 DCHECK(network); |
| 417 // Signal connection state changed after all properties have been updated. | 440 // Signal connection state changed after all properties have been updated. |
| 418 if (ConnectionStateChanged(network, prev_connection_state)) | 441 if (ConnectionStateChanged(network, prev_connection_state)) |
| 419 OnNetworkConnectionStateChanged(network); | 442 OnNetworkConnectionStateChanged(network); |
| 420 NetworkPropertiesUpdated(network); | 443 NetworkPropertiesUpdated(network); |
| 421 } | 444 } |
| 445 managed->set_update_requested(false); | |
| 422 } | 446 } |
| 423 | 447 |
| 424 void NetworkStateHandler::UpdateNetworkServiceProperty( | 448 void NetworkStateHandler::UpdateNetworkServiceProperty( |
| 425 const std::string& service_path, | 449 const std::string& service_path, |
| 426 const std::string& key, | 450 const std::string& key, |
| 427 const base::Value& value) { | 451 const base::Value& value) { |
| 428 NetworkState* network = GetModifiableNetworkState(service_path); | 452 NetworkState* network = GetModifiableNetworkState(service_path); |
| 429 if (!network) | 453 if (!network) |
| 430 return; | 454 return; |
| 431 std::string prev_connection_state = network->connection_state(); | 455 std::string prev_connection_state = network->connection_state(); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 621 } | 645 } |
| 622 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || | 646 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || |
| 623 type == kMatchTypeWireless) { | 647 type == kMatchTypeWireless) { |
| 624 NOTREACHED(); | 648 NOTREACHED(); |
| 625 return flimflam::kTypeWifi; | 649 return flimflam::kTypeWifi; |
| 626 } | 650 } |
| 627 return type; | 651 return type; |
| 628 } | 652 } |
| 629 | 653 |
| 630 } // namespace chromeos | 654 } // namespace chromeos |
| OLD | NEW |