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

Side by Side Diff: remoting/base/compound_buffer.cc

Issue 1273233002: Implement QuicChannel and QuicChannelFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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/p2p/quic_p2p_stream.cc ('k') | remoting/base/constants.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <functional> 5 #include <functional>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
9 #include "remoting/base/compound_buffer.h" 9 #include "remoting/base/compound_buffer.h"
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 locked_ = true; 137 locked_ = true;
138 } 138 }
139 139
140 net::IOBufferWithSize* CompoundBuffer::ToIOBufferWithSize() const { 140 net::IOBufferWithSize* CompoundBuffer::ToIOBufferWithSize() const {
141 net::IOBufferWithSize* result = new net::IOBufferWithSize(total_bytes_); 141 net::IOBufferWithSize* result = new net::IOBufferWithSize(total_bytes_);
142 CopyTo(result->data(), total_bytes_); 142 CopyTo(result->data(), total_bytes_);
143 return result; 143 return result;
144 } 144 }
145 145
146 void CompoundBuffer::CopyTo(char* data, int size) const { 146 void CompoundBuffer::CopyTo(char* data, int size) const {
147 char* pos = data; 147 int pos = 0;
148 for (DataChunkList::const_iterator it = chunks_.begin(); 148 for (DataChunkList::const_iterator it = chunks_.begin();
149 it != chunks_.end(); ++it) { 149 it != chunks_.end() && pos < size; ++it) {
150 CHECK_LE(pos + it->size, data + size); 150 int bytes_to_copy = std::min(size - pos, it->size);
151 memcpy(pos, it->start, it->size); 151 memcpy(data + pos, it->start, bytes_to_copy);
152 pos += it->size; 152 pos += bytes_to_copy;
153 } 153 }
154 } 154 }
155 155
156 void CompoundBuffer::CopyFrom(const CompoundBuffer& source, 156 void CompoundBuffer::CopyFrom(const CompoundBuffer& source,
157 int start, int end) { 157 int start, int end) {
158 // Check that 0 <= |start| <= |end| <= |total_bytes_|. 158 // Check that 0 <= |start| <= |end| <= |total_bytes_|.
159 DCHECK_LE(0, start); 159 DCHECK_LE(0, start);
160 DCHECK_LE(start, end); 160 DCHECK_LE(start, end);
161 DCHECK_LE(end, source.total_bytes()); 161 DCHECK_LE(end, source.total_bytes());
162 162
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 268 }
269 269
270 return count == 0; 270 return count == 0;
271 } 271 }
272 272
273 int64 CompoundBufferInputStream::ByteCount() const { 273 int64 CompoundBufferInputStream::ByteCount() const {
274 return position_; 274 return position_;
275 } 275 }
276 276
277 } // namespace remoting 277 } // namespace remoting
OLDNEW
« no previous file with comments | « net/quic/p2p/quic_p2p_stream.cc ('k') | remoting/base/constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698