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 #ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // map. Resulting IDs will be lowercase and consist of the scheme, host, port | 63 // map. Resulting IDs will be lowercase and consist of the scheme, host, port |
64 // and path (without query string, fragment, etc.). | 64 // and path (without query string, fragment, etc.). |
65 // If the URL is invalid, the invalid spec will be returned, without any | 65 // If the URL is invalid, the invalid spec will be returned, without any |
66 // transformation. | 66 // transformation. |
67 std::string GetIdFromUrl(const GURL& url) const; | 67 std::string GetIdFromUrl(const GURL& url) const; |
68 | 68 |
69 // Method that ensures the map gets cleaned from time to time. The period at | 69 // Method that ensures the map gets cleaned from time to time. The period at |
70 // which garbage collecting happens is adjustable with the | 70 // which garbage collecting happens is adjustable with the |
71 // kRequestBetweenCollecting constant. | 71 // kRequestBetweenCollecting constant. |
72 void GarbageCollectEntriesIfNecessary(); | 72 void GarbageCollectEntriesIfNecessary(); |
| 73 |
73 // Method that does the actual work of garbage collecting. | 74 // Method that does the actual work of garbage collecting. |
74 void GarbageCollectEntries(); | 75 void GarbageCollectEntries(); |
75 | 76 |
76 // Used by tests. | 77 // Used by tests. |
77 int GetNumberOfEntriesForTests() const { return url_entries_.size(); } | 78 int GetNumberOfEntriesForTests() const { return url_entries_.size(); } |
78 | 79 |
79 private: | 80 private: |
80 friend struct DefaultSingletonTraits<URLRequestThrottlerManager>; | 81 friend struct DefaultSingletonTraits<URLRequestThrottlerManager>; |
81 | 82 |
82 // From each URL we generate an ID composed of the scheme, host, port and path | 83 // From each URL we generate an ID composed of the scheme, host, port and path |
(...skipping 19 matching lines...) Expand all Loading... |
102 // Whether we would like to reject outgoing HTTP requests during the back-off | 103 // Whether we would like to reject outgoing HTTP requests during the back-off |
103 // period. | 104 // period. |
104 bool enforce_throttling_; | 105 bool enforce_throttling_; |
105 | 106 |
106 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); | 107 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); |
107 }; | 108 }; |
108 | 109 |
109 } // namespace net | 110 } // namespace net |
110 | 111 |
111 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 112 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
OLD | NEW |