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

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

Issue 15937012: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small bug fixes Created 7 years, 6 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 | Annotate | Revision Log
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 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 << num_bytes_consumed_ << " of " << close_offset_ 132 << num_bytes_consumed_ << " of " << close_offset_
133 << " bytes."; 133 << " bytes.";
134 // Technically it's an error if num_bytes_consumed isn't exactly 134 // Technically it's an error if num_bytes_consumed isn't exactly
135 // equal, but error handling seems silly at this point. 135 // equal, but error handling seems silly at this point.
136 stream_->TerminateFromPeer(half_close_); 136 stream_->TerminateFromPeer(half_close_);
137 return true; 137 return true;
138 } 138 }
139 return false; 139 return false;
140 } 140 }
141 141
142 int QuicStreamSequencer::GetReadableRegions(iovec* iov, int iov_len) { 142 int QuicStreamSequencer::GetReadableRegions(iovec* iov, size_t iov_len) {
143 FrameMap::iterator it = frames_.begin(); 143 FrameMap::iterator it = frames_.begin();
144 int index = 0; 144 size_t index = 0;
145 uint64 offset = num_bytes_consumed_; 145 QuicStreamOffset offset = num_bytes_consumed_;
146 while (it != frames_.end() && index < iov_len) { 146 while (it != frames_.end() && index < iov_len) {
147 if (it->first != offset) return index; 147 if (it->first != offset) return index;
148 148
149 iov[index].iov_base = static_cast<void*>( 149 iov[index].iov_base = static_cast<void*>(
150 const_cast<char*>(it->second.data())); 150 const_cast<char*>(it->second.data()));
151 iov[index].iov_len = it->second.size(); 151 iov[index].iov_len = it->second.size();
152 offset += it->second.size(); 152 offset += it->second.size();
153 153
154 ++index; 154 ++index;
155 ++it; 155 ++it;
156 } 156 }
157 return index; 157 return index;
158 } 158 }
159 159
160 int QuicStreamSequencer::Readv(const struct iovec* iov, int iov_len) { 160 int QuicStreamSequencer::Readv(const struct iovec* iov, size_t iov_len) {
161 FrameMap::iterator it = frames_.begin(); 161 FrameMap::iterator it = frames_.begin();
162 int iov_index = 0; 162 size_t iov_index = 0;
163 size_t iov_offset = 0; 163 size_t iov_offset = 0;
164 size_t frame_offset = 0; 164 size_t frame_offset = 0;
165 size_t initial_bytes_consumed = num_bytes_consumed_; 165 size_t initial_bytes_consumed = num_bytes_consumed_;
166 166
167 while (iov_index < iov_len && 167 while (iov_index < iov_len &&
168 it != frames_.end() && 168 it != frames_.end() &&
169 it->first == num_bytes_consumed_) { 169 it->first == num_bytes_consumed_) {
170 int bytes_to_read = min(iov[iov_index].iov_len - iov_offset, 170 int bytes_to_read = min(iov[iov_index].iov_len - iov_offset,
171 it->second.size() - frame_offset); 171 it->second.size() - frame_offset);
172 172
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } else { 263 } else {
264 string new_data = it->second.substr(bytes_consumed); 264 string new_data = it->second.substr(bytes_consumed);
265 frames_.erase(it); 265 frames_.erase(it);
266 frames_.insert(make_pair(num_bytes_consumed_, new_data)); 266 frames_.insert(make_pair(num_bytes_consumed_, new_data));
267 return; 267 return;
268 } 268 }
269 } 269 }
270 } 270 }
271 271
272 } // namespace net 272 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698