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

Side by Side Diff: content/browser/websockets/websocket_manager.cc

Issue 2343433002: WebSocket Mojo API: set reason when disconnecting a WebSocket interface because of insufficient res… (Closed)
Patch Set: . Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/websockets/WebSocketHandleImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/websockets/websocket_manager.h" 5 #include "content/browser/websockets/websocket_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 delete impl; 101 delete impl;
102 } 102 }
103 } 103 }
104 104
105 void WebSocketManager::DoCreateWebSocket( 105 void WebSocketManager::DoCreateWebSocket(
106 int frame_id, 106 int frame_id,
107 blink::mojom::WebSocketRequest request) { 107 blink::mojom::WebSocketRequest request) {
108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
109 109
110 if (num_pending_connections_ >= kMaxPendingWebSocketConnections) { 110 if (num_pending_connections_ >= kMaxPendingWebSocketConnections) {
111 // Too many websockets! By returning here, we let |request| die, which 111 // Too many websockets!
112 // will be observed by the client as Mojo connection error. 112 request.ResetWithReason(
113 blink::mojom::WebSocket::kInsufficientResources,
114 "Error in connection establishment: net::ERR_INSUFFICIENT_RESOURCES");
113 return; 115 return;
114 } 116 }
115 117
116 // Keep all WebSocketImpls alive until either the client drops its 118 // Keep all WebSocketImpls alive until either the client drops its
117 // connection (see OnLostConnectionToClient) or we need to shutdown. 119 // connection (see OnLostConnectionToClient) or we need to shutdown.
118 120
119 impls_.insert(CreateWebSocketImpl(this, std::move(request), frame_id, 121 impls_.insert(CreateWebSocketImpl(this, std::move(request), frame_id,
120 CalculateDelay())); 122 CalculateDelay()));
121 ++num_pending_connections_; 123 ++num_pending_connections_;
122 124
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 --num_pending_connections_; 189 --num_pending_connections_;
188 DCHECK_GE(num_pending_connections_, 0); 190 DCHECK_GE(num_pending_connections_, 0);
189 ++num_current_failed_connections_; 191 ++num_current_failed_connections_;
190 } 192 }
191 impl->GoAway(); 193 impl->GoAway();
192 impls_.erase(impl); 194 impls_.erase(impl);
193 delete impl; 195 delete impl;
194 } 196 }
195 197
196 } // namespace content 198 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/websockets/WebSocketHandleImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698