Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: net/url_request/url_request_throttler_manager.h

Issue 1148603003: Remove X-Chrome-Exponential-Throttling header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 29 matching lines...) Expand all
40 URLRequestThrottlerManager(); 40 URLRequestThrottlerManager();
41 ~URLRequestThrottlerManager() override; 41 ~URLRequestThrottlerManager() override;
42 42
43 // Must be called for every request, returns the URL request throttler entry 43 // Must be called for every request, returns the URL request throttler entry
44 // associated with the URL. The caller must inform this entry of some events. 44 // associated with the URL. The caller must inform this entry of some events.
45 // Please refer to url_request_throttler_entry_interface.h for further 45 // Please refer to url_request_throttler_entry_interface.h for further
46 // informations. 46 // informations.
47 scoped_refptr<URLRequestThrottlerEntryInterface> RegisterRequestUrl( 47 scoped_refptr<URLRequestThrottlerEntryInterface> RegisterRequestUrl(
48 const GURL& url); 48 const GURL& url);
49 49
50 // Adds the given host to a list of sites for which exponential back-off
51 // throttling will be disabled. Subdomains are not included, so they
52 // must be added separately.
53 void AddToOptOutList(const std::string& host);
54
55 // Registers a new entry in this service and overrides the existing entry (if 50 // Registers a new entry in this service and overrides the existing entry (if
56 // any) for the URL. The service will hold a reference to the entry. 51 // any) for the URL. The service will hold a reference to the entry.
57 // It is only used by unit tests. 52 // It is only used by unit tests.
58 void OverrideEntryForTests(const GURL& url, URLRequestThrottlerEntry* entry); 53 void OverrideEntryForTests(const GURL& url, URLRequestThrottlerEntry* entry);
59 54
60 // Explicitly erases an entry. 55 // Explicitly erases an entry.
61 // This is useful to remove those entries which have got infinite lifetime and 56 // This is useful to remove those entries which have got infinite lifetime and
62 // thus won't be garbage collected. 57 // thus won't be garbage collected.
63 // It is only used by unit tests. 58 // It is only used by unit tests.
64 void EraseEntryForTests(const GURL& url); 59 void EraseEntryForTests(const GURL& url);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 105
111 // Used by tests. 106 // Used by tests.
112 int GetNumberOfEntriesForTests() const { return url_entries_.size(); } 107 int GetNumberOfEntriesForTests() const { return url_entries_.size(); }
113 108
114 private: 109 private:
115 // From each URL we generate an ID composed of the scheme, host, port and path 110 // From each URL we generate an ID composed of the scheme, host, port and path
116 // that allows us to uniquely map an entry to it. 111 // that allows us to uniquely map an entry to it.
117 typedef std::map<std::string, scoped_refptr<URLRequestThrottlerEntry> > 112 typedef std::map<std::string, scoped_refptr<URLRequestThrottlerEntry> >
118 UrlEntryMap; 113 UrlEntryMap;
119 114
120 // We maintain a set of hosts that have opted out of exponential
121 // back-off throttling.
122 typedef std::set<std::string> OptOutHosts;
123
124 // Maximum number of entries that we are willing to collect in our map. 115 // Maximum number of entries that we are willing to collect in our map.
125 static const unsigned int kMaximumNumberOfEntries; 116 static const unsigned int kMaximumNumberOfEntries;
126 // Number of requests that will be made between garbage collection. 117 // Number of requests that will be made between garbage collection.
127 static const unsigned int kRequestsBetweenCollecting; 118 static const unsigned int kRequestsBetweenCollecting;
128 119
129 // Map that contains a list of URL ID and their matching 120 // Map that contains a list of URL ID and their matching
130 // URLRequestThrottlerEntry. 121 // URLRequestThrottlerEntry.
131 UrlEntryMap url_entries_; 122 UrlEntryMap url_entries_;
132 123
133 // Set of hosts that have opted out.
134 OptOutHosts opt_out_hosts_;
135
136 // This keeps track of how many requests have been made. Used with 124 // This keeps track of how many requests have been made. Used with
137 // GarbageCollectEntries. 125 // GarbageCollectEntries.
138 unsigned int requests_since_last_gc_; 126 unsigned int requests_since_last_gc_;
139 127
140 // Valid after construction. 128 // Valid after construction.
141 GURL::Replacements url_id_replacements_; 129 GURL::Replacements url_id_replacements_;
142 130
143 // Certain tests do not obey the net component's threading policy, so we 131 // Certain tests do not obey the net component's threading policy, so we
144 // keep track of whether we're being used by tests, and turn off certain 132 // keep track of whether we're being used by tests, and turn off certain
145 // checks. 133 // checks.
(...skipping 11 matching lines...) Expand all
157 145
158 // Valid once we've registered for network notifications. 146 // Valid once we've registered for network notifications.
159 base::PlatformThreadId registered_from_thread_; 147 base::PlatformThreadId registered_from_thread_;
160 148
161 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); 149 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager);
162 }; 150 };
163 151
164 } // namespace net 152 } // namespace net
165 153
166 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ 154 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_
OLDNEW
« no previous file with comments | « net/url_request/url_request_throttler_header_interface.h ('k') | net/url_request/url_request_throttler_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698