| 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/quic_http_stream.h" | 5 #include "net/quic/quic_http_stream.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 priority_(MINIMUM_PRIORITY), | 39 priority_(MINIMUM_PRIORITY), |
| 40 response_info_(nullptr), | 40 response_info_(nullptr), |
| 41 response_status_(OK), | 41 response_status_(OK), |
| 42 response_headers_received_(false), | 42 response_headers_received_(false), |
| 43 headers_bytes_received_(0), | 43 headers_bytes_received_(0), |
| 44 headers_bytes_sent_(0), | 44 headers_bytes_sent_(0), |
| 45 closed_stream_received_bytes_(0), | 45 closed_stream_received_bytes_(0), |
| 46 closed_stream_sent_bytes_(0), | 46 closed_stream_sent_bytes_(0), |
| 47 user_buffer_len_(0), | 47 user_buffer_len_(0), |
| 48 quic_connection_error_(QUIC_NO_ERROR), | 48 quic_connection_error_(QUIC_NO_ERROR), |
| 49 port_migration_detected_(false), |
| 49 found_promise_(false), | 50 found_promise_(false), |
| 50 push_handle_(nullptr), | 51 push_handle_(nullptr), |
| 51 weak_factory_(this) { | 52 weak_factory_(this) { |
| 52 DCHECK(session_); | 53 DCHECK(session_); |
| 53 session_->AddObserver(this); | 54 session_->AddObserver(this); |
| 54 } | 55 } |
| 55 | 56 |
| 56 QuicHttpStream::~QuicHttpStream() { | 57 QuicHttpStream::~QuicHttpStream() { |
| 57 Close(false); | 58 Close(false); |
| 58 if (session_) | 59 if (session_) |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 void QuicHttpStream::Drain(HttpNetworkSession* session) { | 431 void QuicHttpStream::Drain(HttpNetworkSession* session) { |
| 431 NOTREACHED(); | 432 NOTREACHED(); |
| 432 Close(false); | 433 Close(false); |
| 433 delete this; | 434 delete this; |
| 434 } | 435 } |
| 435 | 436 |
| 436 void QuicHttpStream::PopulateNetErrorDetails(NetErrorDetails* details) { | 437 void QuicHttpStream::PopulateNetErrorDetails(NetErrorDetails* details) { |
| 437 details->connection_info = HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; | 438 details->connection_info = HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3; |
| 438 if (was_handshake_confirmed_) | 439 if (was_handshake_confirmed_) |
| 439 details->quic_connection_error = quic_connection_error_; | 440 details->quic_connection_error = quic_connection_error_; |
| 441 if (session_) { |
| 442 session_->PopulateNetErrorDetails(details); |
| 443 } else { |
| 444 details->quic_port_migration_detected = port_migration_detected_; |
| 445 } |
| 440 } | 446 } |
| 441 | 447 |
| 442 void QuicHttpStream::SetPriority(RequestPriority priority) { | 448 void QuicHttpStream::SetPriority(RequestPriority priority) { |
| 443 priority_ = priority; | 449 priority_ = priority; |
| 444 } | 450 } |
| 445 | 451 |
| 446 void QuicHttpStream::OnHeadersAvailable(const SpdyHeaderBlock& headers, | 452 void QuicHttpStream::OnHeadersAvailable(const SpdyHeaderBlock& headers, |
| 447 size_t frame_len) { | 453 size_t frame_len) { |
| 448 headers_bytes_received_ += frame_len; | 454 headers_bytes_received_ += frame_len; |
| 449 | 455 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 } | 513 } |
| 508 | 514 |
| 509 bool QuicHttpStream::HasSendHeadersComplete() { | 515 bool QuicHttpStream::HasSendHeadersComplete() { |
| 510 return next_state_ > STATE_SEND_HEADERS_COMPLETE; | 516 return next_state_ > STATE_SEND_HEADERS_COMPLETE; |
| 511 } | 517 } |
| 512 | 518 |
| 513 void QuicHttpStream::OnCryptoHandshakeConfirmed() { | 519 void QuicHttpStream::OnCryptoHandshakeConfirmed() { |
| 514 was_handshake_confirmed_ = true; | 520 was_handshake_confirmed_ = true; |
| 515 } | 521 } |
| 516 | 522 |
| 517 void QuicHttpStream::OnSessionClosed(int error) { | 523 void QuicHttpStream::OnSessionClosed(int error, bool port_migration_detected) { |
| 518 Close(false); | 524 Close(false); |
| 519 session_error_ = error; | 525 session_error_ = error; |
| 526 port_migration_detected_ = port_migration_detected; |
| 520 session_.reset(); | 527 session_.reset(); |
| 521 } | 528 } |
| 522 | 529 |
| 523 void QuicHttpStream::OnIOComplete(int rv) { | 530 void QuicHttpStream::OnIOComplete(int rv) { |
| 524 rv = DoLoop(rv); | 531 rv = DoLoop(rv); |
| 525 | 532 |
| 526 if (rv != ERR_IO_PENDING && !callback_.is_null()) { | 533 if (rv != ERR_IO_PENDING && !callback_.is_null()) { |
| 527 DoCallback(rv); | 534 DoCallback(rv); |
| 528 } | 535 } |
| 529 } | 536 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 748 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
| 742 stream_ = nullptr; | 749 stream_ = nullptr; |
| 743 | 750 |
| 744 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress | 751 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress |
| 745 // read. | 752 // read. |
| 746 if (request_body_stream_) | 753 if (request_body_stream_) |
| 747 request_body_stream_->Reset(); | 754 request_body_stream_->Reset(); |
| 748 } | 755 } |
| 749 | 756 |
| 750 } // namespace net | 757 } // namespace net |
| OLD | NEW |