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 "net/websockets/websocket_stream.h" | 5 #include "net/websockets/websocket_stream.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 base::Unretained(this))); | 141 base::Unretained(this))); |
142 url_request_->Start(); | 142 url_request_->Start(); |
143 } | 143 } |
144 | 144 |
145 void PerformUpgrade() { | 145 void PerformUpgrade() { |
146 DCHECK(timer_); | 146 DCHECK(timer_); |
147 DCHECK(handshake_stream_); | 147 DCHECK(handshake_stream_); |
148 | 148 |
149 timer_->Stop(); | 149 timer_->Stop(); |
150 | 150 |
151 std::unique_ptr<URLRequest> url_request = std::move(url_request_); | |
151 WebSocketHandshakeStreamBase* handshake_stream = handshake_stream_; | 152 WebSocketHandshakeStreamBase* handshake_stream = handshake_stream_; |
152 handshake_stream_ = nullptr; | 153 handshake_stream_ = nullptr; |
153 connect_delegate_->OnSuccess(handshake_stream->Upgrade()); | 154 connect_delegate_->OnSuccess(handshake_stream->Upgrade()); |
155 | |
156 // This is safe even if |this| has been already destructed. | |
Adam Rice
2017/01/13 11:08:44
Grammar nit: "has already been deleted".
yhirano
2017/01/13 11:15:50
Done.
| |
157 url_request->CancelWithError(ERR_WEBSOCKET_HANDSHAKE_SUCCESS); | |
154 } | 158 } |
155 | 159 |
156 std::string FailureMessageFromNetError(int net_error) { | 160 std::string FailureMessageFromNetError(int net_error) { |
157 if (net_error == ERR_TUNNEL_CONNECTION_FAILED) { | 161 if (net_error == ERR_TUNNEL_CONNECTION_FAILED) { |
158 // This error is common and confusing, so special-case it. | 162 // This error is common and confusing, so special-case it. |
159 // TODO(ricea): Include the HostPortPair of the selected proxy server in | 163 // TODO(ricea): Include the HostPortPair of the selected proxy server in |
160 // the error message. This is not currently possible because it isn't set | 164 // the error message. This is not currently possible because it isn't set |
161 // in HttpResponseInfo when a ERR_TUNNEL_CONNECTION_FAILED error happens. | 165 // in HttpResponseInfo when a ERR_TUNNEL_CONNECTION_FAILED error happens. |
162 return "Establishing a tunnel via proxy server failed."; | 166 return "Establishing a tunnel via proxy server failed."; |
163 } else { | 167 } else { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 DCHECK(connect_delegate); | 407 DCHECK(connect_delegate); |
404 if (headers.get()) { | 408 if (headers.get()) { |
405 connect_delegate->OnFinishOpeningHandshake( | 409 connect_delegate->OnFinishOpeningHandshake( |
406 base::MakeUnique<WebSocketHandshakeResponseInfo>( | 410 base::MakeUnique<WebSocketHandshakeResponseInfo>( |
407 url, headers->response_code(), headers->GetStatusText(), headers, | 411 url, headers->response_code(), headers->GetStatusText(), headers, |
408 response_time)); | 412 response_time)); |
409 } | 413 } |
410 } | 414 } |
411 | 415 |
412 } // namespace net | 416 } // namespace net |
OLD | NEW |