| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/http/bidirectional_stream.h" | 5 #include "net/http/bidirectional_stream.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 base::Bind(&BidirectionalStream::Delegate::OnFailed, | 62 base::Bind(&BidirectionalStream::Delegate::OnFailed, |
| 63 base::Unretained(delegate_), ERR_DISALLOWED_URL_SCHEME)); | 63 base::Unretained(delegate_), ERR_DISALLOWED_URL_SCHEME)); |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 HttpRequestInfo http_request_info; | 67 HttpRequestInfo http_request_info; |
| 68 http_request_info.url = request_info_->url; | 68 http_request_info.url = request_info_->url; |
| 69 http_request_info.method = request_info_->method; | 69 http_request_info.method = request_info_->method; |
| 70 http_request_info.extra_headers = request_info_->extra_headers; | 70 http_request_info.extra_headers = request_info_->extra_headers; |
| 71 stream_request_.reset( | 71 stream_request_.reset( |
| 72 session->http_stream_factory()->RequestBidirectionalStreamJob( | 72 session->http_stream_factory()->RequestBidirectionalStreamImpl( |
| 73 http_request_info, request_info_->priority, server_ssl_config, | 73 http_request_info, request_info_->priority, server_ssl_config, |
| 74 server_ssl_config, this, net_log_)); | 74 server_ssl_config, this, net_log_)); |
| 75 // Check that this call cannot fail to set a non-NULL |stream_request_|. | 75 // Check that this call cannot fail to set a non-NULL |stream_request_|. |
| 76 DCHECK(stream_request_); | 76 DCHECK(stream_request_); |
| 77 // Check that HttpStreamFactory does not invoke OnBidirectionalStreamJobReady | 77 // Check that HttpStreamFactory does not invoke OnBidirectionalStreamImplReady |
| 78 // synchronously. | 78 // synchronously. |
| 79 DCHECK(!stream_job_); | 79 DCHECK(!stream_impl_); |
| 80 } | 80 } |
| 81 | 81 |
| 82 BidirectionalStream::~BidirectionalStream() { | 82 BidirectionalStream::~BidirectionalStream() { |
| 83 Cancel(); | 83 Cancel(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 int BidirectionalStream::ReadData(IOBuffer* buf, int buf_len) { | 86 int BidirectionalStream::ReadData(IOBuffer* buf, int buf_len) { |
| 87 DCHECK(stream_job_); | 87 DCHECK(stream_impl_); |
| 88 | 88 |
| 89 return stream_job_->ReadData(buf, buf_len); | 89 return stream_impl_->ReadData(buf, buf_len); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void BidirectionalStream::SendData(IOBuffer* data, | 92 void BidirectionalStream::SendData(IOBuffer* data, |
| 93 int length, | 93 int length, |
| 94 bool end_stream) { | 94 bool end_stream) { |
| 95 DCHECK(stream_job_); | 95 DCHECK(stream_impl_); |
| 96 | 96 |
| 97 stream_job_->SendData(data, length, end_stream); | 97 stream_impl_->SendData(data, length, end_stream); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void BidirectionalStream::Cancel() { | 100 void BidirectionalStream::Cancel() { |
| 101 stream_request_.reset(); | 101 stream_request_.reset(); |
| 102 if (stream_job_) { | 102 if (stream_impl_) { |
| 103 stream_job_->Cancel(); | 103 stream_impl_->Cancel(); |
| 104 stream_job_.reset(); | 104 stream_impl_.reset(); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 NextProto BidirectionalStream::GetProtocol() const { | 108 NextProto BidirectionalStream::GetProtocol() const { |
| 109 if (!stream_job_) | 109 if (!stream_impl_) |
| 110 return kProtoUnknown; | 110 return kProtoUnknown; |
| 111 | 111 |
| 112 return stream_job_->GetProtocol(); | 112 return stream_impl_->GetProtocol(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 int64_t BidirectionalStream::GetTotalReceivedBytes() const { | 115 int64_t BidirectionalStream::GetTotalReceivedBytes() const { |
| 116 if (!stream_job_) | 116 if (!stream_impl_) |
| 117 return 0; | 117 return 0; |
| 118 | 118 |
| 119 return stream_job_->GetTotalReceivedBytes(); | 119 return stream_impl_->GetTotalReceivedBytes(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 int64_t BidirectionalStream::GetTotalSentBytes() const { | 122 int64_t BidirectionalStream::GetTotalSentBytes() const { |
| 123 if (!stream_job_) | 123 if (!stream_impl_) |
| 124 return 0; | 124 return 0; |
| 125 | 125 |
| 126 return stream_job_->GetTotalSentBytes(); | 126 return stream_impl_->GetTotalSentBytes(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void BidirectionalStream::OnHeadersSent() { | 129 void BidirectionalStream::OnHeadersSent() { |
| 130 delegate_->OnHeadersSent(); | 130 delegate_->OnHeadersSent(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void BidirectionalStream::OnHeadersReceived( | 133 void BidirectionalStream::OnHeadersReceived( |
| 134 const SpdyHeaderBlock& response_headers) { | 134 const SpdyHeaderBlock& response_headers) { |
| 135 HttpResponseInfo response_info; | 135 HttpResponseInfo response_info; |
| 136 if (!SpdyHeadersToHttpResponse(response_headers, HTTP2, &response_info)) { | 136 if (!SpdyHeadersToHttpResponse(response_headers, HTTP2, &response_info)) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 160 void BidirectionalStream::OnFailed(int status) { | 160 void BidirectionalStream::OnFailed(int status) { |
| 161 delegate_->OnFailed(status); | 161 delegate_->OnFailed(status); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void BidirectionalStream::OnStreamReady(const SSLConfig& used_ssl_config, | 164 void BidirectionalStream::OnStreamReady(const SSLConfig& used_ssl_config, |
| 165 const ProxyInfo& used_proxy_info, | 165 const ProxyInfo& used_proxy_info, |
| 166 HttpStream* stream) { | 166 HttpStream* stream) { |
| 167 NOTREACHED(); | 167 NOTREACHED(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void BidirectionalStream::OnBidirectionalStreamJobReady( | 170 void BidirectionalStream::OnBidirectionalStreamImplReady( |
| 171 const SSLConfig& used_ssl_config, | 171 const SSLConfig& used_ssl_config, |
| 172 const ProxyInfo& used_proxy_info, | 172 const ProxyInfo& used_proxy_info, |
| 173 BidirectionalStreamJob* stream) { | 173 BidirectionalStreamImpl* stream) { |
| 174 DCHECK(!stream_job_); | 174 DCHECK(!stream_impl_); |
| 175 | 175 |
| 176 stream_request_.reset(); | 176 stream_request_.reset(); |
| 177 stream_job_.reset(stream); | 177 stream_impl_.reset(stream); |
| 178 stream_job_->Start(request_info_.get(), net_log_, this, std::move(timer_)); | 178 stream_impl_->Start(request_info_.get(), net_log_, this, std::move(timer_)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void BidirectionalStream::OnWebSocketHandshakeStreamReady( | 181 void BidirectionalStream::OnWebSocketHandshakeStreamReady( |
| 182 const SSLConfig& used_ssl_config, | 182 const SSLConfig& used_ssl_config, |
| 183 const ProxyInfo& used_proxy_info, | 183 const ProxyInfo& used_proxy_info, |
| 184 WebSocketHandshakeStreamBase* stream) { | 184 WebSocketHandshakeStreamBase* stream) { |
| 185 NOTREACHED(); | 185 NOTREACHED(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void BidirectionalStream::OnStreamFailed(int result, | 188 void BidirectionalStream::OnStreamFailed(int result, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 const ProxyInfo& used_proxy_info, | 228 const ProxyInfo& used_proxy_info, |
| 229 HttpStream* stream) { | 229 HttpStream* stream) { |
| 230 DCHECK(stream_request_); | 230 DCHECK(stream_request_); |
| 231 | 231 |
| 232 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); | 232 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void BidirectionalStream::OnQuicBroken() {} | 235 void BidirectionalStream::OnQuicBroken() {} |
| 236 | 236 |
| 237 } // namespace net | 237 } // namespace net |
| OLD | NEW |