| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 DVLOG(1) << "WebSocketBridge::DidStartOpeningHandshake(" | 97 DVLOG(1) << "WebSocketBridge::DidStartOpeningHandshake(" |
| 98 << request.url << ")"; | 98 << request.url << ")"; |
| 99 // All strings are already encoded to ASCII in the browser. | 99 // All strings are already encoded to ASCII in the browser. |
| 100 blink::WebSocketHandshakeRequestInfo request_to_pass; | 100 blink::WebSocketHandshakeRequestInfo request_to_pass; |
| 101 request_to_pass.setURL(WebURL(request.url)); | 101 request_to_pass.setURL(WebURL(request.url)); |
| 102 for (size_t i = 0; i < request.headers.size(); ++i) { | 102 for (size_t i = 0; i < request.headers.size(); ++i) { |
| 103 const std::pair<std::string, std::string>& header = request.headers[i]; | 103 const std::pair<std::string, std::string>& header = request.headers[i]; |
| 104 request_to_pass.addHeaderField(WebString::fromLatin1(header.first), | 104 request_to_pass.addHeaderField(WebString::fromLatin1(header.first), |
| 105 WebString::fromLatin1(header.second)); | 105 WebString::fromLatin1(header.second)); |
| 106 } | 106 } |
| 107 request_to_pass.setHeadersText(WebString::fromLatin1(request.headers_text)); |
| 107 client_->didStartOpeningHandshake(this, request_to_pass); | 108 client_->didStartOpeningHandshake(this, request_to_pass); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void WebSocketBridge::DidFinishOpeningHandshake( | 111 void WebSocketBridge::DidFinishOpeningHandshake( |
| 111 const WebSocketHandshakeResponse& response) { | 112 const WebSocketHandshakeResponse& response) { |
| 112 DVLOG(1) << "WebSocketBridge::DidFinishOpeningHandshake(" | 113 DVLOG(1) << "WebSocketBridge::DidFinishOpeningHandshake(" |
| 113 << response.url << ")"; | 114 << response.url << ")"; |
| 114 // All strings are already encoded to ASCII in the browser. | 115 // All strings are already encoded to ASCII in the browser. |
| 115 blink::WebSocketHandshakeResponseInfo response_to_pass; | 116 blink::WebSocketHandshakeResponseInfo response_to_pass; |
| 116 response_to_pass.setStatusCode(response.status_code); | 117 response_to_pass.setStatusCode(response.status_code); |
| 117 response_to_pass.setStatusText(WebString::fromLatin1(response.status_text)); | 118 response_to_pass.setStatusText(WebString::fromLatin1(response.status_text)); |
| 118 for (size_t i = 0; i < response.headers.size(); ++i) { | 119 for (size_t i = 0; i < response.headers.size(); ++i) { |
| 119 const std::pair<std::string, std::string>& header = response.headers[i]; | 120 const std::pair<std::string, std::string>& header = response.headers[i]; |
| 120 response_to_pass.addHeaderField(WebString::fromLatin1(header.first), | 121 response_to_pass.addHeaderField(WebString::fromLatin1(header.first), |
| 121 WebString::fromLatin1(header.second)); | 122 WebString::fromLatin1(header.second)); |
| 122 } | 123 } |
| 124 response_to_pass.setHeadersText(WebString::fromLatin1(response.headers_text)); |
| 123 client_->didFinishOpeningHandshake(this, response_to_pass); | 125 client_->didFinishOpeningHandshake(this, response_to_pass); |
| 124 } | 126 } |
| 125 | 127 |
| 126 void WebSocketBridge::DidFail(const std::string& message) { | 128 void WebSocketBridge::DidFail(const std::string& message) { |
| 127 DVLOG(1) << "WebSocketBridge::DidFail(" << message << ")"; | 129 DVLOG(1) << "WebSocketBridge::DidFail(" << message << ")"; |
| 128 WebSocketHandleClient* client = client_; | 130 WebSocketHandleClient* client = client_; |
| 129 Disconnect(); | 131 Disconnect(); |
| 130 if (!client) | 132 if (!client) |
| 131 return; | 133 return; |
| 132 | 134 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 return; | 277 return; |
| 276 WebSocketDispatcher* dispatcher = | 278 WebSocketDispatcher* dispatcher = |
| 277 ChildThread::current()->websocket_dispatcher(); | 279 ChildThread::current()->websocket_dispatcher(); |
| 278 dispatcher->RemoveBridge(channel_id_); | 280 dispatcher->RemoveBridge(channel_id_); |
| 279 | 281 |
| 280 channel_id_ = kInvalidChannelId; | 282 channel_id_ = kInvalidChannelId; |
| 281 client_ = NULL; | 283 client_ = NULL; |
| 282 } | 284 } |
| 283 | 285 |
| 284 } // namespace content | 286 } // namespace content |
| OLD | NEW |