| 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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 response_info_->was_npn_negotiated = true; | 690 response_info_->was_npn_negotiated = true; |
| 691 response_info_->npn_negotiated_protocol = "quic/1+spdy/3"; | 691 response_info_->npn_negotiated_protocol = "quic/1+spdy/3"; |
| 692 response_info_->response_time = base::Time::Now(); | 692 response_info_->response_time = base::Time::Now(); |
| 693 response_info_->request_time = request_time_; | 693 response_info_->request_time = request_time_; |
| 694 response_headers_received_ = true; | 694 response_headers_received_ = true; |
| 695 | 695 |
| 696 return OK; | 696 return OK; |
| 697 } | 697 } |
| 698 | 698 |
| 699 int QuicHttpStream::ReadAvailableData(IOBuffer* buf, int buf_len) { | 699 int QuicHttpStream::ReadAvailableData(IOBuffer* buf, int buf_len) { |
| 700 // TODO(rtenneti): Temporary until crbug.com/585591 is solved. | |
| 701 CHECK(!read_in_progress_); | |
| 702 read_in_progress_ = true; | |
| 703 stream_->CrashIfInvalid(); | |
| 704 stream_->set_read_in_progress(read_in_progress_); | |
| 705 | |
| 706 int rv = stream_->Read(buf, buf_len); | 700 int rv = stream_->Read(buf, buf_len); |
| 707 // TODO(rtenneti): Temporary until crbug.com/585591 is solved. | |
| 708 CHECK(read_in_progress_); | |
| 709 read_in_progress_ = false; | |
| 710 stream_->set_read_in_progress(read_in_progress_); | |
| 711 // CrashIfInvalid() may not be necessary. See if |stream_| became a nullptr | |
| 712 // due to memory corruptions. | |
| 713 stream_->CrashIfInvalid(); | |
| 714 | |
| 715 if (stream_->IsDoneReading()) { | 701 if (stream_->IsDoneReading()) { |
| 716 stream_->SetDelegate(nullptr); | 702 stream_->SetDelegate(nullptr); |
| 717 stream_->OnFinRead(); | 703 stream_->OnFinRead(); |
| 718 ResetStream(); | 704 ResetStream(); |
| 719 } | 705 } |
| 720 return rv; | 706 return rv; |
| 721 } | 707 } |
| 722 | 708 |
| 723 void QuicHttpStream::ResetStream() { | 709 void QuicHttpStream::ResetStream() { |
| 724 // TODO(rtenneti): Temporary until crbug.com/585591 is solved. | |
| 725 if (read_in_progress_) { | |
| 726 // |stream_| is going away when Read is called. Should never happen?? | |
| 727 CHECK(false); | |
| 728 } | |
| 729 if (push_handle_) { | 710 if (push_handle_) { |
| 730 push_handle_->Cancel(); | 711 push_handle_->Cancel(); |
| 731 push_handle_ = nullptr; | 712 push_handle_ = nullptr; |
| 732 } | 713 } |
| 733 if (!stream_) | 714 if (!stream_) |
| 734 return; | 715 return; |
| 735 closed_stream_received_bytes_ = stream_->stream_bytes_read(); | 716 closed_stream_received_bytes_ = stream_->stream_bytes_read(); |
| 736 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); | 717 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
| 737 stream_ = nullptr; | 718 stream_ = nullptr; |
| 738 | 719 |
| 739 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress | 720 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress |
| 740 // read. | 721 // read. |
| 741 if (request_body_stream_) | 722 if (request_body_stream_) |
| 742 request_body_stream_->Reset(); | 723 request_body_stream_->Reset(); |
| 743 } | 724 } |
| 744 | 725 |
| 745 } // namespace net | 726 } // namespace net |
| OLD | NEW |