| 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/quic/chromium/quic_http_stream.h" | 5 #include "net/quic/chromium/quic_http_stream.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 ConnectionInfoFromQuicVersion(quic_session()->GetQuicVersion()); | 426 ConnectionInfoFromQuicVersion(quic_session()->GetQuicVersion()); |
| 427 quic_session()->PopulateNetErrorDetails(details); | 427 quic_session()->PopulateNetErrorDetails(details); |
| 428 if (quic_session()->IsCryptoHandshakeConfirmed()) | 428 if (quic_session()->IsCryptoHandshakeConfirmed()) |
| 429 details->quic_connection_error = quic_connection_error_; | 429 details->quic_connection_error = quic_connection_error_; |
| 430 } | 430 } |
| 431 | 431 |
| 432 void QuicHttpStream::SetPriority(RequestPriority priority) { | 432 void QuicHttpStream::SetPriority(RequestPriority priority) { |
| 433 priority_ = priority; | 433 priority_ = priority; |
| 434 } | 434 } |
| 435 | 435 |
| 436 void QuicHttpStream::OnHeadersAvailable(const SpdyHeaderBlock& headers, | 436 void QuicHttpStream::OnInitialHeadersAvailable(const SpdyHeaderBlock& headers, |
| 437 size_t frame_len) { | 437 size_t frame_len) { |
| 438 DCHECK(!response_headers_received_); |
| 438 headers_bytes_received_ += frame_len; | 439 headers_bytes_received_ += frame_len; |
| 439 | 440 |
| 440 // QuicHttpStream ignores trailers. | |
| 441 if (response_headers_received_) { | |
| 442 if (stream_->IsDoneReading()) { | |
| 443 // Close the read side. If the write side has been closed, this will | |
| 444 // invoke QuicHttpStream::OnClose to reset the stream. | |
| 445 stream_->OnFinRead(); | |
| 446 SetResponseStatus(OK); | |
| 447 } | |
| 448 return; | |
| 449 } | |
| 450 | |
| 451 int rv = ProcessResponseHeaders(headers); | 441 int rv = ProcessResponseHeaders(headers); |
| 452 if (rv != ERR_IO_PENDING && !callback_.is_null()) { | 442 if (rv != ERR_IO_PENDING && !callback_.is_null()) { |
| 453 DoCallback(rv); | 443 DoCallback(rv); |
| 454 } | 444 } |
| 455 } | 445 } |
| 456 | 446 |
| 447 void QuicHttpStream::OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers, |
| 448 size_t frame_len) { |
| 449 DCHECK(response_headers_received_); |
| 450 headers_bytes_received_ += frame_len; |
| 451 |
| 452 // QuicHttpStream ignores trailers. |
| 453 if (stream_->IsDoneReading()) { |
| 454 // Close the read side. If the write side has been closed, this will |
| 455 // invoke QuicHttpStream::OnClose to reset the stream. |
| 456 stream_->OnFinRead(); |
| 457 SetResponseStatus(OK); |
| 458 } |
| 459 } |
| 460 |
| 457 void QuicHttpStream::OnDataAvailable() { | 461 void QuicHttpStream::OnDataAvailable() { |
| 458 if (callback_.is_null()) { | 462 if (callback_.is_null()) { |
| 459 // Data is available, but can't be delivered | 463 // Data is available, but can't be delivered |
| 460 return; | 464 return; |
| 461 } | 465 } |
| 462 | 466 |
| 463 CHECK(user_buffer_.get()); | 467 CHECK(user_buffer_.get()); |
| 464 CHECK_NE(0, user_buffer_len_); | 468 CHECK_NE(0, user_buffer_len_); |
| 465 int rv = ReadAvailableData(user_buffer_.get(), user_buffer_len_); | 469 int rv = ReadAvailableData(user_buffer_.get(), user_buffer_len_); |
| 466 if (rv == ERR_IO_PENDING) { | 470 if (rv == ERR_IO_PENDING) { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 quic_stream_error_ != QUIC_STREAM_CONNECTION_ERROR) { | 832 quic_stream_error_ != QUIC_STREAM_CONNECTION_ERROR) { |
| 829 return ERR_QUIC_PROTOCOL_ERROR; | 833 return ERR_QUIC_PROTOCOL_ERROR; |
| 830 } | 834 } |
| 831 | 835 |
| 832 DCHECK_NE(QUIC_HANDSHAKE_TIMEOUT, quic_connection_error_); | 836 DCHECK_NE(QUIC_HANDSHAKE_TIMEOUT, quic_connection_error_); |
| 833 | 837 |
| 834 return ERR_QUIC_PROTOCOL_ERROR; | 838 return ERR_QUIC_PROTOCOL_ERROR; |
| 835 } | 839 } |
| 836 | 840 |
| 837 } // namespace net | 841 } // namespace net |
| OLD | NEW |