diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-20 22:07:43 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-20 22:07:43 +0000 |
commit | 5394e4206cdf407e84ee59ef46ba9001254efd6d (patch) | |
tree | 272fe4989521b4c09bdd7d47b10e4d8f92452f6c /net/url_request/url_request_throttler_manager.cc | |
parent | 378a843690f450ee36f0c4e6e2453d847be1750b (diff) | |
download | chromium_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_manager.cc')
-rw-r--r-- | net/url_request/url_request_throttler_manager.cc | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/net/url_request/url_request_throttler_manager.cc b/net/url_request/url_request_throttler_manager.cc index 04e05c9..f71cf52 100644 --- a/net/url_request/url_request_throttler_manager.cc +++ b/net/url_request/url_request_throttler_manager.cc @@ -31,6 +31,27 @@ scoped_refptr<URLRequestThrottlerEntryInterface> return entry; } +void URLRequestThrottlerManager::OverrideEntryForTests( + const GURL& url, + URLRequestThrottlerEntry* entry) { + if (entry == NULL) + return; + + // Normalize the url. + std::string url_id = GetIdFromUrl(url); + + // Periodically garbage collect old entries. + GarbageCollectEntriesIfNecessary(); + + url_entries_[url_id] = entry; +} + +void URLRequestThrottlerManager::EraseEntryForTests(const GURL& url) { + // Normalize the url. + std::string url_id = GetIdFromUrl(url); + url_entries_.erase(url_id); +} + URLRequestThrottlerManager::URLRequestThrottlerManager() : requests_since_last_gc_(0), enforce_throttling_(true) { @@ -58,6 +79,15 @@ std::string URLRequestThrottlerManager::GetIdFromUrl(const GURL& url) const { return StringToLowerASCII(id.spec()); } +void URLRequestThrottlerManager::GarbageCollectEntriesIfNecessary() { + requests_since_last_gc_++; + if (requests_since_last_gc_ < kRequestsBetweenCollecting) + return; + + requests_since_last_gc_ = 0; + GarbageCollectEntries(); +} + void URLRequestThrottlerManager::GarbageCollectEntries() { UrlEntryMap::iterator i = url_entries_.begin(); @@ -75,34 +105,4 @@ void URLRequestThrottlerManager::GarbageCollectEntries() { } } -void URLRequestThrottlerManager::GarbageCollectEntriesIfNecessary() { - requests_since_last_gc_++; - if (requests_since_last_gc_ < kRequestsBetweenCollecting) - return; - - requests_since_last_gc_ = 0; - GarbageCollectEntries(); -} - -void URLRequestThrottlerManager::OverrideEntryForTests( - const GURL& url, - URLRequestThrottlerEntry* entry) { - if (entry == NULL) - return; - - // Normalize the url. - std::string url_id = GetIdFromUrl(url); - - // Periodically garbage collect old entries. - GarbageCollectEntriesIfNecessary(); - - url_entries_[url_id] = entry; -} - -void URLRequestThrottlerManager::EraseEntryForTests(const GURL& url) { - // Normalize the url. - std::string url_id = GetIdFromUrl(url); - url_entries_.erase(url_id); -} - } // namespace net |