| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
| 18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 19 #include "net/base/net_api.h" | 19 #include "net/base/net_export.h" |
| 20 #include "net/base/network_change_notifier.h" | 20 #include "net/base/network_change_notifier.h" |
| 21 #include "net/url_request/url_request_throttler_entry.h" | 21 #include "net/url_request/url_request_throttler_entry.h" |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 | 24 |
| 25 class BoundNetLog; | 25 class BoundNetLog; |
| 26 class NetLog; | 26 class NetLog; |
| 27 | 27 |
| 28 // Class that registers URL request throttler entries for URLs being accessed | 28 // Class that registers URL request throttler entries for URLs being accessed |
| 29 // in order to supervise traffic. URL requests for HTTP contents should | 29 // in order to supervise traffic. URL requests for HTTP contents should |
| 30 // register their URLs in this manager on each request. | 30 // register their URLs in this manager on each request. |
| 31 // | 31 // |
| 32 // URLRequestThrottlerManager maintains a map of URL IDs to URL request | 32 // URLRequestThrottlerManager maintains a map of URL IDs to URL request |
| 33 // throttler entries. It creates URL request throttler entries when new URLs | 33 // throttler entries. It creates URL request throttler entries when new URLs |
| 34 // are registered, and does garbage collection from time to time in order to | 34 // are registered, and does garbage collection from time to time in order to |
| 35 // clean out outdated entries. URL ID consists of lowercased scheme, host, port | 35 // clean out outdated entries. URL ID consists of lowercased scheme, host, port |
| 36 // and path. All URLs converted to the same ID will share the same entry. | 36 // and path. All URLs converted to the same ID will share the same entry. |
| 37 // | 37 // |
| 38 // NOTE: All usage of this singleton object must be on the same thread, | 38 // NOTE: All usage of this singleton object must be on the same thread, |
| 39 // although to allow it to be used as a singleton, construction and destruction | 39 // although to allow it to be used as a singleton, construction and destruction |
| 40 // can occur on a separate thread. | 40 // can occur on a separate thread. |
| 41 class NET_API URLRequestThrottlerManager | 41 class NET_EXPORT URLRequestThrottlerManager |
| 42 : NON_EXPORTED_BASE(public base::NonThreadSafe), | 42 : NON_EXPORTED_BASE(public base::NonThreadSafe), |
| 43 public NetworkChangeNotifier::IPAddressObserver, | 43 public NetworkChangeNotifier::IPAddressObserver, |
| 44 public NetworkChangeNotifier::OnlineStateObserver { | 44 public NetworkChangeNotifier::OnlineStateObserver { |
| 45 public: | 45 public: |
| 46 static URLRequestThrottlerManager* GetInstance(); | 46 static URLRequestThrottlerManager* GetInstance(); |
| 47 | 47 |
| 48 // Must be called for every request, returns the URL request throttler entry | 48 // Must be called for every request, returns the URL request throttler entry |
| 49 // associated with the URL. The caller must inform this entry of some events. | 49 // associated with the URL. The caller must inform this entry of some events. |
| 50 // Please refer to url_request_throttler_entry_interface.h for further | 50 // Please refer to url_request_throttler_entry_interface.h for further |
| 51 // informations. | 51 // informations. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 // Valid once we've registered for network notifications. | 172 // Valid once we've registered for network notifications. |
| 173 base::PlatformThreadId registered_from_thread_; | 173 base::PlatformThreadId registered_from_thread_; |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); | 175 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 } // namespace net | 178 } // namespace net |
| 179 | 179 |
| 180 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 180 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
| OLD | NEW |