| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_spdy_stream.h" | 5 #include "net/quic/quic_spdy_stream.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "net/quic/quic_bug_tracker.h" | 9 #include "net/quic/quic_bug_tracker.h" |
| 10 #include "net/quic/quic_spdy_session.h" | 10 #include "net/quic/quic_spdy_session.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ | 23 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ |
| 24 " ") | 24 " ") |
| 25 | 25 |
| 26 QuicSpdyStream::QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session) | 26 QuicSpdyStream::QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session) |
| 27 : ReliableQuicStream(id, spdy_session), | 27 : ReliableQuicStream(id, spdy_session), |
| 28 spdy_session_(spdy_session), | 28 spdy_session_(spdy_session), |
| 29 visitor_(nullptr), | 29 visitor_(nullptr), |
| 30 headers_decompressed_(false), | 30 headers_decompressed_(false), |
| 31 priority_(kDefaultPriority), | 31 priority_(kDefaultPriority), |
| 32 trailers_decompressed_(false), | 32 trailers_decompressed_(false), |
| 33 trailers_delivered_(false), | |
| 34 avoid_empty_nonfin_writes_(FLAGS_quic_avoid_empty_nonfin_writes) { | 33 avoid_empty_nonfin_writes_(FLAGS_quic_avoid_empty_nonfin_writes) { |
| 35 DCHECK_NE(kCryptoStreamId, id); | 34 DCHECK_NE(kCryptoStreamId, id); |
| 36 // Don't receive any callbacks from the sequencer until headers | 35 // Don't receive any callbacks from the sequencer until headers |
| 37 // are complete. | 36 // are complete. |
| 38 sequencer()->SetBlockedUntilFlush(); | 37 sequencer()->SetBlockedUntilFlush(); |
| 39 spdy_session_->RegisterStreamPriority(id, priority_); | 38 spdy_session_->RegisterStreamPriority(id, priority_); |
| 40 } | 39 } |
| 41 | 40 |
| 42 QuicSpdyStream::~QuicSpdyStream() { | 41 QuicSpdyStream::~QuicSpdyStream() { |
| 43 if (spdy_session_ != nullptr) { | 42 if (spdy_session_ != nullptr) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 decompressed_headers_.erase(0, bytes_consumed); | 154 decompressed_headers_.erase(0, bytes_consumed); |
| 156 if (FinishedReadingHeaders()) { | 155 if (FinishedReadingHeaders()) { |
| 157 sequencer()->SetUnblocked(); | 156 sequencer()->SetUnblocked(); |
| 158 } | 157 } |
| 159 } | 158 } |
| 160 | 159 |
| 161 void QuicSpdyStream::MarkTrailersConsumed(size_t bytes_consumed) { | 160 void QuicSpdyStream::MarkTrailersConsumed(size_t bytes_consumed) { |
| 162 decompressed_trailers_.erase(0, bytes_consumed); | 161 decompressed_trailers_.erase(0, bytes_consumed); |
| 163 } | 162 } |
| 164 | 163 |
| 165 void QuicSpdyStream::MarkTrailersDelivered() { | |
| 166 trailers_delivered_ = true; | |
| 167 } | |
| 168 | |
| 169 void QuicSpdyStream::ConsumeHeaderList() { | 164 void QuicSpdyStream::ConsumeHeaderList() { |
| 170 header_list_.Clear(); | 165 header_list_.Clear(); |
| 171 if (FinishedReadingHeaders()) { | 166 if (FinishedReadingHeaders()) { |
| 172 sequencer()->SetUnblocked(); | 167 sequencer()->SetUnblocked(); |
| 173 } | 168 } |
| 174 } | 169 } |
| 175 | 170 |
| 176 void QuicSpdyStream::SetPriority(SpdyPriority priority) { | 171 void QuicSpdyStream::SetPriority(SpdyPriority priority) { |
| 177 DCHECK_EQ(0u, stream_bytes_written()); | 172 DCHECK_EQ(0u, stream_bytes_written()); |
| 178 spdy_session_->UpdateStreamPriority(id(), priority); | 173 spdy_session_->UpdateStreamPriority(id(), priority); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // The remaining two characters must be integers. | 370 // The remaining two characters must be integers. |
| 376 if (!isdigit(status[1]) || !isdigit(status[2])) { | 371 if (!isdigit(status[1]) || !isdigit(status[2])) { |
| 377 return false; | 372 return false; |
| 378 } | 373 } |
| 379 return StringToInt(status, status_code); | 374 return StringToInt(status, status_code); |
| 380 } | 375 } |
| 381 | 376 |
| 382 bool QuicSpdyStream::FinishedReadingTrailers() const { | 377 bool QuicSpdyStream::FinishedReadingTrailers() const { |
| 383 // If no further trailing headers are expected, and the decompressed trailers | 378 // If no further trailing headers are expected, and the decompressed trailers |
| 384 // (if any) have been consumed, then reading of trailers is finished. | 379 // (if any) have been consumed, then reading of trailers is finished. |
| 385 if (!fin_received()) { | 380 bool no_more_trailers = fin_received() || trailers_decompressed_; |
| 386 return false; | 381 return no_more_trailers && decompressed_trailers_.empty(); |
| 387 } else if (!trailers_decompressed_) { | |
| 388 return true; | |
| 389 } else { | |
| 390 return trailers_delivered_ && decompressed_trailers_.empty(); | |
| 391 } | |
| 392 } | 382 } |
| 393 | 383 |
| 394 SpdyPriority QuicSpdyStream::priority() const { | 384 SpdyPriority QuicSpdyStream::priority() const { |
| 395 return priority_; | 385 return priority_; |
| 396 } | 386 } |
| 397 | 387 |
| 398 void QuicSpdyStream::ClearSession() { | 388 void QuicSpdyStream::ClearSession() { |
| 399 spdy_session_ = nullptr; | 389 spdy_session_ = nullptr; |
| 400 } | 390 } |
| 401 | 391 |
| 402 } // namespace net | 392 } // namespace net |
| OLD | NEW |