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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 base::Bind(&BidirectionalStream::Delegate::OnFailed, | 59 base::Bind(&BidirectionalStream::Delegate::OnFailed, |
60 base::Unretained(delegate_), ERR_DISALLOWED_URL_SCHEME)); | 60 base::Unretained(delegate_), ERR_DISALLOWED_URL_SCHEME)); |
61 return; | 61 return; |
62 } | 62 } |
63 | 63 |
64 HttpRequestInfo http_request_info; | 64 HttpRequestInfo http_request_info; |
65 http_request_info.url = request_info_->url; | 65 http_request_info.url = request_info_->url; |
66 http_request_info.method = request_info_->method; | 66 http_request_info.method = request_info_->method; |
67 http_request_info.extra_headers = request_info_->extra_headers; | 67 http_request_info.extra_headers = request_info_->extra_headers; |
68 stream_request_.reset( | 68 stream_request_.reset( |
69 session->http_stream_factory()->RequestBidirectionalStreamJob( | 69 session->http_stream_factory()->RequestBidirectionalStreamImpl( |
70 http_request_info, request_info_->priority, server_ssl_config, | 70 http_request_info, request_info_->priority, server_ssl_config, |
71 server_ssl_config, this, net_log_)); | 71 server_ssl_config, this, net_log_)); |
72 // Check that this call cannot fail to set a non-NULL |stream_request_|. | 72 // Check that this call cannot fail to set a non-NULL |stream_request_|. |
73 DCHECK(stream_request_); | 73 DCHECK(stream_request_); |
74 // Check that HttpStreamFactory does not invoke OnBidirectionalStreamJobReady | 74 // Check that HttpStreamFactory does not invoke OnBidirectionalStreamImplReady |
75 // synchronously. | 75 // synchronously. |
76 DCHECK(!stream_job_); | 76 DCHECK(!stream_impl_); |
77 } | 77 } |
78 | 78 |
79 BidirectionalStream::~BidirectionalStream() { | 79 BidirectionalStream::~BidirectionalStream() { |
80 Cancel(); | 80 Cancel(); |
81 } | 81 } |
82 | 82 |
83 int BidirectionalStream::ReadData(IOBuffer* buf, int buf_len) { | 83 int BidirectionalStream::ReadData(IOBuffer* buf, int buf_len) { |
84 DCHECK(stream_job_); | 84 DCHECK(stream_impl_); |
85 | 85 |
86 return stream_job_->ReadData(buf, buf_len); | 86 return stream_impl_->ReadData(buf, buf_len); |
87 } | 87 } |
88 | 88 |
89 void BidirectionalStream::SendData(IOBuffer* data, | 89 void BidirectionalStream::SendData(IOBuffer* data, |
90 int length, | 90 int length, |
91 bool end_stream) { | 91 bool end_stream) { |
92 DCHECK(stream_job_); | 92 DCHECK(stream_impl_); |
93 | 93 |
94 stream_job_->SendData(data, length, end_stream); | 94 stream_impl_->SendData(data, length, end_stream); |
95 } | 95 } |
96 | 96 |
97 void BidirectionalStream::Cancel() { | 97 void BidirectionalStream::Cancel() { |
98 stream_request_.reset(); | 98 stream_request_.reset(); |
99 if (stream_job_) { | 99 if (stream_impl_) { |
100 stream_job_->Cancel(); | 100 stream_impl_->Cancel(); |
101 stream_job_.reset(); | 101 stream_impl_.reset(); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 NextProto BidirectionalStream::GetProtocol() const { | 105 NextProto BidirectionalStream::GetProtocol() const { |
106 if (!stream_job_) | 106 if (!stream_impl_) |
107 return kProtoUnknown; | 107 return kProtoUnknown; |
108 | 108 |
109 return stream_job_->GetProtocol(); | 109 return stream_impl_->GetProtocol(); |
110 } | 110 } |
111 | 111 |
112 int64_t BidirectionalStream::GetTotalReceivedBytes() const { | 112 int64_t BidirectionalStream::GetTotalReceivedBytes() const { |
113 if (!stream_job_) | 113 if (!stream_impl_) |
114 return 0; | 114 return 0; |
115 | 115 |
116 return stream_job_->GetTotalReceivedBytes(); | 116 return stream_impl_->GetTotalReceivedBytes(); |
117 } | 117 } |
118 | 118 |
119 int64_t BidirectionalStream::GetTotalSentBytes() const { | 119 int64_t BidirectionalStream::GetTotalSentBytes() const { |
120 if (!stream_job_) | 120 if (!stream_impl_) |
121 return 0; | 121 return 0; |
122 | 122 |
123 return stream_job_->GetTotalSentBytes(); | 123 return stream_impl_->GetTotalSentBytes(); |
124 } | 124 } |
125 | 125 |
126 void BidirectionalStream::OnHeadersSent() { | 126 void BidirectionalStream::OnHeadersSent() { |
127 delegate_->OnHeadersSent(); | 127 delegate_->OnHeadersSent(); |
128 } | 128 } |
129 | 129 |
130 void BidirectionalStream::OnHeadersReceived( | 130 void BidirectionalStream::OnHeadersReceived( |
131 const SpdyHeaderBlock& response_headers) { | 131 const SpdyHeaderBlock& response_headers) { |
132 delegate_->OnHeadersReceived(response_headers); | 132 delegate_->OnHeadersReceived(response_headers); |
133 } | 133 } |
(...skipping 13 matching lines...) Expand all Loading... |
147 void BidirectionalStream::OnFailed(int status) { | 147 void BidirectionalStream::OnFailed(int status) { |
148 delegate_->OnFailed(status); | 148 delegate_->OnFailed(status); |
149 } | 149 } |
150 | 150 |
151 void BidirectionalStream::OnStreamReady(const SSLConfig& used_ssl_config, | 151 void BidirectionalStream::OnStreamReady(const SSLConfig& used_ssl_config, |
152 const ProxyInfo& used_proxy_info, | 152 const ProxyInfo& used_proxy_info, |
153 HttpStream* stream) { | 153 HttpStream* stream) { |
154 NOTREACHED(); | 154 NOTREACHED(); |
155 } | 155 } |
156 | 156 |
157 void BidirectionalStream::OnBidirectionalStreamJobReady( | 157 void BidirectionalStream::OnBidirectionalStreamImplReady( |
158 const SSLConfig& used_ssl_config, | 158 const SSLConfig& used_ssl_config, |
159 const ProxyInfo& used_proxy_info, | 159 const ProxyInfo& used_proxy_info, |
160 BidirectionalStreamJob* stream) { | 160 BidirectionalStreamImpl* stream) { |
161 DCHECK(!stream_job_); | 161 DCHECK(!stream_impl_); |
162 | 162 |
163 stream_request_.reset(); | 163 stream_request_.reset(); |
164 stream_job_.reset(stream); | 164 stream_impl_.reset(stream); |
165 stream_job_->Start(request_info_.get(), net_log_, this, std::move(timer_)); | 165 stream_impl_->Start(request_info_.get(), net_log_, this, std::move(timer_)); |
166 } | 166 } |
167 | 167 |
168 void BidirectionalStream::OnWebSocketHandshakeStreamReady( | 168 void BidirectionalStream::OnWebSocketHandshakeStreamReady( |
169 const SSLConfig& used_ssl_config, | 169 const SSLConfig& used_ssl_config, |
170 const ProxyInfo& used_proxy_info, | 170 const ProxyInfo& used_proxy_info, |
171 WebSocketHandshakeStreamBase* stream) { | 171 WebSocketHandshakeStreamBase* stream) { |
172 NOTREACHED(); | 172 NOTREACHED(); |
173 } | 173 } |
174 | 174 |
175 void BidirectionalStream::OnStreamFailed(int result, | 175 void BidirectionalStream::OnStreamFailed(int result, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 const ProxyInfo& used_proxy_info, | 215 const ProxyInfo& used_proxy_info, |
216 HttpStream* stream) { | 216 HttpStream* stream) { |
217 DCHECK(stream_request_); | 217 DCHECK(stream_request_); |
218 | 218 |
219 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); | 219 delegate_->OnFailed(ERR_HTTPS_PROXY_TUNNEL_RESPONSE); |
220 } | 220 } |
221 | 221 |
222 void BidirectionalStream::OnQuicBroken() {} | 222 void BidirectionalStream::OnQuicBroken() {} |
223 | 223 |
224 } // namespace net | 224 } // namespace net |
OLD | NEW |