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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 CHECK_LT(s.size(), static_cast<size_t>(INT_MAX)); | 45 CHECK_LT(s.size(), static_cast<size_t>(INT_MAX)); |
46 data_ = const_cast<char*>(string_data_.data()); | 46 data_ = const_cast<char*>(string_data_.data()); |
47 } | 47 } |
48 | 48 |
49 StringIOBuffer::~StringIOBuffer() { | 49 StringIOBuffer::~StringIOBuffer() { |
50 // We haven't allocated the buffer, so remove it before the base class | 50 // We haven't allocated the buffer, so remove it before the base class |
51 // destructor tries to delete[] it. | 51 // destructor tries to delete[] it. |
52 data_ = NULL; | 52 data_ = NULL; |
53 } | 53 } |
54 | 54 |
| 55 ZeroCopyStringIOBuffer::ZeroCopyStringIOBuffer() : IOBuffer() { |
| 56 } |
| 57 |
| 58 void ZeroCopyStringIOBuffer::Done() { |
| 59 data_ = const_cast<char*>(string_.data()); |
| 60 } |
| 61 |
| 62 ZeroCopyStringIOBuffer::~ZeroCopyStringIOBuffer() { |
| 63 data_ = NULL; |
| 64 } |
| 65 |
55 DrainableIOBuffer::DrainableIOBuffer(IOBuffer* base, int size) | 66 DrainableIOBuffer::DrainableIOBuffer(IOBuffer* base, int size) |
56 : IOBuffer(base->data()), | 67 : IOBuffer(base->data()), |
57 base_(base), | 68 base_(base), |
58 size_(size), | 69 size_(size), |
59 used_(0) { | 70 used_(0) { |
60 } | 71 } |
61 | 72 |
62 void DrainableIOBuffer::DidConsume(int bytes) { | 73 void DrainableIOBuffer::DidConsume(int bytes) { |
63 SetOffset(used_ + bytes); | 74 SetOffset(used_ + bytes); |
64 } | 75 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 141 |
131 WrappedIOBuffer::WrappedIOBuffer(const char* data) | 142 WrappedIOBuffer::WrappedIOBuffer(const char* data) |
132 : IOBuffer(const_cast<char*>(data)) { | 143 : IOBuffer(const_cast<char*>(data)) { |
133 } | 144 } |
134 | 145 |
135 WrappedIOBuffer::~WrappedIOBuffer() { | 146 WrappedIOBuffer::~WrappedIOBuffer() { |
136 data_ = NULL; | 147 data_ = NULL; |
137 } | 148 } |
138 | 149 |
139 } // namespace net | 150 } // namespace net |
OLD | NEW |