Large timeouts between in-session portal detection attempts.

https://codereview.chromium.org/385553002/ uses BackoffEntry, but it requires a lot of changes, so it probably won't be merged to M37. I suggest to merge this small fix.

BUG=377725
TEST=manual

Review URL: https://codereview.chromium.org/383183002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283536 0039d316-1c4b-4281-b951-d872f2087c98
parent 66000edf
......@@ -75,10 +75,14 @@ class ErrorScreenStrategy : public PortalDetectorStrategy {
class SessionStrategy : public PortalDetectorStrategy {
public:
static const int kFastDelayBetweenAttemptsSec = 1;
static const int kMaxFastAttempts = 3;
static const int kFastAttemptTimeoutSec = 3;
static const int kMaxFastAttempts = 3;
static const int kSlowDelayBetweenAttemptsSec = 10;
static const int kNormalDelayBetweenAttemptsSec = 10;
static const int kNormalAttemptTimeoutSec = 5;
static const int kMaxNormalAttempts = 3;
static const int kSlowDelayBetweenAttemptsSec = 2 * 60;
static const int kSlowAttemptTimeoutSec = 5;
SessionStrategy() {}
......@@ -90,22 +94,34 @@ class SessionStrategy : public PortalDetectorStrategy {
virtual bool CanPerformAttemptAfterDetectionImpl() OVERRIDE { return true; }
virtual base::TimeDelta GetDelayTillNextAttemptImpl() OVERRIDE {
int delay;
if (delegate_->AttemptCount() < kMaxFastAttempts)
if (IsFastAttempt())
delay = kFastDelayBetweenAttemptsSec;
else if (IsNormalAttempt())
delay = kNormalDelayBetweenAttemptsSec;
else
delay = kSlowDelayBetweenAttemptsSec;
return AdjustDelay(base::TimeDelta::FromSeconds(delay));
}
virtual base::TimeDelta GetNextAttemptTimeoutImpl() OVERRIDE {
int timeout;
if (delegate_->AttemptCount() < kMaxFastAttempts)
if (IsFastAttempt())
timeout = kFastAttemptTimeoutSec;
else if (IsNormalAttempt())
timeout = kNormalAttemptTimeoutSec;
else
timeout = kSlowAttemptTimeoutSec;
return base::TimeDelta::FromSeconds(timeout);
}
private:
bool IsFastAttempt() {
return delegate_->AttemptCount() < kMaxFastAttempts;
}
bool IsNormalAttempt() {
return delegate_->AttemptCount() < kMaxFastAttempts + kMaxNormalAttempts;
}
DISALLOW_COPY_AND_ASSIGN(SessionStrategy);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment