| 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/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 void NetworkStateHandler::UpdateNetworkServiceProperty( | 386 void NetworkStateHandler::UpdateNetworkServiceProperty( |
| 387 const std::string& service_path, | 387 const std::string& service_path, |
| 388 const std::string& key, | 388 const std::string& key, |
| 389 const base::Value& value) { | 389 const base::Value& value) { |
| 390 NetworkState* network = GetModifiableNetworkState(service_path); | 390 NetworkState* network = GetModifiableNetworkState(service_path); |
| 391 if (!network) | 391 if (!network) |
| 392 return; | 392 return; |
| 393 std::string prev_connection_state = network->connection_state(); | 393 std::string prev_connection_state = network->connection_state(); |
| 394 if (!network->PropertyChanged(key, value)) | 394 if (!network->PropertyChanged(key, value)) |
| 395 return; | 395 return; |
| 396 if (network->connection_state() != prev_connection_state) | 396 if (network->connection_state() != prev_connection_state) { |
| 397 OnNetworkConnectionStateChanged(network); | 397 OnNetworkConnectionStateChanged(network); |
| 398 } else if (network->path() == default_network_path_ && |
| 399 key != flimflam::kSignalStrengthProperty) { |
| 400 // WiFi signal strength updates are too noisy, so don't |
| 401 // trigger default network updates for those changes. |
| 402 OnDefaultNetworkChanged(); |
| 403 } |
| 398 | 404 |
| 399 NetworkPropertiesUpdated(network); | 405 NetworkPropertiesUpdated(network); |
| 400 | 406 |
| 401 std::string detail = network->name() + "." + key; | 407 std::string detail = network->name() + "." + key; |
| 402 std::string vstr = ValueAsString(value); | 408 std::string vstr = ValueAsString(value); |
| 403 if (!vstr.empty()) | 409 if (!vstr.empty()) |
| 404 detail += " = " + vstr; | 410 detail += " = " + vstr; |
| 405 network_event_log::AddEntry(kLogModule, "NetworkPropertyUpdated", detail); | 411 network_event_log::AddEntry(kLogModule, "NetworkPropertyUpdated", detail); |
| 406 } | 412 } |
| 407 | 413 |
| 408 void NetworkStateHandler::UpdateNetworkServiceIPAddress( | |
| 409 const std::string& service_path, | |
| 410 const std::string& ip_address) { | |
| 411 NetworkState* network = GetModifiableNetworkState(service_path); | |
| 412 if (!network) | |
| 413 return; | |
| 414 std::string detail = network->name() + ".IPAddress = " + ip_address; | |
| 415 network_event_log::AddEntry(kLogModule, "NetworkIPChanged", detail); | |
| 416 network->set_ip_address(ip_address); | |
| 417 NetworkPropertiesUpdated(network); | |
| 418 } | |
| 419 | |
| 420 void NetworkStateHandler::UpdateDeviceProperty(const std::string& device_path, | 414 void NetworkStateHandler::UpdateDeviceProperty(const std::string& device_path, |
| 421 const std::string& key, | 415 const std::string& key, |
| 422 const base::Value& value) { | 416 const base::Value& value) { |
| 423 DeviceState* device = GetModifiableDeviceState(device_path); | 417 DeviceState* device = GetModifiableDeviceState(device_path); |
| 424 if (!device) | 418 if (!device) |
| 425 return; | 419 return; |
| 426 if (!device->PropertyChanged(key, value)) | 420 if (!device->PropertyChanged(key, value)) |
| 427 return; | 421 return; |
| 428 | 422 |
| 429 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | 423 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 537 |
| 544 void NetworkStateHandler::NetworkPropertiesUpdated( | 538 void NetworkStateHandler::NetworkPropertiesUpdated( |
| 545 const NetworkState* network) { | 539 const NetworkState* network) { |
| 546 if (network->path() == connecting_network_ && !network->IsConnectingState()) | 540 if (network->path() == connecting_network_ && !network->IsConnectingState()) |
| 547 connecting_network_.clear(); | 541 connecting_network_.clear(); |
| 548 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, | 542 FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_, |
| 549 NetworkPropertiesUpdated(network)); | 543 NetworkPropertiesUpdated(network)); |
| 550 } | 544 } |
| 551 | 545 |
| 552 } // namespace chromeos | 546 } // namespace chromeos |
| OLD | NEW |