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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Too many websockets! | 111 // Too many websockets! |
112 request.ResetWithReason( | 112 request.ResetWithReason( |
113 blink::mojom::WebSocket::kInsufficientResources, | 113 blink::mojom::WebSocket::kInsufficientResources, |
114 "Error in connection establishment: net::ERR_INSUFFICIENT_RESOURCES"); | 114 "Error in connection establishment: net::ERR_INSUFFICIENT_RESOURCES"); |
115 return; | 115 return; |
116 } | 116 } |
117 | 117 |
118 // Keep all WebSocketImpls alive until either the client drops its | 118 // Keep all WebSocketImpls alive until either the client drops its |
119 // connection (see OnLostConnectionToClient) or we need to shutdown. | 119 // connection (see OnLostConnectionToClient) or we need to shutdown. |
120 | 120 |
121 impls_.insert(CreateWebSocketImpl(this, std::move(request), frame_id, | 121 impls_.insert(CreateWebSocketImpl(this, std::move(request), process_id_, |
122 CalculateDelay())); | 122 frame_id, CalculateDelay())); |
123 ++num_pending_connections_; | 123 ++num_pending_connections_; |
124 | 124 |
125 if (!throttling_period_timer_.IsRunning()) { | 125 if (!throttling_period_timer_.IsRunning()) { |
126 throttling_period_timer_.Start( | 126 throttling_period_timer_.Start( |
127 FROM_HERE, | 127 FROM_HERE, |
128 base::TimeDelta::FromMinutes(2), | 128 base::TimeDelta::FromMinutes(2), |
129 this, | 129 this, |
130 &WebSocketManager::ThrottlingPeriodTimerCallback); | 130 &WebSocketManager::ThrottlingPeriodTimerCallback); |
131 } | 131 } |
132 } | 132 } |
(...skipping 21 matching lines...) Expand all Loading... |
154 if (num_pending_connections_ == 0 && | 154 if (num_pending_connections_ == 0 && |
155 num_previous_failed_connections_ == 0 && | 155 num_previous_failed_connections_ == 0 && |
156 num_previous_succeeded_connections_ == 0) { | 156 num_previous_succeeded_connections_ == 0) { |
157 throttling_period_timer_.Stop(); | 157 throttling_period_timer_.Stop(); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 WebSocketImpl* WebSocketManager::CreateWebSocketImpl( | 161 WebSocketImpl* WebSocketManager::CreateWebSocketImpl( |
162 WebSocketImpl::Delegate* delegate, | 162 WebSocketImpl::Delegate* delegate, |
163 blink::mojom::WebSocketRequest request, | 163 blink::mojom::WebSocketRequest request, |
| 164 int child_id, |
164 int frame_id, | 165 int frame_id, |
165 base::TimeDelta delay) { | 166 base::TimeDelta delay) { |
166 return new WebSocketImpl(delegate, std::move(request), frame_id, delay); | 167 return new WebSocketImpl(delegate, std::move(request), child_id, frame_id, |
| 168 delay); |
167 } | 169 } |
168 | 170 |
169 int WebSocketManager::GetClientProcessId() { | 171 int WebSocketManager::GetClientProcessId() { |
170 return process_id_; | 172 return process_id_; |
171 } | 173 } |
172 | 174 |
173 StoragePartition* WebSocketManager::GetStoragePartition() { | 175 StoragePartition* WebSocketManager::GetStoragePartition() { |
174 return storage_partition_; | 176 return storage_partition_; |
175 } | 177 } |
176 | 178 |
(...skipping 12 matching lines...) Expand all Loading... |
189 --num_pending_connections_; | 191 --num_pending_connections_; |
190 DCHECK_GE(num_pending_connections_, 0); | 192 DCHECK_GE(num_pending_connections_, 0); |
191 ++num_current_failed_connections_; | 193 ++num_current_failed_connections_; |
192 } | 194 } |
193 impl->GoAway(); | 195 impl->GoAway(); |
194 impls_.erase(impl); | 196 impls_.erase(impl); |
195 delete impl; | 197 delete impl; |
196 } | 198 } |
197 | 199 |
198 } // namespace content | 200 } // namespace content |
OLD | NEW |