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

Unified Diff: content/browser/renderer_host/socket_stream_dispatcher_host.cc

Issue 18932005: Reduce the complexity of WebSocketThrottle's wakeup code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android_dbg build fix Created 7 years, 5 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
« no previous file with comments | « no previous file | net/base/net_error_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/socket_stream_dispatcher_host.cc
diff --git a/content/browser/renderer_host/socket_stream_dispatcher_host.cc b/content/browser/renderer_host/socket_stream_dispatcher_host.cc
index 30f3d35a1f96587cb90e6a63bc110c7af32fa39f..7f122df2c733f790e7a41eaa67373f2086b7e69c 100644
--- a/content/browser/renderer_host/socket_stream_dispatcher_host.cc
+++ b/content/browser/renderer_host/socket_stream_dispatcher_host.cc
@@ -14,6 +14,7 @@
#include "content/common/socket_stream_messages.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/global_request_id.h"
+#include "net/base/net_errors.h"
#include "net/cookies/canonical_cookie.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/websockets/websocket_job.h"
@@ -21,6 +22,12 @@
namespace content {
+namespace {
+
+const size_t kMaxSocketStreamHosts = 16 * 1024;
+
+} // namespace
+
SocketStreamDispatcherHost::SocketStreamDispatcherHost(
int render_process_id,
ResourceMessageFilter::URLRequestContextSelector* selector,
@@ -197,6 +204,18 @@ void SocketStreamDispatcherHost::OnConnect(int render_view_id,
<< " url=" << url
<< " socket_id=" << socket_id;
DCHECK_NE(kNoSocketId, socket_id);
+
+ if (hosts_.size() >= kMaxSocketStreamHosts) {
+ if (!Send(new SocketStreamMsg_Failed(socket_id,
+ net::ERR_TOO_MANY_SOCKET_STREAMS))) {
+ DVLOG(1) << "SocketStreamMsg_Failed failed.";
+ }
+ if (!Send(new SocketStreamMsg_Closed(socket_id))) {
+ DVLOG(1) << "SocketStreamMsg_Closed failed.";
+ }
+ return;
+ }
+
if (hosts_.Lookup(socket_id)) {
DVLOG(1) << "socket_id=" << socket_id << " already registered.";
return;
« no previous file with comments | « no previous file | net/base/net_error_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698