OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 // throttler entries. It creates URL request throttler entries when new URLs | 31 // throttler entries. It creates URL request throttler entries when new URLs |
32 // are registered, and does garbage collection from time to time in order to | 32 // are registered, and does garbage collection from time to time in order to |
33 // clean out outdated entries. URL ID consists of lowercased scheme, host, port | 33 // clean out outdated entries. URL ID consists of lowercased scheme, host, port |
34 // and path. All URLs converted to the same ID will share the same entry. | 34 // and path. All URLs converted to the same ID will share the same entry. |
35 class NET_EXPORT URLRequestThrottlerManager | 35 class NET_EXPORT URLRequestThrottlerManager |
36 : NON_EXPORTED_BASE(public base::NonThreadSafe), | 36 : NON_EXPORTED_BASE(public base::NonThreadSafe), |
37 public NetworkChangeNotifier::IPAddressObserver, | 37 public NetworkChangeNotifier::IPAddressObserver, |
38 public NetworkChangeNotifier::ConnectionTypeObserver { | 38 public NetworkChangeNotifier::ConnectionTypeObserver { |
39 public: | 39 public: |
40 URLRequestThrottlerManager(); | 40 URLRequestThrottlerManager(); |
41 virtual ~URLRequestThrottlerManager(); | 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 | 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 | 51 // throttling will be disabled. Subdomains are not included, so they |
(...skipping 19 matching lines...) Expand all Loading... |
71 | 71 |
72 // Whether throttling is enabled or not. | 72 // Whether throttling is enabled or not. |
73 void set_enforce_throttling(bool enforce); | 73 void set_enforce_throttling(bool enforce); |
74 bool enforce_throttling(); | 74 bool enforce_throttling(); |
75 | 75 |
76 // Sets the NetLog instance to use. | 76 // Sets the NetLog instance to use. |
77 void set_net_log(NetLog* net_log); | 77 void set_net_log(NetLog* net_log); |
78 NetLog* net_log() const; | 78 NetLog* net_log() const; |
79 | 79 |
80 // IPAddressObserver interface. | 80 // IPAddressObserver interface. |
81 virtual void OnIPAddressChanged() override; | 81 void OnIPAddressChanged() override; |
82 | 82 |
83 // ConnectionTypeObserver interface. | 83 // ConnectionTypeObserver interface. |
84 virtual void OnConnectionTypeChanged( | 84 void OnConnectionTypeChanged( |
85 NetworkChangeNotifier::ConnectionType type) override; | 85 NetworkChangeNotifier::ConnectionType type) override; |
86 | 86 |
87 // Method that allows us to transform a URL into an ID that can be used in our | 87 // Method that allows us to transform a URL into an ID that can be used in our |
88 // map. Resulting IDs will be lowercase and consist of the scheme, host, port | 88 // map. Resulting IDs will be lowercase and consist of the scheme, host, port |
89 // and path (without query string, fragment, etc.). | 89 // and path (without query string, fragment, etc.). |
90 // If the URL is invalid, the invalid spec will be returned, without any | 90 // If the URL is invalid, the invalid spec will be returned, without any |
91 // transformation. | 91 // transformation. |
92 std::string GetIdFromUrl(const GURL& url) const; | 92 std::string GetIdFromUrl(const GURL& url) const; |
93 | 93 |
94 // Method that ensures the map gets cleaned from time to time. The period at | 94 // Method that ensures the map gets cleaned from time to time. The period at |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 // Valid once we've registered for network notifications. | 158 // Valid once we've registered for network notifications. |
159 base::PlatformThreadId registered_from_thread_; | 159 base::PlatformThreadId registered_from_thread_; |
160 | 160 |
161 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); | 161 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); |
162 }; | 162 }; |
163 | 163 |
164 } // namespace net | 164 } // namespace net |
165 | 165 |
166 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 166 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
OLD | NEW |