OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_BASE_IO_BUFFER_H_ |
| 6 #define NET_BASE_IO_BUFFER_H_ |
| 7 |
| 8 #include "base/ref_counted.h" |
| 9 |
| 10 namespace net { |
| 11 |
| 12 // This is a simple wrapper around a buffer that provides ref counting for |
| 13 // easier asynchronous IO handling. |
| 14 class IOBuffer : public base::RefCountedThreadSafe<IOBuffer> { |
| 15 public: |
| 16 explicit IOBuffer(int buffer_size) { |
| 17 data_ = new char[buffer_size]; |
| 18 } |
| 19 explicit IOBuffer(char* buffer) : data_(buffer) {} |
| 20 virtual ~IOBuffer() { |
| 21 delete[] data_; |
| 22 } |
| 23 |
| 24 char* data() { return data_; } |
| 25 |
| 26 protected: |
| 27 char* data_; |
| 28 }; |
| 29 |
| 30 } // namespace net |
| 31 |
| 32 #endif // NET_BASE_IO_BUFFER_H_ |
OLD | NEW |