| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/spdy_http_stream.h" | 5 #include "net/spdy/spdy_http_stream.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Still waiting for the response, return IO_PENDING. | 115 // Still waiting for the response, return IO_PENDING. |
| 116 CHECK(response_callback_.is_null()); | 116 CHECK(response_callback_.is_null()); |
| 117 response_callback_ = callback; | 117 response_callback_ = callback; |
| 118 return ERR_IO_PENDING; | 118 return ERR_IO_PENDING; |
| 119 } | 119 } |
| 120 | 120 |
| 121 int SpdyHttpStream::ReadResponseBody( | 121 int SpdyHttpStream::ReadResponseBody( |
| 122 IOBuffer* buf, int buf_len, const CompletionCallback& callback) { | 122 IOBuffer* buf, int buf_len, const CompletionCallback& callback) { |
| 123 // Invalidate HttpRequestInfo pointer. This is to allow the stream to be |
| 124 // shared across multiple transactions which might require this |
| 125 // stream to outlive the request_'s owner. |
| 126 // Only allowed when Reading of response body starts. It is safe to reset it |
| 127 // at this point since request_->upload_data_stream is also not needed |
| 128 // anymore. |
| 129 request_info_ = nullptr; |
| 130 |
| 123 if (stream_.get()) | 131 if (stream_.get()) |
| 124 CHECK(!stream_->IsIdle()); | 132 CHECK(!stream_->IsIdle()); |
| 125 | 133 |
| 126 CHECK(buf); | 134 CHECK(buf); |
| 127 CHECK(buf_len); | 135 CHECK(buf_len); |
| 128 CHECK(!callback.is_null()); | 136 CHECK(!callback.is_null()); |
| 129 | 137 |
| 130 // If we have data buffered, complete the IO immediately. | 138 // If we have data buffered, complete the IO immediately. |
| 131 if (!response_body_queue_.IsEmpty()) { | 139 if (!response_body_queue_.IsEmpty()) { |
| 132 return response_body_queue_.Dequeue(buf->data(), buf_len); | 140 return response_body_queue_.Dequeue(buf->data(), buf_len); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 void SpdyHttpStream::OnDataSent() { | 368 void SpdyHttpStream::OnDataSent() { |
| 361 request_body_buf_size_ = 0; | 369 request_body_buf_size_ = 0; |
| 362 ReadAndSendRequestBodyData(); | 370 ReadAndSendRequestBodyData(); |
| 363 } | 371 } |
| 364 | 372 |
| 365 // TODO(xunjieli): Maybe do something with the trailers. crbug.com/422958. | 373 // TODO(xunjieli): Maybe do something with the trailers. crbug.com/422958. |
| 366 void SpdyHttpStream::OnTrailers(const SpdyHeaderBlock& trailers) {} | 374 void SpdyHttpStream::OnTrailers(const SpdyHeaderBlock& trailers) {} |
| 367 | 375 |
| 368 void SpdyHttpStream::OnClose(int status) { | 376 void SpdyHttpStream::OnClose(int status) { |
| 369 // Cancel any pending reads from the upload data stream. | 377 // Cancel any pending reads from the upload data stream. |
| 370 if (request_info_->upload_data_stream) | 378 if (request_info_ && request_info_->upload_data_stream) |
| 371 request_info_->upload_data_stream->Reset(); | 379 request_info_->upload_data_stream->Reset(); |
| 372 | 380 |
| 373 if (stream_.get()) { | 381 if (stream_.get()) { |
| 374 stream_closed_ = true; | 382 stream_closed_ = true; |
| 375 closed_stream_status_ = status; | 383 closed_stream_status_ = status; |
| 376 closed_stream_id_ = stream_->stream_id(); | 384 closed_stream_id_ = stream_->stream_id(); |
| 377 closed_stream_has_load_timing_info_ = | 385 closed_stream_has_load_timing_info_ = |
| 378 stream_->GetLoadTimingInfo(&closed_stream_load_timing_info_); | 386 stream_->GetLoadTimingInfo(&closed_stream_load_timing_info_); |
| 379 closed_stream_received_bytes_ = stream_->raw_received_bytes(); | 387 closed_stream_received_bytes_ = stream_->raw_received_bytes(); |
| 380 closed_stream_sent_bytes_ = stream_->raw_sent_bytes(); | 388 closed_stream_sent_bytes_ = stream_->raw_sent_bytes(); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 details->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP2; | 615 details->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP2; |
| 608 return; | 616 return; |
| 609 } | 617 } |
| 610 | 618 |
| 611 void SpdyHttpStream::SetPriority(RequestPriority priority) { | 619 void SpdyHttpStream::SetPriority(RequestPriority priority) { |
| 612 // TODO(akalin): Plumb this through to |stream_request_| and | 620 // TODO(akalin): Plumb this through to |stream_request_| and |
| 613 // |stream_|. | 621 // |stream_|. |
| 614 } | 622 } |
| 615 | 623 |
| 616 } // namespace net | 624 } // namespace net |
| OLD | NEW |