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

Side by Side Diff: net/quic/test_tools/quic_stream_sequencer_buffer_peer.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/test_tools/fake_proof_source.cc ('k') | net/quic/test_tools/quic_test_utils.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/test_tools/quic_stream_sequencer_buffer_peer.h" 5 #include "net/quic/test_tools/quic_stream_sequencer_buffer_peer.h"
6 6
7 #include "net/quic/core/quic_flags.h" 7 #include "net/quic/core/quic_flags.h"
8 #include "net/quic/platform/api/quic_logging.h"
8 #include "net/test/gtest_util.h" 9 #include "net/test/gtest_util.h"
9 10
10 typedef net::QuicStreamSequencerBuffer::BufferBlock BufferBlock; 11 typedef net::QuicStreamSequencerBuffer::BufferBlock BufferBlock;
11 typedef net::QuicStreamSequencerBuffer::FrameInfo FrameInfo; 12 typedef net::QuicStreamSequencerBuffer::FrameInfo FrameInfo;
12 typedef net::QuicStreamSequencerBuffer::Gap Gap; 13 typedef net::QuicStreamSequencerBuffer::Gap Gap;
13 14
14 static const size_t kBlockSizeBytes = 15 static const size_t kBlockSizeBytes =
15 net::QuicStreamSequencerBuffer::kBlockSizeBytes; 16 net::QuicStreamSequencerBuffer::kBlockSizeBytes;
16 17
17 namespace net { 18 namespace net {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 buffer_->num_bytes_buffered_ == 0); 61 buffer_->num_bytes_buffered_ == 0);
61 return CheckBufferInvariants(); 62 return CheckBufferInvariants();
62 } 63 }
63 64
64 bool QuicStreamSequencerBufferPeer::CheckBufferInvariants() { 65 bool QuicStreamSequencerBufferPeer::CheckBufferInvariants() {
65 QuicStreamOffset data_span = 66 QuicStreamOffset data_span =
66 buffer_->gaps_.back().begin_offset - buffer_->total_bytes_read_; 67 buffer_->gaps_.back().begin_offset - buffer_->total_bytes_read_;
67 bool capacity_sane = data_span <= buffer_->max_buffer_capacity_bytes_ && 68 bool capacity_sane = data_span <= buffer_->max_buffer_capacity_bytes_ &&
68 data_span >= buffer_->num_bytes_buffered_; 69 data_span >= buffer_->num_bytes_buffered_;
69 if (!capacity_sane) { 70 if (!capacity_sane) {
70 LOG(ERROR) << "data span is larger than capacity."; 71 QUIC_LOG(ERROR) << "data span is larger than capacity.";
71 LOG(ERROR) << "total read: " << buffer_->total_bytes_read_ 72 QUIC_LOG(ERROR) << "total read: " << buffer_->total_bytes_read_
72 << " last byte: " << buffer_->gaps_.back().begin_offset; 73 << " last byte: " << buffer_->gaps_.back().begin_offset;
73 } 74 }
74 bool total_read_sane = 75 bool total_read_sane =
75 buffer_->gaps_.front().begin_offset >= buffer_->total_bytes_read_; 76 buffer_->gaps_.front().begin_offset >= buffer_->total_bytes_read_;
76 if (!total_read_sane) { 77 if (!total_read_sane) {
77 LOG(ERROR) << "read across 1st gap."; 78 QUIC_LOG(ERROR) << "read across 1st gap.";
78 } 79 }
79 bool read_offset_sane = buffer_->ReadOffset() < kBlockSizeBytes; 80 bool read_offset_sane = buffer_->ReadOffset() < kBlockSizeBytes;
80 if (!capacity_sane) { 81 if (!capacity_sane) {
81 LOG(ERROR) << "read offset go beyond 1st block"; 82 QUIC_LOG(ERROR) << "read offset go beyond 1st block";
82 } 83 }
83 bool block_match_capacity = (buffer_->max_buffer_capacity_bytes_ <= 84 bool block_match_capacity = (buffer_->max_buffer_capacity_bytes_ <=
84 buffer_->blocks_count_ * kBlockSizeBytes) && 85 buffer_->blocks_count_ * kBlockSizeBytes) &&
85 (buffer_->max_buffer_capacity_bytes_ > 86 (buffer_->max_buffer_capacity_bytes_ >
86 (buffer_->blocks_count_ - 1) * kBlockSizeBytes); 87 (buffer_->blocks_count_ - 1) * kBlockSizeBytes);
87 if (!capacity_sane) { 88 if (!capacity_sane) {
88 LOG(ERROR) << "block number not match capcaity."; 89 QUIC_LOG(ERROR) << "block number not match capcaity.";
89 } 90 }
90 bool block_retired_when_empty = CheckEmptyInvariants(); 91 bool block_retired_when_empty = CheckEmptyInvariants();
91 if (!block_retired_when_empty) { 92 if (!block_retired_when_empty) {
92 LOG(ERROR) << "block is not retired after use."; 93 QUIC_LOG(ERROR) << "block is not retired after use.";
93 } 94 }
94 return capacity_sane && total_read_sane && read_offset_sane && 95 return capacity_sane && total_read_sane && read_offset_sane &&
95 block_match_capacity && block_retired_when_empty; 96 block_match_capacity && block_retired_when_empty;
96 } 97 }
97 98
98 size_t QuicStreamSequencerBufferPeer::GetInBlockOffset( 99 size_t QuicStreamSequencerBufferPeer::GetInBlockOffset(
99 QuicStreamOffset offset) { 100 QuicStreamOffset offset) {
100 return buffer_->GetInBlockOffset(offset); 101 return buffer_->GetInBlockOffset(offset);
101 } 102 }
102 103
(...skipping 30 matching lines...) Expand all
133 void QuicStreamSequencerBufferPeer::set_gaps(const std::list<Gap>& gaps) { 134 void QuicStreamSequencerBufferPeer::set_gaps(const std::list<Gap>& gaps) {
134 buffer_->gaps_ = gaps; 135 buffer_->gaps_ = gaps;
135 } 136 }
136 137
137 bool QuicStreamSequencerBufferPeer::IsBufferAllocated() { 138 bool QuicStreamSequencerBufferPeer::IsBufferAllocated() {
138 return buffer_->blocks_ != nullptr; 139 return buffer_->blocks_ != nullptr;
139 } 140 }
140 141
141 } // namespace test 142 } // namespace test
142 } // namespace net 143 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/fake_proof_source.cc ('k') | net/quic/test_tools/quic_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698