diff options
author | pauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-13 16:52:32 +0000 |
---|---|---|
committer | pauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-13 16:52:32 +0000 |
commit | 05c4d06b17c4b6970430b66feef0a09d27eeb6a6 (patch) | |
tree | 7a58448932b45a104d1f172c5075e85ff833e6ec /net | |
parent | d44d72eaac32fc3c75956e4dab46d662672fcecf (diff) | |
download | chromium_src-05c4d06b17c4b6970430b66feef0a09d27eeb6a6.zip chromium_src-05c4d06b17c4b6970430b66feef0a09d27eeb6a6.tar.gz chromium_src-05c4d06b17c4b6970430b66feef0a09d27eeb6a6.tar.bz2 |
Make NetworkChangeNotifierWin poll more than once when looking for offline to online transitions. Histogram data suggests that continued polling greatly aides in detecting slow transitions to online.
BUG=124069
Review URL: https://chromiumcodereview.appspot.com/10984052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161764 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/network_change_notifier_win.cc | 22 | ||||
-rw-r--r-- | net/base/network_change_notifier_win.h | 6 |
2 files changed, 26 insertions, 2 deletions
diff --git a/net/base/network_change_notifier_win.cc b/net/base/network_change_notifier_win.cc index 5fefd7f..a32a84d 100644 --- a/net/base/network_change_notifier_win.cc +++ b/net/base/network_change_notifier_win.cc @@ -55,7 +55,8 @@ NetworkChangeNotifierWin::NetworkChangeNotifierWin() : is_watching_(false), sequential_failures_(0), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), - dns_config_service_thread_(new DnsConfigServiceThread()) { + dns_config_service_thread_(new DnsConfigServiceThread()), + last_announced_offline_(IsOffline()) { memset(&addr_overlapped_, 0, sizeof addr_overlapped_); addr_overlapped_.hEvent = WSACreateEvent(); dns_config_service_thread_->StartWithOptions( @@ -212,7 +213,9 @@ void NetworkChangeNotifierWin::NotifyObservers() { // // The one second delay chosen here was determined experimentally // by adamk on Windows 7. - timer_.Stop(); // cancel any already waiting notification + // If after one second we determine we are still offline, we will + // delay again. + offline_polls_ = 0; timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), this, &NetworkChangeNotifierWin::NotifyParentOfConnectionTypeChange); } @@ -271,6 +274,21 @@ bool NetworkChangeNotifierWin::WatchForAddressChangeInternal() { } void NetworkChangeNotifierWin::NotifyParentOfConnectionTypeChange() { + bool current_offline = IsOffline(); + offline_polls_++; + // If we continue to appear offline, delay sending out the notification in + // case we appear to go online within 20 seconds. UMA histogram data shows + // we may not detect the transition to online state after 1 second but within + // 20 seconds we generally do. + if (last_announced_offline_ && current_offline && offline_polls_ <= 20) { + timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1), this, + &NetworkChangeNotifierWin::NotifyParentOfConnectionTypeChange); + return; + } + if (last_announced_offline_) + UMA_HISTOGRAM_CUSTOM_COUNTS("NCN.OfflinePolls", offline_polls_, 1, 50, 50); + last_announced_offline_ = current_offline; + NotifyObserversOfConnectionTypeChange(); } diff --git a/net/base/network_change_notifier_win.h b/net/base/network_change_notifier_win.h index f2d3d99..6af7f06 100644 --- a/net/base/network_change_notifier_win.h +++ b/net/base/network_change_notifier_win.h @@ -93,6 +93,12 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierWin // Thread on which we can run DnsConfigService. scoped_ptr<DnsConfigServiceThread> dns_config_service_thread_; + // Result of IsOffline() when NotifyObserversOfConnectionTypeChange() + // was last called. + bool last_announced_offline_; + // Number of times polled to check if still offline. + int offline_polls_; + DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierWin); }; |