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_host.h" | 5 #include "content/browser/renderer_host/websocket_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "content/browser/renderer_host/websocket_dispatcher_host.h" | 10 #include "content/browser/renderer_host/websocket_dispatcher_host.h" |
11 #include "content/browser/ssl/ssl_error_handler.h" | 11 #include "content/browser/ssl/ssl_error_handler.h" |
12 #include "content/browser/ssl/ssl_manager.h" | 12 #include "content/browser/ssl/ssl_manager.h" |
13 #include "content/common/websocket_messages.h" | 13 #include "content/common/websocket_messages.h" |
14 #include "ipc/ipc_message_macros.h" | 14 #include "ipc/ipc_message_macros.h" |
15 #include "net/http/http_request_headers.h" | 15 #include "net/http/http_request_headers.h" |
16 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
17 #include "net/http/http_util.h" | 17 #include "net/http/http_util.h" |
18 #include "net/ssl/ssl_info.h" | 18 #include "net/ssl/ssl_info.h" |
19 #include "net/websockets/websocket_channel.h" | 19 #include "net/websockets/websocket_channel.h" |
20 #include "net/websockets/websocket_errors.h" | |
21 #include "net/websockets/websocket_event_interface.h" | 20 #include "net/websockets/websocket_event_interface.h" |
22 #include "net/websockets/websocket_frame.h" // for WebSocketFrameHeader::OpCode | 21 #include "net/websockets/websocket_frame.h" // for WebSocketFrameHeader::OpCode |
23 #include "net/websockets/websocket_handshake_request_info.h" | 22 #include "net/websockets/websocket_handshake_request_info.h" |
24 #include "net/websockets/websocket_handshake_response_info.h" | 23 #include "net/websockets/websocket_handshake_response_info.h" |
25 #include "url/origin.h" | 24 #include "url/origin.h" |
26 | 25 |
27 namespace content { | 26 namespace content { |
28 | 27 |
29 namespace { | 28 namespace { |
30 | 29 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 WebSocketDispatcherHost* dispatcher, | 323 WebSocketDispatcherHost* dispatcher, |
325 net::URLRequestContext* url_request_context) | 324 net::URLRequestContext* url_request_context) |
326 : dispatcher_(dispatcher), | 325 : dispatcher_(dispatcher), |
327 url_request_context_(url_request_context), | 326 url_request_context_(url_request_context), |
328 routing_id_(routing_id) { | 327 routing_id_(routing_id) { |
329 DVLOG(1) << "WebSocketHost: created routing_id=" << routing_id; | 328 DVLOG(1) << "WebSocketHost: created routing_id=" << routing_id; |
330 } | 329 } |
331 | 330 |
332 WebSocketHost::~WebSocketHost() {} | 331 WebSocketHost::~WebSocketHost() {} |
333 | 332 |
334 void WebSocketHost::GoAway() { | |
335 OnDropChannel(false, static_cast<uint16>(net::kWebSocketErrorGoingAway), ""); | |
336 } | |
337 | |
338 bool WebSocketHost::OnMessageReceived(const IPC::Message& message) { | 333 bool WebSocketHost::OnMessageReceived(const IPC::Message& message) { |
339 bool handled = true; | 334 bool handled = true; |
340 IPC_BEGIN_MESSAGE_MAP(WebSocketHost, message) | 335 IPC_BEGIN_MESSAGE_MAP(WebSocketHost, message) |
341 IPC_MESSAGE_HANDLER(WebSocketHostMsg_AddChannelRequest, OnAddChannelRequest) | 336 IPC_MESSAGE_HANDLER(WebSocketHostMsg_AddChannelRequest, OnAddChannelRequest) |
342 IPC_MESSAGE_HANDLER(WebSocketMsg_SendFrame, OnSendFrame) | 337 IPC_MESSAGE_HANDLER(WebSocketMsg_SendFrame, OnSendFrame) |
343 IPC_MESSAGE_HANDLER(WebSocketMsg_FlowControl, OnFlowControl) | 338 IPC_MESSAGE_HANDLER(WebSocketMsg_FlowControl, OnFlowControl) |
344 IPC_MESSAGE_HANDLER(WebSocketMsg_DropChannel, OnDropChannel) | 339 IPC_MESSAGE_HANDLER(WebSocketMsg_DropChannel, OnDropChannel) |
345 IPC_MESSAGE_UNHANDLED(handled = false) | 340 IPC_MESSAGE_UNHANDLED(handled = false) |
346 IPC_END_MESSAGE_MAP() | 341 IPC_END_MESSAGE_MAP() |
347 return handled; | 342 return handled; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 DVLOG(3) << "WebSocketHost::OnDropChannel" | 386 DVLOG(3) << "WebSocketHost::OnDropChannel" |
392 << " routing_id=" << routing_id_ << " was_clean=" << was_clean | 387 << " routing_id=" << routing_id_ << " was_clean=" << was_clean |
393 << " code=" << code << " reason=\"" << reason << "\""; | 388 << " code=" << code << " reason=\"" << reason << "\""; |
394 | 389 |
395 DCHECK(channel_); | 390 DCHECK(channel_); |
396 // TODO(yhirano): Handle |was_clean| appropriately. | 391 // TODO(yhirano): Handle |was_clean| appropriately. |
397 channel_->StartClosingHandshake(code, reason); | 392 channel_->StartClosingHandshake(code, reason); |
398 } | 393 } |
399 | 394 |
400 } // namespace content | 395 } // namespace content |
OLD | NEW |