Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: chromeos/network/network_state_handler.cc

Issue 21961003: Request updates when network state changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + fix comment Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_state_handler.cc
diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc
index e3f3dd36723214c4158be45e22ca620f2fc92233..ab3d46448691d0e6c9066e278c319035587d4f33 100644
--- a/chromeos/network/network_state_handler.cc
+++ b/chromeos/network/network_state_handler.cc
@@ -440,7 +440,7 @@ void NetworkStateHandler::UpdateManagedList(ManagedState::ManagedType type,
}
list_entries.insert(path);
}
- // Delete any remaning entries in managed_map.
+ // Delete any remaining entries in managed_map.
STLDeleteContainerPairSecondPointers(managed_map.begin(), managed_map.end());
}
@@ -524,29 +524,43 @@ void NetworkStateHandler::UpdateNetworkServiceProperty(
if (!network)
return;
std::string prev_connection_state = network->connection_state();
+ std::string prev_profile_path = network->profile_path();
if (!network->PropertyChanged(key, value))
return;
if (key == flimflam::kStateProperty) {
- if (ConnectionStateChanged(network, prev_connection_state))
+ if (ConnectionStateChanged(network, prev_connection_state)) {
OnNetworkConnectionStateChanged(network);
+ // If the connection state changes, other properties such as IPConfig
+ // may have changed, so request a full update.
+ RequestUpdateForNetwork(service_path);
+ }
} else {
- if (network->path() == default_network_path_ &&
- key != flimflam::kSignalStrengthProperty &&
- key != shill::kWifiFrequencyListProperty) {
- // WiFi SignalStrength and WifiFrequencyList updates are too noisy, so
+ bool noisy_property =
+ key == flimflam::kSignalStrengthProperty ||
+ key == shill::kWifiFrequencyListProperty;
+ if (network->path() == default_network_path_ && !noisy_property) {
+ // Wifi SignalStrength and WifiFrequencyList updates are too noisy, so
// don't trigger default network updates for those changes.
OnDefaultNetworkChanged();
}
- std::string detail = network->name() + "." + key;
- detail += " = " + network_event_log::ValueAsString(value);
- network_event_log::LogLevel log_level = network_event_log::LOG_LEVEL_EVENT;
- if (key == flimflam::kErrorProperty || key == shill::kErrorDetailsProperty)
- log_level = network_event_log::LOG_LEVEL_ERROR;
- else if (key == flimflam::kSignalStrengthProperty ||
- key == shill::kWifiFrequencyListProperty)
- log_level = network_event_log::LOG_LEVEL_DEBUG;
- NET_LOG_LEVEL(log_level, "NetworkPropertyUpdated", detail);
+ if (prev_profile_path.empty() && !network->profile_path().empty()) {
+ // If added to a Profile, request a full update so that a FavoriteState
+ // gets created.
+ RequestUpdateForNetwork(service_path);
+ }
+ if (!noisy_property) {
+ std::string detail = network->name() + "." + key;
+ detail += " = " + network_event_log::ValueAsString(value);
+ network_event_log::LogLevel log_level;
+ if (key == flimflam::kErrorProperty ||
+ key == shill::kErrorDetailsProperty) {
+ log_level = network_event_log::LOG_LEVEL_ERROR;
+ } else {
+ log_level = network_event_log::LOG_LEVEL_EVENT;
+ }
+ NET_LOG_LEVEL(log_level, "NetworkPropertyUpdated", detail);
+ }
}
NetworkPropertiesUpdated(network);
}
@@ -596,8 +610,8 @@ void NetworkStateHandler::ManagedStateListChanged(
} else if (type == ManagedState::MANAGED_TYPE_FAVORITE) {
NET_LOG_DEBUG("FavoriteListChanged",
base::StringPrintf("Size:%" PRIuS, favorite_list_.size()));
- FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
- NetworkListChanged());
+ // The FavoriteState list only changes when the NetworkState list changes,
+ // so no need to signal observers here again.
} else if (type == ManagedState::MANAGED_TYPE_DEVICE) {
NET_LOG_DEBUG("DeviceListChanged",
base::StringPrintf("Size:%" PRIuS, device_list_.size()));
@@ -690,7 +704,7 @@ void NetworkStateHandler::NetworkPropertiesUpdated(
FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
NetworkPropertiesUpdated(network));
// If |connecting_network_| transitions to a non-idle, non-connecting state,
- // clear it *after* signalling observers.
+ // clear it *after* signaling observers.
if (network->path() == connecting_network_ &&
!network->IsConnectingState() &&
network->connection_state() != flimflam::kStateIdle) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698