summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/net
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-09 02:00:26 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-09 02:00:26 +0000
commit0628ffe893bbe107aeb670b428099c25ae8429fc (patch)
tree51e86285c666d017062a5cf6a8727c0b187b4e62 /chrome/browser/chromeos/net
parent3ebd164a4eac73301d018371ceaf8b1e8d804e13 (diff)
downloadchromium_src-0628ffe893bbe107aeb670b428099c25ae8429fc.zip
chromium_src-0628ffe893bbe107aeb670b428099c25ae8429fc.tar.gz
chromium_src-0628ffe893bbe107aeb670b428099c25ae8429fc.tar.bz2
chromeos: Fix a bug where connection type change sometimes unreported
BUG=146676 TEST=http://codereview.chromium.org/10915077/ needs to be landed to test this patch. Then verifying that 141485 is fixed also verifies this change. Review URL: https://chromiumcodereview.appspot.com/10913103 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/net')
-rw-r--r--chrome/browser/chromeos/net/network_change_notifier_chromeos.cc36
-rw-r--r--chrome/browser/chromeos/net/network_change_notifier_chromeos.h4
2 files changed, 15 insertions, 25 deletions
diff --git a/chrome/browser/chromeos/net/network_change_notifier_chromeos.cc b/chrome/browser/chromeos/net/network_change_notifier_chromeos.cc
index 2007857..dd1c6f0 100644
--- a/chrome/browser/chromeos/net/network_change_notifier_chromeos.cc
+++ b/chrome/browser/chromeos/net/network_change_notifier_chromeos.cc
@@ -30,7 +30,6 @@ NetworkChangeNotifierChromeos::NetworkChangeNotifierChromeos()
: has_active_network_(false),
connection_state_(chromeos::STATE_UNKNOWN),
connection_type_(CONNECTION_NONE),
- is_online_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
BrowserThread::PostDelayedTask(
BrowserThread::UI, FROM_HERE,
@@ -152,10 +151,7 @@ void NetworkChangeNotifierChromeos::UpdateConnectivityState(
}
// We don't care about all transitions of ConnectionState. OnlineStateChange
- // notification should trigger if
- // a) we were online and went offline
- // b) we were offline and went online
- // c) switched to/from captive portal
+ // notification should trigger if ConnectionType is changed.
chromeos::ConnectionState new_connection_state =
network ? network->connection_state() : chromeos::STATE_UNKNOWN;
@@ -174,33 +170,29 @@ void NetworkChangeNotifierChromeos::UpdateConnectivityState(
<< ", was_portal = " << was_portal;
connection_state_ = new_connection_state;
connection_type_ = new_connection_type;
- if (is_online != was_online || is_portal != was_portal ||
- new_connection_type != prev_connection_type) {
- ReportConnectionChange(IsOnline(connection_state_));
+ if (new_connection_type != prev_connection_type) {
+ VLOG(1) << "UpdateConnectivityState3: "
+ << "prev_connection_type = " << prev_connection_type
+ << ", new_connection_type = " << new_connection_type;
+ ReportConnectionChange();
}
- VLOG(2) << " UpdateConnectivityState3: "
+ VLOG(2) << " UpdateConnectivityState4: "
<< "new_cs = " << new_connection_state
<< ", end_cs_ = " << connection_state_
<< "prev_type = " << prev_connection_type
<< ", new_type_ = " << new_connection_type;
}
-void NetworkChangeNotifierChromeos::ReportConnectionChange(bool is_online) {
- VLOG(1) << "ReportConnectionChange: " << (is_online ? "online" : "offline");
+void NetworkChangeNotifierChromeos::ReportConnectionChange() {
if (weak_factory_.HasWeakPtrs()) {
+ // If we have a pending task, cancel it.
DVLOG(1) << "ReportConnectionChange: has pending task";
- // If we are trying to report the same state, just continue as planned.
- // If the online state had changed since we queued the reporting task,
- // then cancel it. This should help us avoid transient edge reporting
- // while switching between connection types (i.e. wifi->ethernet).
- if (is_online != is_online_) {
- weak_factory_.InvalidateWeakPtrs();
- DVLOG(1) << "ReportConnectionChange: canceled pending task";
- }
- return;
+ weak_factory_.InvalidateWeakPtrs();
+ DVLOG(1) << "ReportConnectionChange: canceled pending task";
}
-
- is_online_ = is_online;
+ // Posting task with delay allows us to cancel it when connection type is
+ // changed frequently. This should help us avoid transient edge reporting
+ // while switching between connection types (e.g. ethernet->wifi).
BrowserThread::PostDelayedTask(
BrowserThread::UI, FROM_HERE,
base::Bind(
diff --git a/chrome/browser/chromeos/net/network_change_notifier_chromeos.h b/chrome/browser/chromeos/net/network_change_notifier_chromeos.h
index 071102e..a632456 100644
--- a/chrome/browser/chromeos/net/network_change_notifier_chromeos.h
+++ b/chrome/browser/chromeos/net/network_change_notifier_chromeos.h
@@ -53,7 +53,7 @@ class NetworkChangeNotifierChromeos
const chromeos::Network* network) OVERRIDE;
// Initiate online status change reporting.
- void ReportConnectionChange(bool is_online);
+ void ReportConnectionChange();
void ReportConnectionChangeOnUIThread();
// Callback from online_notification_task_ when online state notification
// is actually scheduled.
@@ -84,8 +84,6 @@ class NetworkChangeNotifierChromeos
// Current active network's IP address.
std::string ip_address_;
- // The last reported online state.
- bool is_online_;
base::WeakPtrFactory<NetworkChangeNotifierChromeos> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierChromeos);