OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/url_request/url_request_throttler_manager.h" | 5 #include "net/url_request/url_request_throttler_manager.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // Find the entry in the map or create it. | 26 // Find the entry in the map or create it. |
27 scoped_refptr<URLRequestThrottlerEntry>& entry = url_entries_[url_id]; | 27 scoped_refptr<URLRequestThrottlerEntry>& entry = url_entries_[url_id]; |
28 if (entry == NULL) | 28 if (entry == NULL) |
29 entry = new URLRequestThrottlerEntry(); | 29 entry = new URLRequestThrottlerEntry(); |
30 | 30 |
31 return entry; | 31 return entry; |
32 } | 32 } |
33 | 33 |
34 URLRequestThrottlerManager::URLRequestThrottlerManager() | 34 URLRequestThrottlerManager::URLRequestThrottlerManager() |
35 : requests_since_last_gc_(0) { | 35 : requests_since_last_gc_(0), |
| 36 enforce_throttling_(true) { |
36 } | 37 } |
37 | 38 |
38 URLRequestThrottlerManager::~URLRequestThrottlerManager() { | 39 URLRequestThrottlerManager::~URLRequestThrottlerManager() { |
39 // Delete all entries. | 40 // Delete all entries. |
40 url_entries_.clear(); | 41 url_entries_.clear(); |
41 } | 42 } |
42 | 43 |
43 std::string URLRequestThrottlerManager::GetIdFromUrl(const GURL& url) const { | 44 std::string URLRequestThrottlerManager::GetIdFromUrl(const GURL& url) const { |
44 if (!url.is_valid()) | 45 if (!url.is_valid()) |
45 return url.possibly_invalid_spec(); | 46 return url.possibly_invalid_spec(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 url_entries_[url_id] = entry; | 99 url_entries_[url_id] = entry; |
99 } | 100 } |
100 | 101 |
101 void URLRequestThrottlerManager::EraseEntryForTests(const GURL& url) { | 102 void URLRequestThrottlerManager::EraseEntryForTests(const GURL& url) { |
102 // Normalize the url. | 103 // Normalize the url. |
103 std::string url_id = GetIdFromUrl(url); | 104 std::string url_id = GetIdFromUrl(url); |
104 url_entries_.erase(url_id); | 105 url_entries_.erase(url_id); |
105 } | 106 } |
106 | 107 |
107 } // namespace net | 108 } // namespace net |
OLD | NEW |