summaryrefslogtreecommitdiffstats
path: root/chrome/browser/url_fetcher_protect.cc
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-21 21:08:50 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-21 21:08:50 +0000
commit66aa1265b6ff166987ffc294b7796f827abd27bc (patch)
tree3545777d69c046f64074a00e782aac5d3228838f /chrome/browser/url_fetcher_protect.cc
parent15069dbc92e8768284393fe18a23f79106cd552e (diff)
downloadchromium_src-66aa1265b6ff166987ffc294b7796f827abd27bc.zip
chromium_src-66aa1265b6ff166987ffc294b7796f827abd27bc.tar.gz
chromium_src-66aa1265b6ff166987ffc294b7796f827abd27bc.tar.bz2
Run MetricsResponseTest on the Mac. This test depended on
url_fetcher_protect.h, which contained a ProtectEntry class, but this name conflicts with the ProtectEntry function in QuickDraw, and apparently QuickDraw headers were being brought in by some other system header we use. Rename our ProtectEntry to URLFetcherProtectEntry, and change ProtectManager for consistency. Review URL: http://codereview.chromium.org/7834 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/url_fetcher_protect.cc')
-rw-r--r--chrome/browser/url_fetcher_protect.cc56
1 files changed, 30 insertions, 26 deletions
diff --git a/chrome/browser/url_fetcher_protect.cc b/chrome/browser/url_fetcher_protect.cc
index def6b07..297a9bb 100644
--- a/chrome/browser/url_fetcher_protect.cc
+++ b/chrome/browser/url_fetcher_protect.cc
@@ -4,23 +4,23 @@
#include "chrome/browser/url_fetcher_protect.h"
-// ProtectEntry --------------------------------------------------------------
+// URLFetcherProtectEntry ----------------------------------------------------
// Default parameters. Time is in milliseconds.
// static
-const int ProtectEntry::kDefaultSlidingWindowPeriod = 2000;
+const int URLFetcherProtectEntry::kDefaultSlidingWindowPeriod = 2000;
-const int ProtectEntry::kDefaultMaxSendThreshold = 20;
-const int ProtectEntry::kDefaultMaxRetries = 0;
+const int URLFetcherProtectEntry::kDefaultMaxSendThreshold = 20;
+const int URLFetcherProtectEntry::kDefaultMaxRetries = 0;
-const int ProtectEntry::kDefaultInitialTimeout = 100;
-const double ProtectEntry::kDefaultMultiplier = 2.0;
-const int ProtectEntry::kDefaultConstantFactor = 100;
-const int ProtectEntry::kDefaultMaximumTimeout = 60000;
+const int URLFetcherProtectEntry::kDefaultInitialTimeout = 100;
+const double URLFetcherProtectEntry::kDefaultMultiplier = 2.0;
+const int URLFetcherProtectEntry::kDefaultConstantFactor = 100;
+const int URLFetcherProtectEntry::kDefaultMaximumTimeout = 60000;
-ProtectEntry::ProtectEntry()
+URLFetcherProtectEntry::URLFetcherProtectEntry()
: sliding_window_period_(kDefaultSlidingWindowPeriod),
max_send_threshold_(kDefaultMaxSendThreshold),
max_retries_(kDefaultMaxRetries),
@@ -31,10 +31,13 @@ ProtectEntry::ProtectEntry()
ResetBackoff();
}
-ProtectEntry::ProtectEntry(int sliding_window_period, int max_send_threshold,
- int max_retries, int initial_timeout,
- double multiplier, int constant_factor,
- int maximum_timeout)
+URLFetcherProtectEntry::URLFetcherProtectEntry(int sliding_window_period,
+ int max_send_threshold,
+ int max_retries,
+ int initial_timeout,
+ double multiplier,
+ int constant_factor,
+ int maximum_timeout)
: sliding_window_period_(sliding_window_period),
max_send_threshold_(max_send_threshold),
max_retries_(max_retries),
@@ -45,7 +48,7 @@ ProtectEntry::ProtectEntry(int sliding_window_period, int max_send_threshold,
ResetBackoff();
}
-int ProtectEntry::UpdateBackoff(EventType event_type) {
+int URLFetcherProtectEntry::UpdateBackoff(EventType event_type) {
// request may be sent in different threads
AutoLock lock(lock_);
@@ -69,7 +72,7 @@ int ProtectEntry::UpdateBackoff(EventType event_type) {
return wait;
}
-TimeDelta ProtectEntry::AntiOverload() {
+TimeDelta URLFetcherProtectEntry::AntiOverload() {
TimeDelta sw = TimeDelta::FromMilliseconds(sliding_window_period_);
TimeTicks now = TimeTicks::Now();
// Estimate when the next request will be sent.
@@ -91,13 +94,13 @@ TimeDelta ProtectEntry::AntiOverload() {
return release_time_ - now;
}
-TimeDelta ProtectEntry::ResetBackoff() {
+TimeDelta URLFetcherProtectEntry::ResetBackoff() {
timeout_period_ = initial_timeout_;
release_time_ = TimeTicks::Now();
return TimeDelta::FromMilliseconds(0);
}
-TimeDelta ProtectEntry::IncreaseBackoff() {
+TimeDelta URLFetcherProtectEntry::IncreaseBackoff() {
TimeTicks now = TimeTicks::Now();
release_time_ = std::max(release_time_, now) +
@@ -112,13 +115,13 @@ TimeDelta ProtectEntry::IncreaseBackoff() {
return release_time_ - now;
}
-// ProtectManager ------------------------------------------------------------
+// URLFetcherProtectManager --------------------------------------------------
// static
-scoped_ptr<ProtectManager> ProtectManager::protect_manager_;
-Lock ProtectManager::lock_;
+scoped_ptr<URLFetcherProtectManager> URLFetcherProtectManager::protect_manager_;
+Lock URLFetcherProtectManager::lock_;
-ProtectManager::~ProtectManager() {
+URLFetcherProtectManager::~URLFetcherProtectManager() {
// Deletes all entries
ProtectService::iterator i;
for (i = services_.begin(); i != services_.end(); ++i) {
@@ -128,16 +131,16 @@ ProtectManager::~ProtectManager() {
}
// static
-ProtectManager* ProtectManager::GetInstance() {
+URLFetcherProtectManager* URLFetcherProtectManager::GetInstance() {
AutoLock lock(lock_);
if (protect_manager_.get() == NULL) {
- protect_manager_.reset(new ProtectManager());
+ protect_manager_.reset(new URLFetcherProtectManager());
}
return protect_manager_.get();
}
-ProtectEntry* ProtectManager::Register(std::string id) {
+URLFetcherProtectEntry* URLFetcherProtectManager::Register(std::string id) {
AutoLock lock(lock_);
ProtectService::iterator i = services_.find(id);
@@ -148,12 +151,13 @@ ProtectEntry* ProtectManager::Register(std::string id) {
}
// Creates a new entry.
- ProtectEntry* entry = new ProtectEntry();
+ URLFetcherProtectEntry* entry = new URLFetcherProtectEntry();
services_[id] = entry;
return entry;
}
-ProtectEntry* ProtectManager::Register(std::string id, ProtectEntry* entry) {
+URLFetcherProtectEntry* URLFetcherProtectManager::Register(
+ std::string id, URLFetcherProtectEntry* entry) {
AutoLock lock(lock_);
ProtectService::iterator i = services_.find(id);