summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_throttler_entry.cc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 22:07:43 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-20 22:07:43 +0000
commit5394e4206cdf407e84ee59ef46ba9001254efd6d (patch)
tree272fe4989521b4c09bdd7d47b10e4d8f92452f6c /net/url_request/url_request_throttler_entry.cc
parent378a843690f450ee36f0c4e6e2453d847be1750b (diff)
downloadchromium_src-5394e4206cdf407e84ee59ef46ba9001254efd6d.zip
chromium_src-5394e4206cdf407e84ee59ef46ba9001254efd6d.tar.gz
chromium_src-5394e4206cdf407e84ee59ef46ba9001254efd6d.tar.bz2
Reorder the methods in net/url_request/.
BUG=68682 TEST=compiles Review URL: http://codereview.chromium.org/6382003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72013 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_throttler_entry.cc')
-rw-r--r--net/url_request/url_request_throttler_entry.cc82
1 files changed, 41 insertions, 41 deletions
diff --git a/net/url_request/url_request_throttler_entry.cc b/net/url_request/url_request_throttler_entry.cc
index 4abb438..e5da528 100644
--- a/net/url_request/url_request_throttler_entry.cc
+++ b/net/url_request/url_request_throttler_entry.cc
@@ -65,17 +65,36 @@ URLRequestThrottlerEntry::URLRequestThrottlerEntry(
Initialize();
}
-URLRequestThrottlerEntry::~URLRequestThrottlerEntry() {
-}
+bool URLRequestThrottlerEntry::IsEntryOutdated() const {
+ if (entry_lifetime_ms_ == -1)
+ return false;
-void URLRequestThrottlerEntry::Initialize() {
- // Since this method is called by the constructors, GetTimeNow() (a virtual
- // method) is not used.
- exponential_backoff_release_time_ = base::TimeTicks::Now();
- failure_count_ = 0;
- latest_response_was_failure_ = false;
+ base::TimeTicks now = GetTimeNow();
- sliding_window_release_time_ = base::TimeTicks::Now();
+ // If there are send events in the sliding window period, we still need this
+ // entry.
+ if (send_log_.size() > 0 &&
+ send_log_.back() + sliding_window_period_ > now) {
+ return false;
+ }
+
+ int64 unused_since_ms =
+ (now - exponential_backoff_release_time_).InMilliseconds();
+
+ // Release time is further than now, we are managing it.
+ if (unused_since_ms < 0)
+ return false;
+
+ // latest_response_was_failure_ is true indicates that the latest one or
+ // more requests encountered server errors or had malformed response bodies.
+ // In that case, we don't want to collect the entry unless it hasn't been used
+ // for longer than the maximum allowed back-off.
+ if (latest_response_was_failure_)
+ return unused_since_ms > std::max(maximum_backoff_ms_, entry_lifetime_ms_);
+
+ // Otherwise, consider the entry is outdated if it hasn't been used for the
+ // specified lifetime period.
+ return unused_since_ms > entry_lifetime_ms_;
}
bool URLRequestThrottlerEntry::IsDuringExponentialBackoff() const {
@@ -153,38 +172,6 @@ void URLRequestThrottlerEntry::UpdateWithResponse(
}
}
-bool URLRequestThrottlerEntry::IsEntryOutdated() const {
- if (entry_lifetime_ms_ == -1)
- return false;
-
- base::TimeTicks now = GetTimeNow();
-
- // If there are send events in the sliding window period, we still need this
- // entry.
- if (send_log_.size() > 0 &&
- send_log_.back() + sliding_window_period_ > now) {
- return false;
- }
-
- int64 unused_since_ms =
- (now - exponential_backoff_release_time_).InMilliseconds();
-
- // Release time is further than now, we are managing it.
- if (unused_since_ms < 0)
- return false;
-
- // latest_response_was_failure_ is true indicates that the latest one or
- // more requests encountered server errors or had malformed response bodies.
- // In that case, we don't want to collect the entry unless it hasn't been used
- // for longer than the maximum allowed back-off.
- if (latest_response_was_failure_)
- return unused_since_ms > std::max(maximum_backoff_ms_, entry_lifetime_ms_);
-
- // Otherwise, consider the entry is outdated if it hasn't been used for the
- // specified lifetime period.
- return unused_since_ms > entry_lifetime_ms_;
-}
-
void URLRequestThrottlerEntry::ReceivedContentWasMalformed() {
// For any response that is marked as malformed now, we have probably
// considered it as a success when receiving it and decreased the failure
@@ -199,6 +186,19 @@ void URLRequestThrottlerEntry::ReceivedContentWasMalformed() {
exponential_backoff_release_time_ = CalculateExponentialBackoffReleaseTime();
}
+URLRequestThrottlerEntry::~URLRequestThrottlerEntry() {
+}
+
+void URLRequestThrottlerEntry::Initialize() {
+ // Since this method is called by the constructors, GetTimeNow() (a virtual
+ // method) is not used.
+ exponential_backoff_release_time_ = base::TimeTicks::Now();
+ failure_count_ = 0;
+ latest_response_was_failure_ = false;
+
+ sliding_window_release_time_ = base::TimeTicks::Now();
+}
+
base::TimeTicks
URLRequestThrottlerEntry::CalculateExponentialBackoffReleaseTime() {
double delay = initial_backoff_ms_;