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

Unified Diff: chromeos/network/network_state_handler.cc

Issue 979183003: Fix logic for default network notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_432404_default_network_0
Patch Set: Rebase Created 5 years, 9 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 | chromeos/network/network_state_handler_unittest.cc » ('j') | 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 7703b10c6867ea8a2a4db1c7e8defcdcc19ed570..236789c566874b5a0438f87f42899dadde5e5a4e 100644
--- a/chromeos/network/network_state_handler.cc
+++ b/chromeos/network/network_state_handler.cc
@@ -772,15 +772,23 @@ void NetworkStateHandler::DefaultNetworkServiceChanged(
if (!network) {
// If NetworkState is not available yet, do not notify observers here,
// they will be notified when the state is received.
- NET_LOG_DEBUG("Default NetworkState not available",
- default_network_path_);
+ NET_LOG(EVENT) << "Default NetworkState not available: "
+ << default_network_path_;
return;
}
}
if (network && !network->IsConnectedState()) {
- NET_LOG_ERROR(
- "DefaultNetwork is not connected: " + network->connection_state(),
- network->path());
+ if (network->IsConnectingState()) {
+ NET_LOG(EVENT) << "DefaultNetwork is connecting: " << GetLogName(network)
+ << ": " << network->connection_state();
+ } else {
+ NET_LOG(ERROR) << "DefaultNetwork in unexpected state: "
+ << GetLogName(network) << ": "
+ << network->connection_state();
+ }
+ // Do not notify observers here, the notification will occur when the
+ // connection state changes.
+ return;
}
NotifyDefaultNetworkChanged(network);
}
@@ -867,23 +875,33 @@ void NetworkStateHandler::OnNetworkConnectionStateChanged(
NetworkState* network) {
SCOPED_NET_LOG_IF_SLOW();
DCHECK(network);
- std::string event = "NetworkConnectionStateChanged";
+ bool notify_default = false;
if (network->path() == default_network_path_) {
- event = "Default" + event;
- if (!network->IsConnectedState()) {
- NET_LOG_EVENT(
- "DefaultNetwork is not connected: " + network->connection_state(),
- network->path());
+ if (network->IsConnectedState()) {
+ notify_default = true;
+ } else if (network->IsConnectingState()) {
+ // Wait until the network is actually connected to notify that the default
+ // network changed.
+ NET_LOG(EVENT) << "Default network is not connected: "
+ << GetLogName(network)
+ << "State: " << network->connection_state();
+ } else {
+ NET_LOG(ERROR) << "Default network in unexpected state: "
+ << GetLogName(network)
+ << "State: " << network->connection_state();
default_network_path_.clear();
SortNetworkList();
NotifyDefaultNetworkChanged(nullptr);
}
}
- NET_LOG_EVENT("NOTIFY:" + event + ": " + network->connection_state(),
- GetLogName(network));
+ std::string desc = "NetworkConnectionStateChanged";
+ if (notify_default)
+ desc = "Default" + desc;
+ NET_LOG(EVENT) << "NOTIFY: " << desc << ": " << GetLogName(network) << ": "
+ << network->connection_state();
FOR_EACH_OBSERVER(NetworkStateHandlerObserver, observers_,
NetworkConnectionStateChanged(network));
- if (network->path() == default_network_path_)
+ if (notify_default)
NotifyDefaultNetworkChanged(network);
}
« no previous file with comments | « no previous file | chromeos/network/network_state_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698