| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |