diff options
author | derekjchow <derekjchow@chromium.org> | 2015-02-27 12:19:50 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-27 20:20:24 +0000 |
commit | 542a7adc69868ebe872876036b7dd2837a0d5b28 (patch) | |
tree | 9d99412d313cd4604d1dc5f3608eb37111016392 /chromecast/net | |
parent | 4da44cdeee60cc12ce4ff550cf535615b35ff7f6 (diff) | |
download | chromium_src-542a7adc69868ebe872876036b7dd2837a0d5b28.zip chromium_src-542a7adc69868ebe872876036b7dd2837a0d5b28.tar.gz chromium_src-542a7adc69868ebe872876036b7dd2837a0d5b28.tar.bz2 |
Perform more aggressive connectivity checks.
Perform connectivity check even if offline. NetworkChangeNotifier
does not accuratly report IsOffline on some platforms.
R=gunsch@chromium.org,wzhong@chromium.org
BUG=
Review URL: https://codereview.chromium.org/963163003
Cr-Commit-Position: refs/heads/master@{#318502}
Diffstat (limited to 'chromecast/net')
-rw-r--r-- | chromecast/net/connectivity_checker.cc | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/chromecast/net/connectivity_checker.cc b/chromecast/net/connectivity_checker.cc index d33977a..0c78b5d 100644 --- a/chromecast/net/connectivity_checker.cc +++ b/chromecast/net/connectivity_checker.cc @@ -60,10 +60,8 @@ void ConnectivityChecker::Initialize() { url_request_context_.reset(builder.Build()); net::NetworkChangeNotifier::AddConnectionTypeObserver(this); - if (!net::NetworkChangeNotifier::IsOffline()) { - loop_proxy_->PostTask(FROM_HERE, - base::Bind(&ConnectivityChecker::Check, this)); - } + loop_proxy_->PostTask(FROM_HERE, + base::Bind(&ConnectivityChecker::Check, this)); } ConnectivityChecker::~ConnectivityChecker() { @@ -118,15 +116,11 @@ void ConnectivityChecker::Check() { void ConnectivityChecker::OnConnectionTypeChanged( net::NetworkChangeNotifier::ConnectionType type) { - Cancel(); - - // If there is no connection, set connectivity to false. Otherwise retest - // connectivity - if (type == net::NetworkChangeNotifier::CONNECTION_NONE) { + if (type == net::NetworkChangeNotifier::CONNECTION_NONE) SetConnectivity(false); - } else { - Check(); - } + + Cancel(); + Check(); } void ConnectivityChecker::OnResponseStarted(net::URLRequest* request) { @@ -154,11 +148,9 @@ void ConnectivityChecker::OnResponseStarted(net::URLRequest* request) { } // Check again - if (!net::NetworkChangeNotifier::IsOffline()) { - loop_proxy_->PostDelayedTask( - FROM_HERE, base::Bind(&ConnectivityChecker::Check, this), - base::TimeDelta::FromSeconds(kConnectivityPeriodSeconds)); - } + loop_proxy_->PostDelayedTask( + FROM_HERE, base::Bind(&ConnectivityChecker::Check, this), + base::TimeDelta::FromSeconds(kConnectivityPeriodSeconds)); } void ConnectivityChecker::OnReadCompleted(net::URLRequest* request, |