| 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/core/quic_spdy_stream.h" | 5 #include "net/quic/core/quic_spdy_stream.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ | 25 (session()->perspective() == Perspective::IS_SERVER ? "Server: " : "Client:" \ |
| 26 " ") | 26 " ") |
| 27 | 27 |
| 28 QuicSpdyStream::QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session) | 28 QuicSpdyStream::QuicSpdyStream(QuicStreamId id, QuicSpdySession* spdy_session) |
| 29 : ReliableQuicStream(id, spdy_session), | 29 : ReliableQuicStream(id, spdy_session), |
| 30 spdy_session_(spdy_session), | 30 spdy_session_(spdy_session), |
| 31 visitor_(nullptr), | 31 visitor_(nullptr), |
| 32 headers_decompressed_(false), | 32 headers_decompressed_(false), |
| 33 priority_(kDefaultPriority), | 33 priority_(kDefaultPriority), |
| 34 trailers_decompressed_(false), | 34 trailers_decompressed_(false), |
| 35 trailers_delivered_(false) { | 35 trailers_consumed_(false) { |
| 36 DCHECK_NE(kCryptoStreamId, id); | 36 DCHECK_NE(kCryptoStreamId, id); |
| 37 // Don't receive any callbacks from the sequencer until headers | 37 // Don't receive any callbacks from the sequencer until headers |
| 38 // are complete. | 38 // are complete. |
| 39 sequencer()->SetBlockedUntilFlush(); | 39 sequencer()->SetBlockedUntilFlush(); |
| 40 spdy_session_->RegisterStreamPriority(id, priority_); | 40 spdy_session_->RegisterStreamPriority(id, priority_); |
| 41 } | 41 } |
| 42 | 42 |
| 43 QuicSpdyStream::~QuicSpdyStream() { | 43 QuicSpdyStream::~QuicSpdyStream() { |
| 44 if (spdy_session_ != nullptr) { | 44 if (spdy_session_ != nullptr) { |
| 45 spdy_session_->UnregisterStreamPriority(id()); | 45 spdy_session_->UnregisterStreamPriority(id()); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 decompressed_headers_.erase(0, bytes_consumed); | 155 decompressed_headers_.erase(0, bytes_consumed); |
| 156 if (FinishedReadingHeaders()) { | 156 if (FinishedReadingHeaders()) { |
| 157 sequencer()->SetUnblocked(); | 157 sequencer()->SetUnblocked(); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 void QuicSpdyStream::MarkTrailersConsumed(size_t bytes_consumed) { | 161 void QuicSpdyStream::MarkTrailersConsumed(size_t bytes_consumed) { |
| 162 decompressed_trailers_.erase(0, bytes_consumed); | 162 decompressed_trailers_.erase(0, bytes_consumed); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void QuicSpdyStream::MarkTrailersDelivered() { | 165 void QuicSpdyStream::MarkTrailersConsumed() { |
| 166 trailers_delivered_ = true; | 166 trailers_consumed_ = true; |
| 167 } | 167 } |
| 168 | 168 |
| 169 void QuicSpdyStream::ConsumeHeaderList() { | 169 void QuicSpdyStream::ConsumeHeaderList() { |
| 170 header_list_.Clear(); | 170 header_list_.Clear(); |
| 171 if (FinishedReadingHeaders()) { | 171 if (FinishedReadingHeaders()) { |
| 172 sequencer()->SetUnblocked(); | 172 sequencer()->SetUnblocked(); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 void QuicSpdyStream::SetPriority(SpdyPriority priority) { | 176 void QuicSpdyStream::SetPriority(SpdyPriority priority) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 391 } |
| 392 | 392 |
| 393 bool QuicSpdyStream::FinishedReadingTrailers() const { | 393 bool QuicSpdyStream::FinishedReadingTrailers() const { |
| 394 // If no further trailing headers are expected, and the decompressed trailers | 394 // If no further trailing headers are expected, and the decompressed trailers |
| 395 // (if any) have been consumed, then reading of trailers is finished. | 395 // (if any) have been consumed, then reading of trailers is finished. |
| 396 if (!fin_received()) { | 396 if (!fin_received()) { |
| 397 return false; | 397 return false; |
| 398 } else if (!trailers_decompressed_) { | 398 } else if (!trailers_decompressed_) { |
| 399 return true; | 399 return true; |
| 400 } else { | 400 } else { |
| 401 return trailers_delivered_ && decompressed_trailers_.empty(); | 401 return trailers_consumed_ && decompressed_trailers_.empty(); |
| 402 } | 402 } |
| 403 } | 403 } |
| 404 | 404 |
| 405 SpdyPriority QuicSpdyStream::priority() const { | 405 SpdyPriority QuicSpdyStream::priority() const { |
| 406 return priority_; | 406 return priority_; |
| 407 } | 407 } |
| 408 | 408 |
| 409 void QuicSpdyStream::ClearSession() { | 409 void QuicSpdyStream::ClearSession() { |
| 410 spdy_session_ = nullptr; | 410 spdy_session_ = nullptr; |
| 411 } | 411 } |
| 412 | 412 |
| 413 QuicConsumedData QuicSpdyStream::WritevDataInner( | 413 QuicConsumedData QuicSpdyStream::WritevDataInner( |
| 414 QuicIOVector iov, | 414 QuicIOVector iov, |
| 415 QuicStreamOffset offset, | 415 QuicStreamOffset offset, |
| 416 bool fin, | 416 bool fin, |
| 417 QuicAckListenerInterface* ack_notifier_delegate) { | 417 QuicAckListenerInterface* ack_notifier_delegate) { |
| 418 if (spdy_session_->headers_stream() != nullptr && | 418 if (spdy_session_->headers_stream() != nullptr && |
| 419 spdy_session_->force_hol_blocking()) { | 419 spdy_session_->force_hol_blocking()) { |
| 420 return spdy_session_->headers_stream()->WritevStreamData( | 420 return spdy_session_->headers_stream()->WritevStreamData( |
| 421 id(), iov, offset, fin, ack_notifier_delegate); | 421 id(), iov, offset, fin, ack_notifier_delegate); |
| 422 } | 422 } |
| 423 return ReliableQuicStream::WritevDataInner(iov, offset, fin, | 423 return ReliableQuicStream::WritevDataInner(iov, offset, fin, |
| 424 ack_notifier_delegate); | 424 ack_notifier_delegate); |
| 425 } | 425 } |
| 426 | 426 |
| 427 } // namespace net | 427 } // namespace net |
| OLD | NEW |