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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 size_t QuicSpdyStream::WriteTrailers( | 88 size_t QuicSpdyStream::WriteTrailers( |
89 SpdyHeaderBlock trailer_block, | 89 SpdyHeaderBlock trailer_block, |
90 QuicAckListenerInterface* ack_notifier_delegate) { | 90 QuicAckListenerInterface* ack_notifier_delegate) { |
91 if (fin_sent()) { | 91 if (fin_sent()) { |
92 QUIC_BUG << "Trailers cannot be sent after a FIN."; | 92 QUIC_BUG << "Trailers cannot be sent after a FIN."; |
93 return 0; | 93 return 0; |
94 } | 94 } |
95 | 95 |
96 // The header block must contain the final offset for this stream, as the | 96 // The header block must contain the final offset for this stream, as the |
97 // trailers may be processed out of order at the peer. | 97 // trailers may be processed out of order at the peer. |
| 98 DVLOG(1) << "Inserting trailer: (" << kFinalOffsetHeaderKey << ", " |
| 99 << stream_bytes_written() + queued_data_bytes() << ")"; |
98 trailer_block.insert(std::make_pair( | 100 trailer_block.insert(std::make_pair( |
99 kFinalOffsetHeaderKey, | 101 kFinalOffsetHeaderKey, |
100 base::IntToString(stream_bytes_written() + queued_data_bytes()))); | 102 base::IntToString(stream_bytes_written() + queued_data_bytes()))); |
101 | 103 |
102 // Write the trailing headers with a FIN, and close stream for writing: | 104 // Write the trailing headers with a FIN, and close stream for writing: |
103 // trailers are the last thing to be sent on a stream. | 105 // trailers are the last thing to be sent on a stream. |
104 const bool kFin = true; | 106 const bool kFin = true; |
105 size_t bytes_written = spdy_session_->WriteHeaders( | 107 size_t bytes_written = spdy_session_->WriteHeaders( |
106 id(), trailer_block, kFin, priority_, ack_notifier_delegate); | 108 id(), trailer_block, kFin, priority_, ack_notifier_delegate); |
107 set_fin_sent(kFin); | 109 set_fin_sent(kFin); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 decompressed_headers_.erase(0, bytes_consumed); | 150 decompressed_headers_.erase(0, bytes_consumed); |
149 if (FinishedReadingHeaders()) { | 151 if (FinishedReadingHeaders()) { |
150 sequencer()->SetUnblocked(); | 152 sequencer()->SetUnblocked(); |
151 } | 153 } |
152 } | 154 } |
153 | 155 |
154 void QuicSpdyStream::MarkTrailersConsumed(size_t bytes_consumed) { | 156 void QuicSpdyStream::MarkTrailersConsumed(size_t bytes_consumed) { |
155 decompressed_trailers_.erase(0, bytes_consumed); | 157 decompressed_trailers_.erase(0, bytes_consumed); |
156 } | 158 } |
157 | 159 |
| 160 void QuicSpdyStream::ConsumeHeaderList() { |
| 161 header_list_.Clear(); |
| 162 if (FinishedReadingHeaders()) { |
| 163 sequencer()->SetUnblocked(); |
| 164 } |
| 165 } |
| 166 |
158 void QuicSpdyStream::SetPriority(SpdyPriority priority) { | 167 void QuicSpdyStream::SetPriority(SpdyPriority priority) { |
159 DCHECK_EQ(0u, stream_bytes_written()); | 168 DCHECK_EQ(0u, stream_bytes_written()); |
160 spdy_session_->UpdateStreamPriority(id(), priority); | 169 spdy_session_->UpdateStreamPriority(id(), priority); |
161 priority_ = priority; | 170 priority_ = priority; |
162 } | 171 } |
163 | 172 |
164 void QuicSpdyStream::OnStreamHeaders(StringPiece headers_data) { | 173 void QuicSpdyStream::OnStreamHeaders(StringPiece headers_data) { |
165 if (!headers_decompressed_) { | 174 if (!headers_decompressed_) { |
166 headers_data.AppendToString(&decompressed_headers_); | 175 headers_data.AppendToString(&decompressed_headers_); |
167 } else { | 176 } else { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // If no further trailing headers are expected, and the decompressed trailers | 374 // If no further trailing headers are expected, and the decompressed trailers |
366 // (if any) have been consumed, then reading of trailers is finished. | 375 // (if any) have been consumed, then reading of trailers is finished. |
367 bool no_more_trailers = fin_received() || trailers_decompressed_; | 376 bool no_more_trailers = fin_received() || trailers_decompressed_; |
368 return no_more_trailers && decompressed_trailers_.empty(); | 377 return no_more_trailers && decompressed_trailers_.empty(); |
369 } | 378 } |
370 | 379 |
371 SpdyPriority QuicSpdyStream::priority() const { | 380 SpdyPriority QuicSpdyStream::priority() const { |
372 return priority_; | 381 return priority_; |
373 } | 382 } |
374 } // namespace net | 383 } // namespace net |
OLD | NEW |