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

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

Issue 1408803002: relnote: Measure HOL blocking in QUIC headers stream. Flag protected by quic_measure_headers_hol_bl… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@uma_for_hol_merge
Patch Set: get rid of git certs leakage Created 5 years, 2 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_stream_sequencer.h ('k') | net/quic/quic_stream_sequencer_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_stream_sequencer.h" 5 #include "net/quic/quic_stream_sequencer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "net/quic/quic_clock.h"
12 #include "net/quic/quic_frame_list.h" 13 #include "net/quic/quic_frame_list.h"
13 #include "net/quic/reliable_quic_stream.h" 14 #include "net/quic/reliable_quic_stream.h"
15 #include "net/quic/reliable_quic_stream.h"
14 16
15 using std::min; 17 using std::min;
16 using std::numeric_limits; 18 using std::numeric_limits;
17 using std::string; 19 using std::string;
18 20
19 namespace net { 21 namespace net {
20 22
21 QuicStreamSequencer::QuicStreamSequencer(ReliableQuicStream* quic_stream) 23 QuicStreamSequencer::QuicStreamSequencer(ReliableQuicStream* quic_stream,
24 const QuicClock* clock)
22 : stream_(quic_stream), 25 : stream_(quic_stream),
23 num_bytes_consumed_(0), 26 num_bytes_consumed_(0),
24 close_offset_(numeric_limits<QuicStreamOffset>::max()), 27 close_offset_(numeric_limits<QuicStreamOffset>::max()),
25 blocked_(false), 28 blocked_(false),
26 num_bytes_buffered_(0), 29 num_bytes_buffered_(0),
27 num_frames_received_(0), 30 num_frames_received_(0),
28 num_duplicate_frames_received_(0), 31 num_duplicate_frames_received_(0),
29 num_early_frames_received_(0) {} 32 num_early_frames_received_(0),
33 clock_(clock) {}
30 34
31 QuicStreamSequencer::~QuicStreamSequencer() {} 35 QuicStreamSequencer::~QuicStreamSequencer() {}
32 36
33 void QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) { 37 void QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) {
34 ++num_frames_received_; 38 ++num_frames_received_;
35 const QuicStreamOffset byte_offset = frame.offset; 39 const QuicStreamOffset byte_offset = frame.offset;
36 const size_t data_len = frame.data.length(); 40 const size_t data_len = frame.data.length();
37 if (data_len == 0 && !frame.fin) { 41 if (data_len == 0 && !frame.fin) {
38 // Stream frames must have data or a fin flag. 42 // Stream frames must have data or a fin flag.
39 stream_->CloseConnectionWithDetails(QUIC_INVALID_STREAM_FRAME, 43 stream_->CloseConnectionWithDetails(QUIC_INVALID_STREAM_FRAME,
40 "Empty stream frame without FIN set."); 44 "Empty stream frame without FIN set.");
41 return; 45 return;
42 } 46 }
43 47
44 if (frame.fin) { 48 if (frame.fin) {
45 CloseStreamAtOffset(frame.offset + data_len); 49 CloseStreamAtOffset(frame.offset + data_len);
46 if (data_len == 0) { 50 if (data_len == 0) {
47 return; 51 return;
48 } 52 }
49 } 53 }
50 size_t bytes_written; 54 size_t bytes_written;
51 QuicErrorCode result = 55 QuicErrorCode result = buffered_frames_.WriteAtOffset(
52 buffered_frames_.WriteAtOffset(byte_offset, frame.data, &bytes_written); 56 byte_offset, frame.data, clock_->ApproximateNow(), &bytes_written);
53 57
54 if (result == QUIC_INVALID_STREAM_DATA) { 58 if (result == QUIC_INVALID_STREAM_DATA) {
55 stream_->CloseConnectionWithDetails( 59 stream_->CloseConnectionWithDetails(
56 QUIC_INVALID_STREAM_FRAME, "Stream frame overlaps with buffered data."); 60 QUIC_INVALID_STREAM_FRAME, "Stream frame overlaps with buffered data.");
57 return; 61 return;
58 } 62 }
59 if (result == QUIC_NO_ERROR && bytes_written == 0) { 63 if (result == QUIC_NO_ERROR && bytes_written == 0) {
60 ++num_duplicate_frames_received_; 64 ++num_duplicate_frames_received_;
61 // Silently ignore duplicates. 65 // Silently ignore duplicates.
62 return; 66 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return true; 108 return true;
105 } 109 }
106 return false; 110 return false;
107 } 111 }
108 112
109 int QuicStreamSequencer::GetReadableRegions(iovec* iov, size_t iov_len) const { 113 int QuicStreamSequencer::GetReadableRegions(iovec* iov, size_t iov_len) const {
110 DCHECK(!blocked_); 114 DCHECK(!blocked_);
111 return buffered_frames_.GetReadableRegions(iov, iov_len); 115 return buffered_frames_.GetReadableRegions(iov, iov_len);
112 } 116 }
113 117
118 bool QuicStreamSequencer::GetReadableRegion(iovec* iov,
119 QuicTime* timestamp) const {
120 DCHECK(!blocked_);
121 return buffered_frames_.GetReadableRegion(iov, timestamp);
122 }
123
114 int QuicStreamSequencer::Readv(const struct iovec* iov, size_t iov_len) { 124 int QuicStreamSequencer::Readv(const struct iovec* iov, size_t iov_len) {
115 DCHECK(!blocked_); 125 DCHECK(!blocked_);
116 size_t bytes_read = buffered_frames_.ReadvAndInvalidate(iov, iov_len); 126 size_t bytes_read = buffered_frames_.ReadvAndInvalidate(iov, iov_len);
117 RecordBytesConsumed(bytes_read); 127 RecordBytesConsumed(bytes_read);
118 return static_cast<int>(bytes_read); 128 return static_cast<int>(bytes_read);
119 } 129 }
120 130
121 bool QuicStreamSequencer::HasBytesToRead() const { 131 bool QuicStreamSequencer::HasBytesToRead() const {
122 return buffered_frames_.HasBytesToRead(); 132 return buffered_frames_.HasBytesToRead();
123 } 133 }
(...skipping 28 matching lines...) Expand all
152 } 162 }
153 163
154 void QuicStreamSequencer::RecordBytesConsumed(size_t bytes_consumed) { 164 void QuicStreamSequencer::RecordBytesConsumed(size_t bytes_consumed) {
155 num_bytes_consumed_ += bytes_consumed; 165 num_bytes_consumed_ += bytes_consumed;
156 num_bytes_buffered_ -= bytes_consumed; 166 num_bytes_buffered_ -= bytes_consumed;
157 167
158 stream_->AddBytesConsumed(bytes_consumed); 168 stream_->AddBytesConsumed(bytes_consumed);
159 } 169 }
160 170
161 } // namespace net 171 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_sequencer.h ('k') | net/quic/quic_stream_sequencer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698