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

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

Issue 2100213002: Make QuicSpdyStream::ParseHeaderStatusCode() inparam const. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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"
11 #include "net/quic/quic_utils.h" 11 #include "net/quic/quic_utils.h"
12 #include "net/quic/quic_write_blocked_list.h" 12 #include "net/quic/quic_write_blocked_list.h"
13 #include "net/quic/spdy_utils.h" 13 #include "net/quic/spdy_utils.h"
14 14
15 using base::IntToString;
15 using base::StringPiece; 16 using base::StringPiece;
16 using net::SpdyPriority;
17 using std::min; 17 using std::min;
18 using std::string; 18 using std::string;
19 19
20 namespace net { 20 namespace net {
21 21
22 #define ENDPOINT \ 22 #define ENDPOINT \
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)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (fin_sent()) { 94 if (fin_sent()) {
95 QUIC_BUG << "Trailers cannot be sent after a FIN."; 95 QUIC_BUG << "Trailers cannot be sent after a FIN.";
96 return 0; 96 return 0;
97 } 97 }
98 98
99 // The header block must contain the final offset for this stream, as the 99 // The header block must contain the final offset for this stream, as the
100 // trailers may be processed out of order at the peer. 100 // trailers may be processed out of order at the peer.
101 DVLOG(1) << "Inserting trailer: (" << kFinalOffsetHeaderKey << ", " 101 DVLOG(1) << "Inserting trailer: (" << kFinalOffsetHeaderKey << ", "
102 << stream_bytes_written() + queued_data_bytes() << ")"; 102 << stream_bytes_written() + queued_data_bytes() << ")";
103 SpdyHeaderBlock trailer_block_with_offset(trailer_block); 103 SpdyHeaderBlock trailer_block_with_offset(trailer_block);
104 trailer_block_with_offset.insert(std::make_pair( 104 trailer_block_with_offset.insert(
105 kFinalOffsetHeaderKey, 105 std::make_pair(kFinalOffsetHeaderKey,
106 base::IntToString(stream_bytes_written() + queued_data_bytes()))); 106 IntToString(stream_bytes_written() + queued_data_bytes()))) ;
107 107
108 // Write the trailing headers with a FIN, and close stream for writing: 108 // Write the trailing headers with a FIN, and close stream for writing:
109 // trailers are the last thing to be sent on a stream. 109 // trailers are the last thing to be sent on a stream.
110 const bool kFin = true; 110 const bool kFin = true;
111 size_t bytes_written = spdy_session_->WriteHeaders( 111 size_t bytes_written = spdy_session_->WriteHeaders(
112 id(), trailer_block_with_offset, kFin, priority_, ack_notifier_delegate); 112 id(), trailer_block_with_offset, kFin, priority_, ack_notifier_delegate);
113 set_fin_sent(kFin); 113 set_fin_sent(kFin);
114 114
115 // Trailers are the last thing to be sent on a stream, but if there is still 115 // Trailers are the last thing to be sent on a stream, but if there is still
116 // queued data then CloseWriteSide() will cause it never to be sent. 116 // queued data then CloseWriteSide() will cause it never to be sent.
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 visitor_ = nullptr; 354 visitor_ = nullptr;
355 visitor->OnClose(this); 355 visitor->OnClose(this);
356 } 356 }
357 } 357 }
358 358
359 bool QuicSpdyStream::FinishedReadingHeaders() const { 359 bool QuicSpdyStream::FinishedReadingHeaders() const {
360 return headers_decompressed_ && decompressed_headers_.empty() && 360 return headers_decompressed_ && decompressed_headers_.empty() &&
361 header_list_.empty(); 361 header_list_.empty();
362 } 362 }
363 363
364 bool QuicSpdyStream::ParseHeaderStatusCode(SpdyHeaderBlock* header, 364 bool QuicSpdyStream::ParseHeaderStatusCode(const SpdyHeaderBlock& header,
365 int* status_code) const { 365 int* status_code) const {
366 StringPiece status = (*header)[":status"]; 366 SpdyHeaderBlock::const_iterator it = header.find(":status");
367 if (it == header.end()) {
368 return false;
369 }
370 const StringPiece status(it->second);
367 if (status.size() != 3) { 371 if (status.size() != 3) {
368 return false; 372 return false;
369 } 373 }
370 // First character must be an integer in range [1,5]. 374 // First character must be an integer in range [1,5].
371 if (status[0] < '1' || status[0] > '5') { 375 if (status[0] < '1' || status[0] > '5') {
372 return false; 376 return false;
373 } 377 }
374 // The remaining two characters must be integers. 378 // The remaining two characters must be integers.
375 if (!isdigit(status[1]) || !isdigit(status[2])) { 379 if (!isdigit(status[1]) || !isdigit(status[2])) {
376 return false; 380 return false;
(...skipping 15 matching lines...) Expand all
392 396
393 SpdyPriority QuicSpdyStream::priority() const { 397 SpdyPriority QuicSpdyStream::priority() const {
394 return priority_; 398 return priority_;
395 } 399 }
396 400
397 void QuicSpdyStream::ClearSession() { 401 void QuicSpdyStream::ClearSession() {
398 spdy_session_ = nullptr; 402 spdy_session_ = nullptr;
399 } 403 }
400 404
401 } // namespace net 405 } // 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