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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 RequestScan(); | 287 RequestScan(); |
288 } | 288 } |
289 | 289 |
290 void NetworkStateHandler::ConnectToBestWifiNetwork() { | 290 void NetworkStateHandler::ConnectToBestWifiNetwork() { |
291 NET_LOG_EVENT("ConnectToBestWifiNetwork", ""); | 291 NET_LOG_EVENT("ConnectToBestWifiNetwork", ""); |
292 WaitForScan(flimflam::kTypeWifi, | 292 WaitForScan(flimflam::kTypeWifi, |
293 base::Bind(&internal::ShillPropertyHandler::ConnectToBestServices, | 293 base::Bind(&internal::ShillPropertyHandler::ConnectToBestServices, |
294 shill_property_handler_->AsWeakPtr())); | 294 shill_property_handler_->AsWeakPtr())); |
295 } | 295 } |
296 | 296 |
| 297 bool NetworkStateHandler::RequestUpdateForNetwork( |
| 298 const std::string& service_path) { |
| 299 NetworkState* network = GetModifiableNetworkState(service_path); |
| 300 if (!network) |
| 301 return false; // Only request an update for known networks. |
| 302 network->set_update_requested(true); |
| 303 NET_LOG_EVENT("RequestUpdate", service_path); |
| 304 shill_property_handler_->RequestProperties( |
| 305 ManagedState::MANAGED_TYPE_NETWORK, service_path); |
| 306 return true; |
| 307 } |
| 308 |
| 309 void NetworkStateHandler::RequestUpdateForAllNetworks() { |
| 310 NET_LOG_EVENT("RequestUpdateForAllNetworks", ""); |
| 311 for (ManagedStateList::iterator iter = network_list_.begin(); |
| 312 iter != network_list_.end(); ++iter) { |
| 313 ManagedState* network = *iter; |
| 314 network->set_update_requested(true); |
| 315 shill_property_handler_->RequestProperties( |
| 316 ManagedState::MANAGED_TYPE_NETWORK, network->path()); |
| 317 } |
| 318 } |
| 319 |
297 void NetworkStateHandler::SetConnectingNetwork( | 320 void NetworkStateHandler::SetConnectingNetwork( |
298 const std::string& service_path) { | 321 const std::string& service_path) { |
299 connecting_network_ = service_path; | 322 connecting_network_ = service_path; |
300 const NetworkState* network = GetNetworkState(service_path); | 323 const NetworkState* network = GetNetworkState(service_path); |
301 if (network) | 324 if (network) |
302 NET_LOG_EVENT("SetConnectingNetwork", GetManagedStateLogName(network)); | 325 NET_LOG_EVENT("SetConnectingNetwork", GetManagedStateLogName(network)); |
303 else | 326 else |
304 NET_LOG_ERROR("SetConnectingNetwork to unknown network", service_path); | 327 NET_LOG_ERROR("SetConnectingNetwork to unknown network", service_path); |
305 } | 328 } |
306 | 329 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 if (type == ManagedState::MANAGED_TYPE_NETWORK) { | 411 if (type == ManagedState::MANAGED_TYPE_NETWORK) { |
389 if (managed->PropertyChanged(iter.key(), iter.value())) | 412 if (managed->PropertyChanged(iter.key(), iter.value())) |
390 network_property_updated = true; | 413 network_property_updated = true; |
391 } else { | 414 } else { |
392 managed->PropertyChanged(iter.key(), iter.value()); | 415 managed->PropertyChanged(iter.key(), iter.value()); |
393 } | 416 } |
394 } | 417 } |
395 managed->InitialPropertiesReceived(); | 418 managed->InitialPropertiesReceived(); |
396 NET_LOG_DEBUG("PropertiesReceived", GetManagedStateLogName(managed)); | 419 NET_LOG_DEBUG("PropertiesReceived", GetManagedStateLogName(managed)); |
397 // Notify observers. | 420 // Notify observers. |
398 if (network_property_updated) { | 421 if (network_property_updated || managed->update_requested()) { |
399 NetworkState* network = managed->AsNetworkState(); | 422 NetworkState* network = managed->AsNetworkState(); |
400 DCHECK(network); | 423 DCHECK(network); |
401 // Signal connection state changed after all properties have been updated. | 424 // Signal connection state changed after all properties have been updated. |
402 if (ConnectionStateChanged(network, prev_connection_state)) | 425 if (ConnectionStateChanged(network, prev_connection_state)) |
403 OnNetworkConnectionStateChanged(network); | 426 OnNetworkConnectionStateChanged(network); |
404 NetworkPropertiesUpdated(network); | 427 NetworkPropertiesUpdated(network); |
405 } | 428 } |
| 429 managed->set_update_requested(false); |
406 } | 430 } |
407 | 431 |
408 void NetworkStateHandler::UpdateNetworkServiceProperty( | 432 void NetworkStateHandler::UpdateNetworkServiceProperty( |
409 const std::string& service_path, | 433 const std::string& service_path, |
410 const std::string& key, | 434 const std::string& key, |
411 const base::Value& value) { | 435 const base::Value& value) { |
412 NetworkState* network = GetModifiableNetworkState(service_path); | 436 NetworkState* network = GetModifiableNetworkState(service_path); |
413 if (!network) | 437 if (!network) |
414 return; | 438 return; |
415 std::string prev_connection_state = network->connection_state(); | 439 std::string prev_connection_state = network->connection_state(); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 624 } |
601 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || | 625 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || |
602 type == kMatchTypeWireless) { | 626 type == kMatchTypeWireless) { |
603 NOTREACHED(); | 627 NOTREACHED(); |
604 return flimflam::kTypeWifi; | 628 return flimflam::kTypeWifi; |
605 } | 629 } |
606 return type; | 630 return type; |
607 } | 631 } |
608 | 632 |
609 } // namespace chromeos | 633 } // namespace chromeos |
OLD | NEW |