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

Unified Diff: chrome/browser/chromeos/net/network_portal_detector_impl.cc

Issue 419463004: Increased delay before next portal detection attempt in the case of !ONLINE -> ONLINE transition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 5 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/portal_detector/network_portal_detector_strategy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/net/network_portal_detector_impl.cc
diff --git a/chrome/browser/chromeos/net/network_portal_detector_impl.cc b/chrome/browser/chromeos/net/network_portal_detector_impl.cc
index c2629417672556c365cf2633b2a8bcb72a69445c..f8fb896216ccb77042879ad037f0cb25085cdf79 100644
--- a/chrome/browser/chromeos/net/network_portal_detector_impl.cc
+++ b/chrome/browser/chromeos/net/network_portal_detector_impl.cc
@@ -37,6 +37,22 @@ const int kProxyChangeDelaySec = 1;
// offline state in a row before notification is sent to observers.
const int kMaxOfflineResultsBeforeReport = 3;
+// Delay before portal detection attempt after !ONLINE -> !ONLINE
+// transition.
+const int kShortInitialDelayBetweenAttemptsMs = 600;
+
+// Maximum timeout before portal detection attempts after !ONLINE ->
+// !ONLINE transition.
+const int kShortMaximumDelayBetweenAttemptsMs = 2 * 60 * 1000;
+
+// Delay before portal detection attempt after !ONLINE -> ONLINE
+// transition.
+const int kLongInitialDelayBetweenAttemptsMs = 30 * 1000;
+
+// Maximum timeout before portal detection attempts after !ONLINE ->
+// ONLINE transition.
+const int kLongMaximumDelayBetweenAttemptsMs = 5 * 60 * 1000;
+
const NetworkState* DefaultNetwork() {
return NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
}
@@ -207,13 +223,12 @@ NetworkPortalDetectorImpl::NetworkPortalDetectorImpl(
test_url_(CaptivePortalDetector::kDefaultURL),
enabled_(false),
strategy_(PortalDetectorStrategy::CreateById(
- PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN)),
+ PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN, this)),
last_detection_result_(CAPTIVE_PORTAL_STATUS_UNKNOWN),
same_detection_result_count_(0),
no_response_result_count_(0),
weak_factory_(this) {
captive_portal_detector_.reset(new CaptivePortalDetector(request_context));
- strategy_->set_delegate(this);
registrar_.Add(this,
chrome::NOTIFICATION_LOGIN_PROXY_CHANGED,
@@ -309,8 +324,7 @@ void NetworkPortalDetectorImpl::SetStrategy(
PortalDetectorStrategy::StrategyId id) {
if (id == strategy_->Id())
return;
- strategy_.reset(PortalDetectorStrategy::CreateById(id).release());
- strategy_->set_delegate(this);
+ strategy_ = PortalDetectorStrategy::CreateById(id, this).Pass();
StopDetection();
StartDetectionIfIdle();
}
@@ -504,7 +518,15 @@ void NetworkPortalDetectorImpl::OnAttemptCompleted(
if (last_detection_result_ != state.status) {
last_detection_result_ = state.status;
same_detection_result_count_ = 1;
- strategy_->Reset();
+ net::BackoffEntry::Policy policy = strategy_->policy();
+ if (state.status == CAPTIVE_PORTAL_STATUS_ONLINE) {
+ policy.initial_delay_ms = kLongInitialDelayBetweenAttemptsMs;
+ policy.maximum_backoff_ms = kLongMaximumDelayBetweenAttemptsMs;
+ } else {
+ policy.initial_delay_ms = kShortInitialDelayBetweenAttemptsMs;
+ policy.maximum_backoff_ms = kShortMaximumDelayBetweenAttemptsMs;
+ }
+ strategy_->SetPolicyAndReset(policy);
} else {
++same_detection_result_count_;
}
« no previous file with comments | « no previous file | chromeos/network/portal_detector/network_portal_detector_strategy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698