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/child/websocket_bridge.h" | 5 #include "content/child/websocket_bridge.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "content/child/child_thread.h" | 14 #include "content/child/child_thread.h" |
15 #include "content/child/websocket_dispatcher.h" | 15 #include "content/child/websocket_dispatcher.h" |
16 #include "content/common/websocket.h" | 16 #include "content/common/websocket.h" |
17 #include "content/common/websocket_messages.h" | 17 #include "content/common/websocket_messages.h" |
18 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
19 #include "ipc/ipc_message_macros.h" | 19 #include "ipc/ipc_message_macros.h" |
20 #include "url/gurl.h" | |
21 #include "third_party/WebKit/public/platform/WebSocketHandle.h" | 20 #include "third_party/WebKit/public/platform/WebSocketHandle.h" |
22 #include "third_party/WebKit/public/platform/WebSocketHandleClient.h" | 21 #include "third_party/WebKit/public/platform/WebSocketHandleClient.h" |
23 #include "third_party/WebKit/public/platform/WebSocketHandshakeRequestInfo.h" | 22 #include "third_party/WebKit/public/platform/WebSocketHandshakeRequestInfo.h" |
24 #include "third_party/WebKit/public/platform/WebSocketHandshakeResponseInfo.h" | 23 #include "third_party/WebKit/public/platform/WebSocketHandshakeResponseInfo.h" |
25 #include "third_party/WebKit/public/platform/WebString.h" | 24 #include "third_party/WebKit/public/platform/WebString.h" |
26 #include "third_party/WebKit/public/platform/WebURL.h" | 25 #include "third_party/WebKit/public/platform/WebURL.h" |
27 #include "third_party/WebKit/public/platform/WebVector.h" | 26 #include "third_party/WebKit/public/platform/WebVector.h" |
| 27 #include "url/gurl.h" |
| 28 #include "url/origin.h" |
28 | 29 |
29 using blink::WebSocketHandle; | 30 using blink::WebSocketHandle; |
30 using blink::WebSocketHandleClient; | 31 using blink::WebSocketHandleClient; |
31 using blink::WebString; | 32 using blink::WebString; |
32 using blink::WebURL; | 33 using blink::WebURL; |
33 using blink::WebVector; | 34 using blink::WebVector; |
34 | 35 |
35 namespace content { | 36 namespace content { |
36 | 37 |
37 namespace { | 38 namespace { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 WebSocketHandleClient* client) { | 210 WebSocketHandleClient* client) { |
210 DCHECK_EQ(kInvalidChannelId, channel_id_); | 211 DCHECK_EQ(kInvalidChannelId, channel_id_); |
211 WebSocketDispatcher* dispatcher = | 212 WebSocketDispatcher* dispatcher = |
212 ChildThread::current()->websocket_dispatcher(); | 213 ChildThread::current()->websocket_dispatcher(); |
213 channel_id_ = dispatcher->AddBridge(this); | 214 channel_id_ = dispatcher->AddBridge(this); |
214 client_ = client; | 215 client_ = client; |
215 | 216 |
216 std::vector<std::string> protocols_to_pass; | 217 std::vector<std::string> protocols_to_pass; |
217 for (size_t i = 0; i < protocols.size(); ++i) | 218 for (size_t i = 0; i < protocols.size(); ++i) |
218 protocols_to_pass.push_back(protocols[i].utf8()); | 219 protocols_to_pass.push_back(protocols[i].utf8()); |
219 GURL origin_to_pass(origin.utf8()); | 220 url::Origin origin_to_pass(origin.utf8()); |
220 | 221 |
221 DVLOG(1) << "Bridge#" << channel_id_ << " Connect(" | 222 DVLOG(1) << "Bridge#" << channel_id_ << " Connect(" << url << ", (" |
222 << url << ", (" << JoinString(protocols_to_pass, ", ") << "), " | 223 << JoinString(protocols_to_pass, ", ") << "), " |
223 << origin_to_pass << ")"; | 224 << origin_to_pass.string() << ")"; |
224 | 225 |
225 ChildThread::current()->Send( | 226 ChildThread::current()->Send( |
226 new WebSocketHostMsg_AddChannelRequest(channel_id_, | 227 new WebSocketHostMsg_AddChannelRequest(channel_id_, |
227 url, | 228 url, |
228 protocols_to_pass, | 229 protocols_to_pass, |
229 origin_to_pass)); | 230 origin_to_pass)); |
230 } | 231 } |
231 | 232 |
232 void WebSocketBridge::send(bool fin, | 233 void WebSocketBridge::send(bool fin, |
233 WebSocketHandle::MessageType type, | 234 WebSocketHandle::MessageType type, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 return; | 289 return; |
289 WebSocketDispatcher* dispatcher = | 290 WebSocketDispatcher* dispatcher = |
290 ChildThread::current()->websocket_dispatcher(); | 291 ChildThread::current()->websocket_dispatcher(); |
291 dispatcher->RemoveBridge(channel_id_); | 292 dispatcher->RemoveBridge(channel_id_); |
292 | 293 |
293 channel_id_ = kInvalidChannelId; | 294 channel_id_ = kInvalidChannelId; |
294 client_ = NULL; | 295 client_ = NULL; |
295 } | 296 } |
296 | 297 |
297 } // namespace content | 298 } // namespace content |
OLD | NEW |