| 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/renderer_host/websocket_dispatcher_host.h" | 5 #include "content/browser/renderer_host/websocket_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 routing_id, this, get_context_callback_.Run(), delay); | 76 routing_id, this, get_context_callback_.Run(), delay); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool WebSocketDispatcherHost::OnMessageReceived(const IPC::Message& message) { | 79 bool WebSocketDispatcherHost::OnMessageReceived(const IPC::Message& message) { |
| 80 switch (message.type()) { | 80 switch (message.type()) { |
| 81 case WebSocketHostMsg_AddChannelRequest::ID: | 81 case WebSocketHostMsg_AddChannelRequest::ID: |
| 82 case WebSocketHostMsg_SendBlob::ID: | 82 case WebSocketHostMsg_SendBlob::ID: |
| 83 case WebSocketMsg_SendFrame::ID: | 83 case WebSocketMsg_SendFrame::ID: |
| 84 case WebSocketMsg_FlowControl::ID: | 84 case WebSocketMsg_FlowControl::ID: |
| 85 case WebSocketMsg_DropChannel::ID: | 85 case WebSocketMsg_DropChannel::ID: |
| 86 case WebSocketHostMsg_LoaderTransferTest_Setup::ID: |
| 87 case WebSocketHostMsg_LoaderTransferTest_Send::ID: |
| 88 case WebSocketHostMsg_LoaderTransferTest_Close::ID: |
| 86 break; | 89 break; |
| 87 | 90 |
| 88 default: | 91 default: |
| 89 // Every message that has not been handled by a previous filter passes | 92 // Every message that has not been handled by a previous filter passes |
| 90 // through here, so it is good to pass them on as efficiently as possible. | 93 // through here, so it is good to pass them on as efficiently as possible. |
| 91 return false; | 94 return false; |
| 92 } | 95 } |
| 93 | 96 |
| 94 int routing_id = message.routing_id(); | 97 int routing_id = message.routing_id(); |
| 95 WebSocketHost* host = GetHost(routing_id); | 98 WebSocketHost* host = GetHost(routing_id); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 uint16_t code, | 230 uint16_t code, |
| 228 const std::string& reason) { | 231 const std::string& reason) { |
| 229 if (SendOrDrop( | 232 if (SendOrDrop( |
| 230 new WebSocketMsg_DropChannel(routing_id, was_clean, code, reason)) == | 233 new WebSocketMsg_DropChannel(routing_id, was_clean, code, reason)) == |
| 231 WEBSOCKET_HOST_DELETED) | 234 WEBSOCKET_HOST_DELETED) |
| 232 return WEBSOCKET_HOST_DELETED; | 235 return WEBSOCKET_HOST_DELETED; |
| 233 DeleteWebSocketHost(routing_id); | 236 DeleteWebSocketHost(routing_id); |
| 234 return WEBSOCKET_HOST_DELETED; | 237 return WEBSOCKET_HOST_DELETED; |
| 235 } | 238 } |
| 236 | 239 |
| 240 |
| 241 void WebSocketDispatcherHost::SendLoaderTransferTest_SetDataBuffer( |
| 242 int routing_id, base::SharedMemoryHandle shm_handle) { |
| 243 Send(new WebSocketMsg_LoaderTransferTest_SetDataBuffer( |
| 244 routing_id, shm_handle)); |
| 245 } |
| 246 |
| 247 void WebSocketDispatcherHost::SendLoaderTransferTest_Ack(int routing_id) { |
| 248 Send(new WebSocketMsg_LoaderTransferTest_Ack(routing_id)); |
| 249 } |
| 250 |
| 251 void WebSocketDispatcherHost::SendLoaderTransferTest_Done(int routing_id) { |
| 252 Send(new WebSocketMsg_LoaderTransferTest_Done(routing_id)); |
| 253 } |
| 254 |
| 237 WebSocketDispatcherHost::~WebSocketDispatcherHost() { | 255 WebSocketDispatcherHost::~WebSocketDispatcherHost() { |
| 238 std::vector<WebSocketHost*> hosts; | 256 std::vector<WebSocketHost*> hosts; |
| 239 for (base::hash_map<int, WebSocketHost*>::const_iterator i = hosts_.begin(); | 257 for (base::hash_map<int, WebSocketHost*>::const_iterator i = hosts_.begin(); |
| 240 i != hosts_.end(); ++i) { | 258 i != hosts_.end(); ++i) { |
| 241 // In order to avoid changing the container while iterating, we copy | 259 // In order to avoid changing the container while iterating, we copy |
| 242 // the hosts. | 260 // the hosts. |
| 243 hosts.push_back(i->second); | 261 hosts.push_back(i->second); |
| 244 } | 262 } |
| 245 | 263 |
| 246 for (size_t i = 0; i < hosts.size(); ++i) { | 264 for (size_t i = 0; i < hosts.size(); ++i) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 num_current_succeeded_connections_ = 0; | 319 num_current_succeeded_connections_ = 0; |
| 302 | 320 |
| 303 if (num_pending_connections_ == 0 && | 321 if (num_pending_connections_ == 0 && |
| 304 num_previous_failed_connections_ == 0 && | 322 num_previous_failed_connections_ == 0 && |
| 305 num_previous_succeeded_connections_ == 0) { | 323 num_previous_succeeded_connections_ == 0) { |
| 306 throttling_period_timer_.Stop(); | 324 throttling_period_timer_.Stop(); |
| 307 } | 325 } |
| 308 } | 326 } |
| 309 | 327 |
| 310 } // namespace content | 328 } // namespace content |
| OLD | NEW |