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

Unified Diff: content/browser/renderer_host/websocket_host.h

Issue 972963002: Per-renderer WebSocket throttling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Style fixes, bug fixes. Created 5 years, 10 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: content/browser/renderer_host/websocket_host.h
diff --git a/content/browser/renderer_host/websocket_host.h b/content/browser/renderer_host/websocket_host.h
index 39c1e41edbed3d56985f1bba437898bfae234c80..0d1cf842d6e3f6c21b89884835de297fefd7dcb8 100644
--- a/content/browser/renderer_host/websocket_host.h
+++ b/content/browser/renderer_host/websocket_host.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "content/common/websocket.h"
@@ -37,7 +38,8 @@ class CONTENT_EXPORT WebSocketHost {
public:
WebSocketHost(int routing_id,
WebSocketDispatcherHost* dispatcher,
- net::URLRequestContext* url_request_context);
+ net::URLRequestContext* url_request_context,
+ int delay_in_ms);
Adam Rice 2015/03/03 15:10:03 I would make this argument type a base::TimeDelta
hiroshige 2015/03/04 06:02:38 Done.
virtual ~WebSocketHost();
// The renderer process is going away.
@@ -50,6 +52,9 @@ class CONTENT_EXPORT WebSocketHost {
int routing_id() const { return routing_id_; }
+ bool handshakeSucceeded() const { return handshake_succeeded_; }
Adam Rice 2015/03/03 15:10:03 This should be named handshake_succeeded() by Chro
hiroshige 2015/03/04 06:02:38 Done.
+ void OnHandshakeSucceeded() { handshake_succeeded_ = true; }
+
private:
// Handlers for each message type, dispatched by OnMessageReceived(), as
// defined in content/common/websocket_messages.h
@@ -59,6 +64,11 @@ class CONTENT_EXPORT WebSocketHost {
const url::Origin& origin,
int render_frame_id);
+ void AddChannel(const GURL& socket_url,
+ const std::vector<std::string>& requested_protocols,
+ const url::Origin& origin,
+ int render_frame_id);
+
void OnSendFrame(bool fin,
WebSocketMessageType type,
const std::vector<char>& data);
@@ -79,6 +89,20 @@ class CONTENT_EXPORT WebSocketHost {
// The ID used to route messages.
const int routing_id_;
+ // Delay used for per-renderer WebSocket throttling.
+ int delay_in_ms_;
+
+ // SendFlowControl() is delayed when OnFlowControl() is called before
+ // AddChannel() is called.
+ // A negative value indicates there is no pending SendFlowControl().
Adam Rice 2015/03/03 15:10:03 I would just use 0 to mean no pending flow control
hiroshige 2015/03/04 06:02:38 Done.
+ int64 pending_flow_control_quota_;
+
+ // handshake_succeeded_ is set and used by WebSocketDispatcherHost
+ // to manage counters for per-renderer WebSocket throttling.
+ bool handshake_succeeded_;
+
+ base::WeakPtrFactory<WebSocketHost> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(WebSocketHost);
};

Powered by Google App Engine
This is Rietveld 408576698