Chromium Code Reviews| Index: net/url_request/url_request_throttler_manager.h |
| diff --git a/net/url_request/url_request_throttler_manager.h b/net/url_request/url_request_throttler_manager.h |
| index 4b9b21f316ee3ad53f60e9b49371e4c2531edfb7..28e4b69ea106289fda4f255bd25932bd1313b91e 100644 |
| --- a/net/url_request/url_request_throttler_manager.h |
| +++ b/net/url_request/url_request_throttler_manager.h |
| @@ -16,10 +16,14 @@ |
| #include "base/threading/non_thread_safe.h" |
| #include "googleurl/src/gurl.h" |
| #include "net/base/net_api.h" |
| +#include "net/base/network_change_notifier.h" |
| #include "net/url_request/url_request_throttler_entry.h" |
| namespace net { |
| +class BoundNetLog; |
| +class NetLog; |
| + |
| // Class that registers URL request throttler entries for URLs being accessed |
| // in order to supervise traffic. URL requests for HTTP contents should |
| // register their URLs in this manager on each request. |
| @@ -33,8 +37,10 @@ namespace net { |
| // NOTE: All usage of this singleton object must be on the same thread, |
| // although to allow it to be used as a singleton, construction and destruction |
| // can occur on a separate thread. |
| -class NET_API URLRequestThrottlerManager |
|
wtc
2011/05/25 23:12:06
IMPORTANT: this is a merging error. Please add ba
Jói
2011/05/26 14:53:42
Fixed. Thanks for catching that.
|
| - : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| +class URLRequestThrottlerManager |
| + : NON_EXPORTED_BASE(public base::NonThreadSafe), |
| + public NetworkChangeNotifier::IPAddressObserver, |
| + public NetworkChangeNotifier::OnlineStateObserver { |
| public: |
| static URLRequestThrottlerManager* GetInstance(); |
| @@ -71,6 +77,16 @@ class NET_API URLRequestThrottlerManager |
| void set_enforce_throttling(bool enforce); |
| bool enforce_throttling(); |
| + // Sets the NetLog instance to use. |
| + void set_net_log(NetLog* net_log); |
| + NetLog* net_log() const; |
| + |
| + // IPAddressObserver interface. |
| + virtual void OnIPAddressChanged() OVERRIDE; |
| + |
| + // OnlineStateObserver interface. |
| + virtual void OnOnlineStateChanged(bool online) OVERRIDE; |
| + |
| protected: |
| URLRequestThrottlerManager(); |
| ~URLRequestThrottlerManager(); |
| @@ -90,6 +106,15 @@ class NET_API URLRequestThrottlerManager |
| // Method that does the actual work of garbage collecting. |
| void GarbageCollectEntries(); |
| + // When we switch from online to offline or change IP addresses, we |
| + // clear all back-off history. This is a precaution in case the change in |
| + // online state now lets us communicate without error with servers that |
| + // we were previously getting 500 or 503 responses from (perhaps the |
| + // responses are from a badly-written proxy that should have returned a |
| + // 502 or 504 because it's upstream connection was down or it had no route |
| + // to the server). |
| + void OnNetworkChange(); |
| + |
| // Used by tests. |
| int GetNumberOfEntriesForTests() const { return url_entries_.size(); } |
| @@ -136,6 +161,13 @@ class NET_API URLRequestThrottlerManager |
| // workaround. |
| bool enable_thread_checks_; |
| + // Initially false, switches to true once we have logged because of back-off |
| + // being disabled for localhost. |
| + bool logged_for_localhost_disabled_; |
| + |
| + // NetLog to use, or NULL if none configured. |
| + scoped_ptr<BoundNetLog> net_log_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager); |
| }; |