OLD | NEW |
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 #ifndef NET_BASE_IO_BUFFER_H_ | 5 #ifndef NET_BASE_IO_BUFFER_H_ |
6 #define NET_BASE_IO_BUFFER_H_ | 6 #define NET_BASE_IO_BUFFER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 int capacity_; | 218 int capacity_; |
219 int offset_; | 219 int offset_; |
220 }; | 220 }; |
221 | 221 |
222 // This versions allows a pickle to be used as the storage for a write-style | 222 // This versions allows a pickle to be used as the storage for a write-style |
223 // operation, avoiding an extra data copy. | 223 // operation, avoiding an extra data copy. |
224 class NET_EXPORT PickledIOBuffer : public IOBuffer { | 224 class NET_EXPORT PickledIOBuffer : public IOBuffer { |
225 public: | 225 public: |
226 PickledIOBuffer(); | 226 PickledIOBuffer(); |
227 | 227 |
228 Pickle* pickle() { return &pickle_; } | 228 base::Pickle* pickle() { return &pickle_; } |
229 | 229 |
230 // Signals that we are done writing to the pickle and we can use it for a | 230 // Signals that we are done writing to the pickle and we can use it for a |
231 // write-style IO operation. | 231 // write-style IO operation. |
232 void Done(); | 232 void Done(); |
233 | 233 |
234 private: | 234 private: |
235 ~PickledIOBuffer() override; | 235 ~PickledIOBuffer() override; |
236 | 236 |
237 Pickle pickle_; | 237 base::Pickle pickle_; |
238 }; | 238 }; |
239 | 239 |
240 // This class allows the creation of a temporary IOBuffer that doesn't really | 240 // This class allows the creation of a temporary IOBuffer that doesn't really |
241 // own the underlying buffer. Please use this class only as a last resort. | 241 // own the underlying buffer. Please use this class only as a last resort. |
242 // A good example is the buffer for a synchronous operation, where we can be | 242 // A good example is the buffer for a synchronous operation, where we can be |
243 // sure that nobody is keeping an extra reference to this object so the lifetime | 243 // sure that nobody is keeping an extra reference to this object so the lifetime |
244 // of the buffer can be completely managed by its intended owner. | 244 // of the buffer can be completely managed by its intended owner. |
245 class NET_EXPORT WrappedIOBuffer : public IOBuffer { | 245 class NET_EXPORT WrappedIOBuffer : public IOBuffer { |
246 public: | 246 public: |
247 explicit WrappedIOBuffer(const char* data); | 247 explicit WrappedIOBuffer(const char* data); |
248 | 248 |
249 protected: | 249 protected: |
250 ~WrappedIOBuffer() override; | 250 ~WrappedIOBuffer() override; |
251 }; | 251 }; |
252 | 252 |
253 } // namespace net | 253 } // namespace net |
254 | 254 |
255 #endif // NET_BASE_IO_BUFFER_H_ | 255 #endif // NET_BASE_IO_BUFFER_H_ |
OLD | NEW |