OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_buffer.h" | 5 #include "net/quic/core/quic_stream_sequencer_buffer.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "net/quic/core/quic_flags.h" | 8 #include "net/quic/core/quic_flags.h" |
9 #include "net/quic/platform/api/quic_bug_tracker.h" | 9 #include "net/quic/platform/api/quic_bug_tracker.h" |
10 #include "net/quic/platform/api/quic_logging.h" | 10 #include "net/quic/platform/api/quic_logging.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return false; | 74 return false; |
75 } | 75 } |
76 delete blocks_[idx]; | 76 delete blocks_[idx]; |
77 blocks_[idx] = nullptr; | 77 blocks_[idx] = nullptr; |
78 QUIC_DVLOG(1) << "Retired block with index: " << idx; | 78 QUIC_DVLOG(1) << "Retired block with index: " << idx; |
79 return true; | 79 return true; |
80 } | 80 } |
81 | 81 |
82 QuicErrorCode QuicStreamSequencerBuffer::OnStreamData( | 82 QuicErrorCode QuicStreamSequencerBuffer::OnStreamData( |
83 QuicStreamOffset starting_offset, | 83 QuicStreamOffset starting_offset, |
84 base::StringPiece data, | 84 QuicStringPiece data, |
85 QuicTime timestamp, | 85 QuicTime timestamp, |
86 size_t* const bytes_buffered, | 86 size_t* const bytes_buffered, |
87 std::string* error_details) { | 87 std::string* error_details) { |
88 CHECK_EQ(destruction_indicator_, 123456) << "This object has been destructed"; | 88 CHECK_EQ(destruction_indicator_, 123456) << "This object has been destructed"; |
89 *bytes_buffered = 0; | 89 *bytes_buffered = 0; |
90 QuicStreamOffset offset = starting_offset; | 90 QuicStreamOffset offset = starting_offset; |
91 size_t size = data.size(); | 91 size_t size = data.size(); |
92 if (size == 0) { | 92 if (size == 0) { |
93 *error_details = "Received empty stream frame without FIN."; | 93 *error_details = "Received empty stream frame without FIN."; |
94 return QUIC_EMPTY_STREAM_FRAME_NO_FIN; | 94 return QUIC_EMPTY_STREAM_FRAME_NO_FIN; |
95 } | 95 } |
96 | 96 |
97 // Find the first gap not ending before |offset|. This gap maybe the gap to | 97 // Find the first gap not ending before |offset|. This gap maybe the gap to |
98 // fill if the arriving frame doesn't overlaps with previous ones. | 98 // fill if the arriving frame doesn't overlaps with previous ones. |
99 std::list<Gap>::iterator current_gap = gaps_.begin(); | 99 std::list<Gap>::iterator current_gap = gaps_.begin(); |
100 while (current_gap != gaps_.end() && current_gap->end_offset <= offset) { | 100 while (current_gap != gaps_.end() && current_gap->end_offset <= offset) { |
101 ++current_gap; | 101 ++current_gap; |
102 } | 102 } |
103 | 103 |
104 DCHECK(current_gap != gaps_.end()); | 104 DCHECK(current_gap != gaps_.end()); |
105 | 105 |
106 // "duplication": might duplicate with data alread filled,but also might | 106 // "duplication": might duplicate with data alread filled,but also might |
107 // overlap across different base::StringPiece objects already written. | 107 // overlap across different QuicStringPiece objects already written. |
108 // In both cases, don't write the data, | 108 // In both cases, don't write the data, |
109 // and allow the caller of this method to handle the result. | 109 // and allow the caller of this method to handle the result. |
110 if (offset < current_gap->begin_offset && | 110 if (offset < current_gap->begin_offset && |
111 offset + size <= current_gap->begin_offset) { | 111 offset + size <= current_gap->begin_offset) { |
112 QUIC_DVLOG(1) << "Duplicated data at offset: " << offset | 112 QUIC_DVLOG(1) << "Duplicated data at offset: " << offset |
113 << " length: " << size; | 113 << " length: " << size; |
114 return QUIC_NO_ERROR; | 114 return QUIC_NO_ERROR; |
115 } | 115 } |
116 if (offset < current_gap->begin_offset && | 116 if (offset < current_gap->begin_offset && |
117 offset + size > current_gap->begin_offset) { | 117 offset + size > current_gap->begin_offset) { |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 QuicStreamOffset current_frame_end_offset = | 584 QuicStreamOffset current_frame_end_offset = |
585 it.second.length + current_frame_begin_offset; | 585 it.second.length + current_frame_begin_offset; |
586 current_frames_string.append(QuicStrCat( | 586 current_frames_string.append(QuicStrCat( |
587 "[", current_frame_begin_offset, ", ", current_frame_end_offset, | 587 "[", current_frame_begin_offset, ", ", current_frame_end_offset, |
588 ") receiving time ", it.second.timestamp.ToDebuggingValue())); | 588 ") receiving time ", it.second.timestamp.ToDebuggingValue())); |
589 } | 589 } |
590 return current_frames_string; | 590 return current_frames_string; |
591 } | 591 } |
592 | 592 |
593 } // namespace net | 593 } // namespace net |
OLD | NEW |