| 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/spdy/bidirectional_stream_spdy_impl.h" | 5 #include "net/spdy/bidirectional_stream_spdy_impl.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/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 180 |
| 181 if (!stream_) | 181 if (!stream_) |
| 182 return 0; | 182 return 0; |
| 183 | 183 |
| 184 return stream_->raw_sent_bytes(); | 184 return stream_->raw_sent_bytes(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void BidirectionalStreamSpdyImpl::OnRequestHeadersSent() { | 187 void BidirectionalStreamSpdyImpl::OnRequestHeadersSent() { |
| 188 DCHECK(stream_); | 188 DCHECK(stream_); |
| 189 | 189 |
| 190 negotiated_protocol_ = stream_->GetProtocol(); | 190 negotiated_protocol_ = kProtoHTTP2; |
| 191 if (delegate_) | 191 if (delegate_) |
| 192 delegate_->OnStreamReady(/*request_headers_sent=*/true); | 192 delegate_->OnStreamReady(/*request_headers_sent=*/true); |
| 193 } | 193 } |
| 194 | 194 |
| 195 SpdyResponseHeadersStatus BidirectionalStreamSpdyImpl::OnResponseHeadersUpdated( | 195 SpdyResponseHeadersStatus BidirectionalStreamSpdyImpl::OnResponseHeadersUpdated( |
| 196 const SpdyHeaderBlock& response_headers) { | 196 const SpdyHeaderBlock& response_headers) { |
| 197 DCHECK(stream_); | 197 DCHECK(stream_); |
| 198 | 198 |
| 199 if (delegate_) | 199 if (delegate_) |
| 200 delegate_->OnHeadersReceived(response_headers); | 200 delegate_->OnHeadersReceived(response_headers); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 260 } |
| 261 | 261 |
| 262 int BidirectionalStreamSpdyImpl::SendRequestHeadersHelper() { | 262 int BidirectionalStreamSpdyImpl::SendRequestHeadersHelper() { |
| 263 std::unique_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | 263 std::unique_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); |
| 264 HttpRequestInfo http_request_info; | 264 HttpRequestInfo http_request_info; |
| 265 http_request_info.url = request_info_->url; | 265 http_request_info.url = request_info_->url; |
| 266 http_request_info.method = request_info_->method; | 266 http_request_info.method = request_info_->method; |
| 267 http_request_info.extra_headers = request_info_->extra_headers; | 267 http_request_info.extra_headers = request_info_->extra_headers; |
| 268 | 268 |
| 269 CreateSpdyHeadersFromHttpRequest( | 269 CreateSpdyHeadersFromHttpRequest( |
| 270 http_request_info, http_request_info.extra_headers, | 270 http_request_info, http_request_info.extra_headers, true, headers.get()); |
| 271 stream_->GetProtocolVersion(), true, headers.get()); | |
| 272 return stream_->SendRequestHeaders(std::move(headers), | 271 return stream_->SendRequestHeaders(std::move(headers), |
| 273 request_info_->end_stream_on_headers | 272 request_info_->end_stream_on_headers |
| 274 ? NO_MORE_DATA_TO_SEND | 273 ? NO_MORE_DATA_TO_SEND |
| 275 : MORE_DATA_TO_SEND); | 274 : MORE_DATA_TO_SEND); |
| 276 } | 275 } |
| 277 | 276 |
| 278 void BidirectionalStreamSpdyImpl::OnStreamInitialized(int rv) { | 277 void BidirectionalStreamSpdyImpl::OnStreamInitialized(int rv) { |
| 279 DCHECK_NE(ERR_IO_PENDING, rv); | 278 DCHECK_NE(ERR_IO_PENDING, rv); |
| 280 if (rv == OK) { | 279 if (rv == OK) { |
| 281 stream_ = stream_request_.ReleaseStream(); | 280 stream_ = stream_request_.ReleaseStream(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 355 |
| 357 bool BidirectionalStreamSpdyImpl::ShouldWaitForMoreBufferedData() const { | 356 bool BidirectionalStreamSpdyImpl::ShouldWaitForMoreBufferedData() const { |
| 358 if (stream_closed_) | 357 if (stream_closed_) |
| 359 return false; | 358 return false; |
| 360 DCHECK_GT(read_buffer_len_, 0); | 359 DCHECK_GT(read_buffer_len_, 0); |
| 361 return read_data_queue_.GetTotalSize() < | 360 return read_data_queue_.GetTotalSize() < |
| 362 static_cast<size_t>(read_buffer_len_); | 361 static_cast<size_t>(read_buffer_len_); |
| 363 } | 362 } |
| 364 | 363 |
| 365 } // namespace net | 364 } // namespace net |
| OLD | NEW |