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

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

Issue 2611613003: Add quic_logging (Closed)
Patch Set: fix failed test? Created 3 years, 11 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/core/quic_stream.cc ('k') | net/quic/core/quic_stream_sequencer_buffer.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/core/quic_stream_sequencer.h" 5 #include "net/quic/core/quic_stream_sequencer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/logging.h"
14 #include "net/quic/core/quic_flags.h" 13 #include "net/quic/core/quic_flags.h"
15 #include "net/quic/core/quic_packets.h" 14 #include "net/quic/core/quic_packets.h"
16 #include "net/quic/core/quic_stream.h" 15 #include "net/quic/core/quic_stream.h"
17 #include "net/quic/core/quic_stream_sequencer_buffer.h" 16 #include "net/quic/core/quic_stream_sequencer_buffer.h"
18 #include "net/quic/core/quic_utils.h" 17 #include "net/quic/core/quic_utils.h"
19 #include "net/quic/platform/api/quic_bug_tracker.h" 18 #include "net/quic/platform/api/quic_bug_tracker.h"
20 #include "net/quic/platform/api/quic_clock.h" 19 #include "net/quic/platform/api/quic_clock.h"
20 #include "net/quic/platform/api/quic_logging.h"
21 #include "net/quic/platform/api/quic_str_cat.h" 21 #include "net/quic/platform/api/quic_str_cat.h"
22 22
23 using base::StringPiece; 23 using base::StringPiece;
24 using std::string; 24 using std::string;
25 25
26 namespace net { 26 namespace net {
27 27
28 QuicStreamSequencer::QuicStreamSequencer(QuicStream* quic_stream, 28 QuicStreamSequencer::QuicStreamSequencer(QuicStream* quic_stream,
29 const QuicClock* clock) 29 const QuicClock* clock)
30 : stream_(quic_stream), 30 : stream_(quic_stream),
(...skipping 21 matching lines...) Expand all
52 size_t bytes_written; 52 size_t bytes_written;
53 string error_details; 53 string error_details;
54 QuicErrorCode result = buffered_frames_.OnStreamData( 54 QuicErrorCode result = buffered_frames_.OnStreamData(
55 byte_offset, StringPiece(frame.data_buffer, frame.data_length), 55 byte_offset, StringPiece(frame.data_buffer, frame.data_length),
56 clock_->ApproximateNow(), &bytes_written, &error_details); 56 clock_->ApproximateNow(), &bytes_written, &error_details);
57 if (result != QUIC_NO_ERROR) { 57 if (result != QUIC_NO_ERROR) {
58 string details = QuicStrCat( 58 string details = QuicStrCat(
59 "Stream ", stream_->id(), ": ", QuicErrorCodeToString(result), ": ", 59 "Stream ", stream_->id(), ": ", QuicErrorCodeToString(result), ": ",
60 error_details, "\nPeer Address: ", 60 error_details, "\nPeer Address: ",
61 stream_->PeerAddressOfLatestPacket().ToString()); 61 stream_->PeerAddressOfLatestPacket().ToString());
62 DLOG(WARNING) << QuicErrorCodeToString(result); 62 QUIC_LOG_FIRST_N(WARNING, 50) << QuicErrorCodeToString(result);
63 DLOG(WARNING) << details; 63 QUIC_LOG_FIRST_N(WARNING, 50) << details;
64 stream_->CloseConnectionWithDetails(result, details); 64 stream_->CloseConnectionWithDetails(result, details);
65 return; 65 return;
66 } 66 }
67 67
68 if (bytes_written == 0) { 68 if (bytes_written == 0) {
69 ++num_duplicate_frames_received_; 69 ++num_duplicate_frames_received_;
70 // Silently ignore duplicates. 70 // Silently ignore duplicates.
71 return; 71 return;
72 } 72 }
73 73
(...skipping 23 matching lines...) Expand all
97 close_offset_ = offset; 97 close_offset_ = offset;
98 98
99 MaybeCloseStream(); 99 MaybeCloseStream();
100 } 100 }
101 101
102 bool QuicStreamSequencer::MaybeCloseStream() { 102 bool QuicStreamSequencer::MaybeCloseStream() {
103 if (blocked_ || !IsClosed()) { 103 if (blocked_ || !IsClosed()) {
104 return false; 104 return false;
105 } 105 }
106 106
107 DVLOG(1) << "Passing up termination, as we've processed " 107 QUIC_DVLOG(1) << "Passing up termination, as we've processed "
108 << buffered_frames_.BytesConsumed() << " of " << close_offset_ 108 << buffered_frames_.BytesConsumed() << " of " << close_offset_
109 << " bytes."; 109 << " bytes.";
110 // This will cause the stream to consume the FIN. 110 // This will cause the stream to consume the FIN.
111 // Technically it's an error if |num_bytes_consumed| isn't exactly 111 // Technically it's an error if |num_bytes_consumed| isn't exactly
112 // equal to |close_offset|, but error handling seems silly at this point. 112 // equal to |close_offset|, but error handling seems silly at this point.
113 if (ignore_read_data_) { 113 if (ignore_read_data_) {
114 // The sequencer is discarding stream data and must notify the stream on 114 // The sequencer is discarding stream data and must notify the stream on
115 // receipt of a FIN because the consumer won't. 115 // receipt of a FIN because the consumer won't.
116 stream_->OnFinRead(); 116 stream_->OnFinRead();
117 } else { 117 } else {
118 stream_->OnDataAvailable(); 118 stream_->OnDataAvailable();
119 } 119 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 void QuicStreamSequencer::ReleaseBufferIfEmpty() { 195 void QuicStreamSequencer::ReleaseBufferIfEmpty() {
196 if (buffered_frames_.Empty()) { 196 if (buffered_frames_.Empty()) {
197 buffered_frames_.ReleaseWholeBuffer(); 197 buffered_frames_.ReleaseWholeBuffer();
198 } 198 }
199 } 199 }
200 200
201 void QuicStreamSequencer::FlushBufferedFrames() { 201 void QuicStreamSequencer::FlushBufferedFrames() {
202 DCHECK(ignore_read_data_); 202 DCHECK(ignore_read_data_);
203 size_t bytes_flushed = buffered_frames_.FlushBufferedFrames(); 203 size_t bytes_flushed = buffered_frames_.FlushBufferedFrames();
204 DVLOG(1) << "Flushing buffered data at offset " 204 QUIC_DVLOG(1) << "Flushing buffered data at offset "
205 << buffered_frames_.BytesConsumed() << " length " << bytes_flushed 205 << buffered_frames_.BytesConsumed() << " length "
206 << " for stream " << stream_->id(); 206 << bytes_flushed << " for stream " << stream_->id();
207 stream_->AddBytesConsumed(bytes_flushed); 207 stream_->AddBytesConsumed(bytes_flushed);
208 MaybeCloseStream(); 208 MaybeCloseStream();
209 } 209 }
210 210
211 size_t QuicStreamSequencer::NumBytesBuffered() const { 211 size_t QuicStreamSequencer::NumBytesBuffered() const {
212 return buffered_frames_.BytesBuffered(); 212 return buffered_frames_.BytesBuffered();
213 } 213 }
214 214
215 QuicStreamOffset QuicStreamSequencer::NumBytesConsumed() const { 215 QuicStreamOffset QuicStreamSequencer::NumBytesConsumed() const {
216 return buffered_frames_.BytesConsumed(); 216 return buffered_frames_.BytesConsumed();
217 } 217 }
218 218
219 const string QuicStreamSequencer::DebugString() const { 219 const string QuicStreamSequencer::DebugString() const {
220 // clang-format off 220 // clang-format off
221 return QuicStrCat("QuicStreamSequencer:", 221 return QuicStrCat("QuicStreamSequencer:",
222 "\n bytes buffered: ", NumBytesBuffered(), 222 "\n bytes buffered: ", NumBytesBuffered(),
223 "\n bytes consumed: ", NumBytesConsumed(), 223 "\n bytes consumed: ", NumBytesConsumed(),
224 "\n has bytes to read: ", HasBytesToRead() ? "true" : "false", 224 "\n has bytes to read: ", HasBytesToRead() ? "true" : "false",
225 "\n frames received: ", num_frames_received(), 225 "\n frames received: ", num_frames_received(),
226 "\n close offset bytes: ", close_offset_, 226 "\n close offset bytes: ", close_offset_,
227 "\n is closed: ", IsClosed() ? "true" : "false"); 227 "\n is closed: ", IsClosed() ? "true" : "false");
228 // clang-format on 228 // clang-format on
229 } 229 }
230 230
231 } // namespace net 231 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_stream.cc ('k') | net/quic/core/quic_stream_sequencer_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698