Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: net/quic/quic_spdy_stream.cc

Issue 1761263002: Landing recent QUIC changes until 7:19 PM, Feb 26, 2016 UTC-5. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ActivateStream() call to QuicChromiumClientSession to fix server push failure Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_spdy_stream.h ('k') | net/quic/quic_spdy_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // TODO(rch): Add test to ensure fin_sent_ is set whenever a fin is sent. 72 // TODO(rch): Add test to ensure fin_sent_ is set whenever a fin is sent.
73 set_fin_sent(true); 73 set_fin_sent(true);
74 CloseWriteSide(); 74 CloseWriteSide();
75 } 75 }
76 return bytes_written; 76 return bytes_written;
77 } 77 }
78 78
79 size_t QuicSpdyStream::WriteTrailers( 79 size_t QuicSpdyStream::WriteTrailers(
80 SpdyHeaderBlock trailer_block, 80 SpdyHeaderBlock trailer_block,
81 QuicAckListenerInterface* ack_notifier_delegate) { 81 QuicAckListenerInterface* ack_notifier_delegate) {
82 if (!FLAGS_quic_supports_trailers) {
83 return 0;
84 }
85 if (fin_sent()) { 82 if (fin_sent()) {
86 QUIC_BUG << "Trailers cannot be sent after a FIN."; 83 QUIC_BUG << "Trailers cannot be sent after a FIN.";
87 return 0; 84 return 0;
88 } 85 }
89 86
90 // The header block must contain the final offset for this stream, as the 87 // The header block must contain the final offset for this stream, as the
91 // trailers may be processed out of order at the peer. 88 // trailers may be processed out of order at the peer.
92 trailer_block.insert(std::make_pair( 89 trailer_block.insert(std::make_pair(
93 kFinalOffsetHeaderKey, 90 kFinalOffsetHeaderKey,
94 base::IntToString(stream_bytes_written() + queued_data_bytes()))); 91 base::IntToString(stream_bytes_written() + queued_data_bytes())));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 bool QuicSpdyStream::IsDoneReading() const { 124 bool QuicSpdyStream::IsDoneReading() const {
128 bool done_reading_headers = FinishedReadingHeaders(); 125 bool done_reading_headers = FinishedReadingHeaders();
129 bool done_reading_body = sequencer()->IsClosed(); 126 bool done_reading_body = sequencer()->IsClosed();
130 bool done_reading_trailers = FinishedReadingTrailers(); 127 bool done_reading_trailers = FinishedReadingTrailers();
131 return done_reading_headers && done_reading_body && done_reading_trailers; 128 return done_reading_headers && done_reading_body && done_reading_trailers;
132 } 129 }
133 130
134 bool QuicSpdyStream::HasBytesToRead() const { 131 bool QuicSpdyStream::HasBytesToRead() const {
135 bool headers_to_read = !decompressed_headers_.empty(); 132 bool headers_to_read = !decompressed_headers_.empty();
136 bool body_to_read = sequencer()->HasBytesToRead(); 133 bool body_to_read = sequencer()->HasBytesToRead();
137 bool trailers_to_read = 134 bool trailers_to_read = !decompressed_trailers_.empty();
138 (FLAGS_quic_supports_trailers && !decompressed_trailers_.empty());
139 return headers_to_read || body_to_read || trailers_to_read; 135 return headers_to_read || body_to_read || trailers_to_read;
140 } 136 }
141 137
142 void QuicSpdyStream::MarkHeadersConsumed(size_t bytes_consumed) { 138 void QuicSpdyStream::MarkHeadersConsumed(size_t bytes_consumed) {
143 decompressed_headers_.erase(0, bytes_consumed); 139 decompressed_headers_.erase(0, bytes_consumed);
144 if (FinishedReadingHeaders()) { 140 if (FinishedReadingHeaders()) {
145 sequencer()->SetUnblocked(); 141 sequencer()->SetUnblocked();
146 } 142 }
147 } 143 }
148 144
149 void QuicSpdyStream::MarkTrailersConsumed(size_t bytes_consumed) { 145 void QuicSpdyStream::MarkTrailersConsumed(size_t bytes_consumed) {
150 decompressed_trailers_.erase(0, bytes_consumed); 146 decompressed_trailers_.erase(0, bytes_consumed);
151 } 147 }
152 148
153 void QuicSpdyStream::SetPriority(SpdyPriority priority) { 149 void QuicSpdyStream::SetPriority(SpdyPriority priority) {
154 DCHECK_EQ(0u, stream_bytes_written()); 150 DCHECK_EQ(0u, stream_bytes_written());
155 spdy_session_->UpdateStreamPriority(id(), priority); 151 spdy_session_->UpdateStreamPriority(id(), priority);
156 priority_ = priority; 152 priority_ = priority;
157 } 153 }
158 154
159 void QuicSpdyStream::OnStreamHeaders(StringPiece headers_data) { 155 void QuicSpdyStream::OnStreamHeaders(StringPiece headers_data) {
160 if (!FLAGS_quic_supports_trailers || !headers_decompressed_) { 156 if (!headers_decompressed_) {
161 headers_data.AppendToString(&decompressed_headers_); 157 headers_data.AppendToString(&decompressed_headers_);
162 } else { 158 } else {
163 DCHECK(!trailers_decompressed_); 159 DCHECK(!trailers_decompressed_);
164 headers_data.AppendToString(&decompressed_trailers_); 160 headers_data.AppendToString(&decompressed_trailers_);
165 } 161 }
166 } 162 }
167 163
168 void QuicSpdyStream::OnStreamHeadersPriority(SpdyPriority priority) { 164 void QuicSpdyStream::OnStreamHeadersPriority(SpdyPriority priority) {
169 DCHECK_EQ(Perspective::IS_SERVER, session()->connection()->perspective()); 165 DCHECK_EQ(Perspective::IS_SERVER, session()->connection()->perspective());
170 SetPriority(priority); 166 SetPriority(priority);
171 } 167 }
172 168
173 void QuicSpdyStream::OnStreamHeadersComplete(bool fin, size_t frame_len) { 169 void QuicSpdyStream::OnStreamHeadersComplete(bool fin, size_t frame_len) {
174 if (!FLAGS_quic_supports_trailers || !headers_decompressed_) { 170 if (!headers_decompressed_) {
175 OnInitialHeadersComplete(fin, frame_len); 171 OnInitialHeadersComplete(fin, frame_len);
176 } else { 172 } else {
177 OnTrailingHeadersComplete(fin, frame_len); 173 OnTrailingHeadersComplete(fin, frame_len);
178 } 174 }
179 } 175 }
180 176
181 void QuicSpdyStream::OnInitialHeadersComplete(bool fin, size_t /*frame_len*/) { 177 void QuicSpdyStream::OnInitialHeadersComplete(bool fin, size_t /*frame_len*/) {
182 headers_decompressed_ = true; 178 headers_decompressed_ = true;
183 if (fin) { 179 if (fin) {
184 OnStreamFrame(QuicStreamFrame(id(), fin, 0, StringPiece())); 180 OnStreamFrame(QuicStreamFrame(id(), fin, 0, StringPiece()));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 visitor_ = nullptr; 240 visitor_ = nullptr;
245 visitor->OnClose(this); 241 visitor->OnClose(this);
246 } 242 }
247 } 243 }
248 244
249 bool QuicSpdyStream::FinishedReadingHeaders() const { 245 bool QuicSpdyStream::FinishedReadingHeaders() const {
250 return headers_decompressed_ && decompressed_headers_.empty(); 246 return headers_decompressed_ && decompressed_headers_.empty();
251 } 247 }
252 248
253 bool QuicSpdyStream::FinishedReadingTrailers() const { 249 bool QuicSpdyStream::FinishedReadingTrailers() const {
254 if (!FLAGS_quic_supports_trailers) {
255 return true;
256 }
257 // If no further trailing headers are expected, and the decompressed trailers 250 // If no further trailing headers are expected, and the decompressed trailers
258 // (if any) have been consumed, then reading of trailers is finished. 251 // (if any) have been consumed, then reading of trailers is finished.
259 bool no_more_trailers = fin_received() || trailers_decompressed_; 252 bool no_more_trailers = fin_received() || trailers_decompressed_;
260 return no_more_trailers && decompressed_trailers_.empty(); 253 return no_more_trailers && decompressed_trailers_.empty();
261 } 254 }
262 255
263 SpdyPriority QuicSpdyStream::priority() const { 256 SpdyPriority QuicSpdyStream::priority() const {
264 return priority_; 257 return priority_;
265 } 258 }
266 } // namespace net 259 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_spdy_stream.h ('k') | net/quic/quic_spdy_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698