| Index: net/url_request/url_request_throttler_manager.cc
|
| diff --git a/net/url_request/url_request_throttler_manager.cc b/net/url_request/url_request_throttler_manager.cc
|
| index 04e05c9af017af5be8cfa9a21e036b2ecb0f7b53..f71cf52b86b76ef8cd6d4888b55b2e1f1c000e9a 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
|
|
|