OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |