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

Side by Side Diff: net/base/io_buffer.cc

Issue 178473022: MTP Streaming: Readahead Buffer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: this patchset allows memory reuse Created 6 years, 9 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
« net/base/io_buffer.h ('K') | « net/base/io_buffer.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/io_buffer.h" 5 #include "net/base/io_buffer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace net { 9 namespace net {
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return used_; 72 return used_;
73 } 73 }
74 74
75 void DrainableIOBuffer::SetOffset(int bytes) { 75 void DrainableIOBuffer::SetOffset(int bytes) {
76 DCHECK_GE(bytes, 0); 76 DCHECK_GE(bytes, 0);
77 DCHECK_LE(bytes, size_); 77 DCHECK_LE(bytes, size_);
78 used_ = bytes; 78 used_ = bytes;
79 data_ = base_->data() + used_; 79 data_ = base_->data() + used_;
80 } 80 }
81 81
82 void DrainableIOBuffer::SetSize(int size) {
83 DCHECK_GE(size, 0);
84 DCHECK_LE(used_, size);
85 size_ = size;
86 }
87
82 DrainableIOBuffer::~DrainableIOBuffer() { 88 DrainableIOBuffer::~DrainableIOBuffer() {
83 // The buffer is owned by the |base_| instance. 89 // The buffer is owned by the |base_| instance.
84 data_ = NULL; 90 data_ = NULL;
85 } 91 }
86 92
87 GrowableIOBuffer::GrowableIOBuffer() 93 GrowableIOBuffer::GrowableIOBuffer()
88 : IOBuffer(), 94 : IOBuffer(),
89 capacity_(0), 95 capacity_(0),
90 offset_(0) { 96 offset_(0) {
91 } 97 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 136
131 WrappedIOBuffer::WrappedIOBuffer(const char* data) 137 WrappedIOBuffer::WrappedIOBuffer(const char* data)
132 : IOBuffer(const_cast<char*>(data)) { 138 : IOBuffer(const_cast<char*>(data)) {
133 } 139 }
134 140
135 WrappedIOBuffer::~WrappedIOBuffer() { 141 WrappedIOBuffer::~WrappedIOBuffer() {
136 data_ = NULL; 142 data_ = NULL;
137 } 143 }
138 144
139 } // namespace net 145 } // namespace net
OLDNEW
« net/base/io_buffer.h ('K') | « net/base/io_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698