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

Side by Side Diff: content/browser/renderer_host/websocket_host.cc

Issue 170843007: Introduce url::Origin to represent Web Origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 | « content/browser/renderer_host/websocket_host.h ('k') | content/child/websocket_bridge.cc » ('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/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/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "content/browser/renderer_host/websocket_dispatcher_host.h" 9 #include "content/browser/renderer_host/websocket_dispatcher_host.h"
10 #include "content/common/websocket_messages.h" 10 #include "content/common/websocket_messages.h"
11 #include "ipc/ipc_message_macros.h" 11 #include "ipc/ipc_message_macros.h"
12 #include "net/http/http_request_headers.h" 12 #include "net/http/http_request_headers.h"
13 #include "net/http/http_response_headers.h" 13 #include "net/http/http_response_headers.h"
14 #include "net/http/http_util.h" 14 #include "net/http/http_util.h"
15 #include "net/websockets/websocket_channel.h" 15 #include "net/websockets/websocket_channel.h"
16 #include "net/websockets/websocket_event_interface.h" 16 #include "net/websockets/websocket_event_interface.h"
17 #include "net/websockets/websocket_frame.h" // for WebSocketFrameHeader::OpCode 17 #include "net/websockets/websocket_frame.h" // for WebSocketFrameHeader::OpCode
18 #include "net/websockets/websocket_handshake_request_info.h" 18 #include "net/websockets/websocket_handshake_request_info.h"
19 #include "net/websockets/websocket_handshake_response_info.h" 19 #include "net/websockets/websocket_handshake_response_info.h"
20 #include "url/origin.h"
20 21
21 namespace content { 22 namespace content {
22 23
23 namespace { 24 namespace {
24 25
25 typedef net::WebSocketEventInterface::ChannelState ChannelState; 26 typedef net::WebSocketEventInterface::ChannelState ChannelState;
26 27
27 // Convert a content::WebSocketMessageType to a 28 // Convert a content::WebSocketMessageType to a
28 // net::WebSocketFrameHeader::OpCode 29 // net::WebSocketFrameHeader::OpCode
29 net::WebSocketFrameHeader::OpCode MessageTypeToOpCode( 30 net::WebSocketFrameHeader::OpCode MessageTypeToOpCode(
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 IPC_MESSAGE_HANDLER(WebSocketMsg_FlowControl, OnFlowControl) 234 IPC_MESSAGE_HANDLER(WebSocketMsg_FlowControl, OnFlowControl)
234 IPC_MESSAGE_HANDLER(WebSocketMsg_DropChannel, OnDropChannel) 235 IPC_MESSAGE_HANDLER(WebSocketMsg_DropChannel, OnDropChannel)
235 IPC_MESSAGE_UNHANDLED(handled = false) 236 IPC_MESSAGE_UNHANDLED(handled = false)
236 IPC_END_MESSAGE_MAP_EX() 237 IPC_END_MESSAGE_MAP_EX()
237 return handled; 238 return handled;
238 } 239 }
239 240
240 void WebSocketHost::OnAddChannelRequest( 241 void WebSocketHost::OnAddChannelRequest(
241 const GURL& socket_url, 242 const GURL& socket_url,
242 const std::vector<std::string>& requested_protocols, 243 const std::vector<std::string>& requested_protocols,
243 const GURL& origin) { 244 const url::Origin& origin) {
244 DVLOG(3) << "WebSocketHost::OnAddChannelRequest" 245 DVLOG(3) << "WebSocketHost::OnAddChannelRequest"
245 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url 246 << " routing_id=" << routing_id_ << " socket_url=\"" << socket_url
246 << "\" requested_protocols=\"" 247 << "\" requested_protocols=\""
247 << JoinString(requested_protocols, ", ") << "\" origin=\"" << origin 248 << JoinString(requested_protocols, ", ") << "\" origin=\""
248 << "\""; 249 << origin.string() << "\"";
249 250
250 channel_->SendAddChannelRequest(socket_url, requested_protocols, origin); 251 channel_->SendAddChannelRequest(
252 socket_url, requested_protocols, origin);
251 } 253 }
252 254
253 void WebSocketHost::OnSendFrame(bool fin, 255 void WebSocketHost::OnSendFrame(bool fin,
254 WebSocketMessageType type, 256 WebSocketMessageType type,
255 const std::vector<char>& data) { 257 const std::vector<char>& data) {
256 DVLOG(3) << "WebSocketHost::OnSendFrame" 258 DVLOG(3) << "WebSocketHost::OnSendFrame"
257 << " routing_id=" << routing_id_ << " fin=" << fin 259 << " routing_id=" << routing_id_ << " fin=" << fin
258 << " type=" << type << " data is " << data.size() << " bytes"; 260 << " type=" << type << " data is " << data.size() << " bytes";
259 261
260 channel_->SendFrame(fin, MessageTypeToOpCode(type), data); 262 channel_->SendFrame(fin, MessageTypeToOpCode(type), data);
(...skipping 11 matching lines...) Expand all
272 const std::string& reason) { 274 const std::string& reason) {
273 DVLOG(3) << "WebSocketHost::OnDropChannel" 275 DVLOG(3) << "WebSocketHost::OnDropChannel"
274 << " routing_id=" << routing_id_ << " was_clean=" << was_clean 276 << " routing_id=" << routing_id_ << " was_clean=" << was_clean
275 << " code=" << code << " reason=\"" << reason << "\""; 277 << " code=" << code << " reason=\"" << reason << "\"";
276 278
277 // TODO(yhirano): Handle |was_clean| appropriately. 279 // TODO(yhirano): Handle |was_clean| appropriately.
278 channel_->StartClosingHandshake(code, reason); 280 channel_->StartClosingHandshake(code, reason);
279 } 281 }
280 282
281 } // namespace content 283 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/websocket_host.h ('k') | content/child/websocket_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698