| 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> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/threading/non_thread_safe.h" | |
| 15 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "base/threading/thread_checker.h" |
| 16 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 17 #include "net/base/network_change_notifier.h" | 17 #include "net/base/network_change_notifier.h" |
| 18 #include "net/url_request/url_request_throttler_entry.h" | 18 #include "net/url_request/url_request_throttler_entry.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | 22 |
| 23 class NetLog; | 23 class NetLog; |
| 24 class NetLogWithSource; | 24 class NetLogWithSource; |
| 25 | 25 |
| 26 // Class that registers URL request throttler entries for URLs being accessed | 26 // Class that registers URL request throttler entries for URLs being accessed |
| 27 // in order to supervise traffic. URL requests for HTTP contents should | 27 // in order to supervise traffic. URL requests for HTTP contents should |
| 28 // register their URLs in this manager on each request. | 28 // register their URLs in this manager on each request. |
| 29 // | 29 // |
| 30 // URLRequestThrottlerManager maintains a map of URL IDs to URL request | 30 // URLRequestThrottlerManager maintains a map of URL IDs to URL request |
| 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 : public NetworkChangeNotifier::IPAddressObserver, |
| 37 public NetworkChangeNotifier::IPAddressObserver, | |
| 38 public NetworkChangeNotifier::ConnectionTypeObserver { | 37 public NetworkChangeNotifier::ConnectionTypeObserver { |
| 39 public: | 38 public: |
| 40 URLRequestThrottlerManager(); | 39 URLRequestThrottlerManager(); |
| 41 ~URLRequestThrottlerManager() override; | 40 ~URLRequestThrottlerManager() override; |
| 42 | 41 |
| 43 // Must be called for every request, returns the URL request throttler entry | 42 // 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. | 43 // 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 | 44 // Please refer to url_request_throttler_entry_interface.h for further |
| 46 // informations. | 45 // informations. |
| 47 scoped_refptr<URLRequestThrottlerEntryInterface> RegisterRequestUrl( | 46 scoped_refptr<URLRequestThrottlerEntryInterface> RegisterRequestUrl( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Initially false, switches to true once we have logged because of back-off | 138 // Initially false, switches to true once we have logged because of back-off |
| 140 // being disabled for localhost. | 139 // being disabled for localhost. |
| 141 bool logged_for_localhost_disabled_; | 140 bool logged_for_localhost_disabled_; |
| 142 | 141 |
| 143 // NetLog to use, if configured. | 142 // NetLog to use, if configured. |
| 144 NetLogWithSource net_log_; | 143 NetLogWithSource net_log_; |
| 145 | 144 |
| 146 // Valid once we've registered for network notifications. | 145 // Valid once we've registered for network notifications. |
| 147 base::PlatformThreadId registered_from_thread_; | 146 base::PlatformThreadId registered_from_thread_; |
| 148 | 147 |
| 148 THREAD_CHECKER(thread_checker_); |
| 149 |
| 149 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); | 150 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); |
| 150 }; | 151 }; |
| 151 | 152 |
| 152 } // namespace net | 153 } // namespace net |
| 153 | 154 |
| 154 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 155 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
| OLD | NEW |