| 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 "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 #include "net/base/net_api.h" |
| 18 #include "net/url_request/url_request_throttler_entry.h" | 19 #include "net/url_request/url_request_throttler_entry.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 | 22 |
| 22 // Class that registers URL request throttler entries for URLs being accessed | 23 // Class that registers URL request throttler entries for URLs being accessed |
| 23 // in order to supervise traffic. URL requests for HTTP contents should | 24 // in order to supervise traffic. URL requests for HTTP contents should |
| 24 // register their URLs in this manager on each request. | 25 // register their URLs in this manager on each request. |
| 25 // | 26 // |
| 26 // URLRequestThrottlerManager maintains a map of URL IDs to URL request | 27 // URLRequestThrottlerManager maintains a map of URL IDs to URL request |
| 27 // throttler entries. It creates URL request throttler entries when new URLs | 28 // throttler entries. It creates URL request throttler entries when new URLs |
| 28 // are registered, and does garbage collection from time to time in order to | 29 // are registered, and does garbage collection from time to time in order to |
| 29 // clean out outdated entries. URL ID consists of lowercased scheme, host, port | 30 // clean out outdated entries. URL ID consists of lowercased scheme, host, port |
| 30 // and path. All URLs converted to the same ID will share the same entry. | 31 // and path. All URLs converted to the same ID will share the same entry. |
| 31 // | 32 // |
| 32 // NOTE: All usage of this singleton object must be on the same thread, | 33 // NOTE: All usage of this singleton object must be on the same thread, |
| 33 // although to allow it to be used as a singleton, construction and destruction | 34 // although to allow it to be used as a singleton, construction and destruction |
| 34 // can occur on a separate thread. | 35 // can occur on a separate thread. |
| 35 class URLRequestThrottlerManager : public base::NonThreadSafe { | 36 class NET_API URLRequestThrottlerManager |
| 37 : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 36 public: | 38 public: |
| 37 static URLRequestThrottlerManager* GetInstance(); | 39 static URLRequestThrottlerManager* GetInstance(); |
| 38 | 40 |
| 39 // Must be called for every request, returns the URL request throttler entry | 41 // Must be called for every request, returns the URL request throttler entry |
| 40 // associated with the URL. The caller must inform this entry of some events. | 42 // associated with the URL. The caller must inform this entry of some events. |
| 41 // Please refer to url_request_throttler_entry_interface.h for further | 43 // Please refer to url_request_throttler_entry_interface.h for further |
| 42 // informations. | 44 // informations. |
| 43 scoped_refptr<URLRequestThrottlerEntryInterface> RegisterRequestUrl( | 45 scoped_refptr<URLRequestThrottlerEntryInterface> RegisterRequestUrl( |
| 44 const GURL& url); | 46 const GURL& url); |
| 45 | 47 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // TODO(joi): See if we can fix the offending unit tests and remove this | 135 // TODO(joi): See if we can fix the offending unit tests and remove this |
| 134 // workaround. | 136 // workaround. |
| 135 bool enable_thread_checks_; | 137 bool enable_thread_checks_; |
| 136 | 138 |
| 137 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); | 139 DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); |
| 138 }; | 140 }; |
| 139 | 141 |
| 140 } // namespace net | 142 } // namespace net |
| 141 | 143 |
| 142 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ | 144 #endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_MANAGER_H_ |
| OLD | NEW |