Index: content/browser/renderer_host/websocket_dispatcher_host.h |
diff --git a/content/browser/renderer_host/websocket_dispatcher_host.h b/content/browser/renderer_host/websocket_dispatcher_host.h |
index b9cdd343837ea2e57429adf1933455d5e2f84151..4e68354a5286e45b77c998e540638206ec7ebc0b 100644 |
--- a/content/browser/renderer_host/websocket_dispatcher_host.h |
+++ b/content/browser/renderer_host/websocket_dispatcher_host.h |
@@ -12,6 +12,7 @@ |
#include "base/callback.h" |
#include "base/compiler_specific.h" |
#include "base/containers/hash_tables.h" |
+#include "base/timer/timer.h" |
#include "content/common/content_export.h" |
#include "content/common/websocket.h" |
#include "content/public/browser/browser_message_filter.h" |
@@ -32,9 +33,9 @@ class CONTENT_EXPORT WebSocketDispatcherHost : public BrowserMessageFilter { |
public: |
typedef base::Callback<net::URLRequestContext*()> GetRequestContextCallback; |
- // Given a routing_id, WebSocketHostFactory returns a new instance of |
- // WebSocketHost or its subclass. |
- typedef base::Callback<WebSocketHost*(int)> WebSocketHostFactory; // NOLINT |
+ // Given a routing_id and delay_in_ms, WebSocketHostFactory returns a new |
+ // instance of WebSocketHost or its subclass. |
+ typedef base::Callback<WebSocketHost*(int, int)> WebSocketHostFactory; |
// Return value for methods that may delete the WebSocketHost. This enum is |
// binary-compatible with net::WebSocketEventInterface::ChannelState, to make |
@@ -118,7 +119,7 @@ class CONTENT_EXPORT WebSocketDispatcherHost : public BrowserMessageFilter { |
~WebSocketDispatcherHost() override; |
- WebSocketHost* CreateWebSocketHost(int routing_id); |
+ WebSocketHost* CreateWebSocketHost(int routing_id, int delay_in_ms); |
// Looks up a WebSocketHost object by |routing_id|. Returns the object if one |
// is found, or NULL otherwise. |
@@ -134,6 +135,12 @@ class CONTENT_EXPORT WebSocketDispatcherHost : public BrowserMessageFilter { |
// removes it from the |hosts_| table. |
void DeleteWebSocketHost(int routing_id); |
+ // Calculate delay for Per-renderer WebSocket throttling. |
+ int64 CalculateDelayInMs() const; |
Adam Rice
2015/03/03 15:10:02
This method could return a base::TimeDelta object,
hiroshige
2015/03/04 06:02:37
Done.
|
+ |
+ // FIXME |
+ void FinishThrottlingPeriod(); |
Adam Rice
2015/03/03 15:10:02
This is not a very clear name for the method. Mayb
hiroshige
2015/03/04 06:02:37
How about "ThrottlingPeriodTimerCallback()" (and c
Adam Rice
2015/03/04 08:20:49
Sounds good to me.
hiroshige
2015/03/04 11:13:14
Done.
|
+ |
// Table of WebSocketHost objects, owned by this object, indexed by |
// routing_id. |
WebSocketHostTable hosts_; |
@@ -147,6 +154,19 @@ class CONTENT_EXPORT WebSocketDispatcherHost : public BrowserMessageFilter { |
WebSocketHostFactory websocket_host_factory_; |
+ // Timer and counters for Per-renderer WebSocket throttling. |
Adam Rice
2015/03/03 15:10:02
Nitpick: The P of per-renderer should be lowercase
hiroshige
2015/03/04 06:02:37
Done.
|
+ base::RepeatingTimer<WebSocketDispatcherHost> timer_; |
Adam Rice
2015/03/03 15:10:02
A slightly more specific name might be better, lik
hiroshige
2015/03/04 11:13:14
Done.
|
+ // The current number of pending connections. |
+ int num_pending_connections_; |
+ // The number of handshakes that failed in the current and previous time |
+ // period. |
+ int num_current_succeeded_connections_; |
+ int num_previous_succeeded_connections_; |
+ // The number of handshakes that succeeded in the current and previous time |
+ // period. |
+ int num_current_failed_connections_; |
+ int num_previous_failed_connections_; |
+ |
DISALLOW_COPY_AND_ASSIGN(WebSocketDispatcherHost); |
}; |