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> |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 if (!client_) | 199 if (!client_) |
200 return; | 200 return; |
201 | 201 |
202 client_->didStartClosingHandshake(this); | 202 client_->didStartClosingHandshake(this); |
203 // |this| can be deleted here. | 203 // |this| can be deleted here. |
204 } | 204 } |
205 | 205 |
206 void WebSocketBridge::connect(const WebURL& url, | 206 void WebSocketBridge::connect(const WebURL& url, |
207 const WebVector<WebString>& protocols, | 207 const WebVector<WebString>& protocols, |
208 const WebSecurityOrigin& origin, | 208 const WebSecurityOrigin& origin, |
| 209 const WebString& user_agent_override, |
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 ChildThreadImpl::current()->websocket_dispatcher(); | 213 ChildThreadImpl::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 | 220 |
220 DVLOG(1) << "Bridge#" << channel_id_ << " Connect(" << url << ", (" | 221 DVLOG(1) << "Bridge#" << channel_id_ << " Connect(" << url << ", (" |
221 << base::JoinString(protocols_to_pass, ", ") << "), " | 222 << base::JoinString(protocols_to_pass, ", ") << "), " |
222 << origin.toString().utf8() << ")"; | 223 << origin.toString().utf8() << ")"; |
223 | 224 |
| 225 // Headers (ie: User-Agent) are ISO Latin 1. |
224 ChildThreadImpl::current()->Send(new WebSocketHostMsg_AddChannelRequest( | 226 ChildThreadImpl::current()->Send(new WebSocketHostMsg_AddChannelRequest( |
225 channel_id_, url, protocols_to_pass, origin, render_frame_id_)); | 227 channel_id_, url, protocols_to_pass, origin, |
| 228 user_agent_override.latin1(), render_frame_id_)); |
226 } | 229 } |
227 | 230 |
228 void WebSocketBridge::send(bool fin, | 231 void WebSocketBridge::send(bool fin, |
229 WebSocketHandle::MessageType type, | 232 WebSocketHandle::MessageType type, |
230 const char* data, | 233 const char* data, |
231 size_t size) { | 234 size_t size) { |
232 if (channel_id_ == kInvalidChannelId) | 235 if (channel_id_ == kInvalidChannelId) |
233 return; | 236 return; |
234 | 237 |
235 WebSocketMessageType type_to_pass = WEB_SOCKET_MESSAGE_TYPE_CONTINUATION; | 238 WebSocketMessageType type_to_pass = WEB_SOCKET_MESSAGE_TYPE_CONTINUATION; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 return; | 287 return; |
285 WebSocketDispatcher* dispatcher = | 288 WebSocketDispatcher* dispatcher = |
286 ChildThreadImpl::current()->websocket_dispatcher(); | 289 ChildThreadImpl::current()->websocket_dispatcher(); |
287 dispatcher->RemoveBridge(channel_id_); | 290 dispatcher->RemoveBridge(channel_id_); |
288 | 291 |
289 channel_id_ = kInvalidChannelId; | 292 channel_id_ = kInvalidChannelId; |
290 client_ = NULL; | 293 client_ = NULL; |
291 } | 294 } |
292 | 295 |
293 } // namespace content | 296 } // namespace content |
OLD | NEW |