Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Unified Diff: net/url_request/url_request_throttler_manager.h

Issue 6966038: Anti-DDoS enhancements: Log to net log, UMA stats, improved policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..846b682ad612f724f9b0d45de68e94cd0b8ef93d 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.
@@ -34,7 +38,9 @@ namespace net {
// although to allow it to be used as a singleton, construction and destruction
// can occur on a separate thread.
class NET_API URLRequestThrottlerManager
- : NON_EXPORTED_BASE(public base::NonThreadSafe) {
+ : 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);
};
« no previous file with comments | « net/url_request/url_request_throttler_entry_interface.h ('k') | net/url_request/url_request_throttler_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698