summaryrefslogtreecommitdiffstats
path: root/net/base/io_buffer.h
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-10 23:08:33 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-10 23:08:33 +0000
commit4d8a425272c3a2749c9a0d13cce43df3be8de789 (patch)
treecf903adb661feb8477e06ffe465101ef4eb6b91e /net/base/io_buffer.h
parentc07d895f10758a47d36ba70cbd9f032ad9e34477 (diff)
downloadchromium_src-4d8a425272c3a2749c9a0d13cce43df3be8de789.zip
chromium_src-4d8a425272c3a2749c9a0d13cce43df3be8de789.tar.gz
chromium_src-4d8a425272c3a2749c9a0d13cce43df3be8de789.tar.bz2
Extend the IOBuffer to the disk cache.
This is cleanup from bug 5325. Review URL: http://codereview.chromium.org/20134 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/io_buffer.h')
-rw-r--r--net/base/io_buffer.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/net/base/io_buffer.h b/net/base/io_buffer.h
index 39399ad..88066c2 100644
--- a/net/base/io_buffer.h
+++ b/net/base/io_buffer.h
@@ -19,7 +19,7 @@ class IOBuffer : public base::RefCountedThreadSafe<IOBuffer> {
DCHECK(buffer_size);
data_ = new char[buffer_size];
}
- explicit IOBuffer(char* buffer) : data_(buffer) {}
+ explicit IOBuffer(char* data) : data_(data) {}
virtual ~IOBuffer() {
delete[] data_;
}
@@ -30,6 +30,20 @@ class IOBuffer : public base::RefCountedThreadSafe<IOBuffer> {
char* data_;
};
+// This class allows the creation of a temporary IOBuffer that doesn't really
+// own the underlying buffer. Please use this class only as a last resort.
+// A good example is the buffer for a synchronous operation, where we can be
+// sure that nobody is keeping an extra reference to this object so the lifetime
+// of the buffer can be completely managed by its intended owner.
+class WrappedIOBuffer : public net::IOBuffer {
+ public:
+ explicit WrappedIOBuffer(const char* data)
+ : net::IOBuffer(const_cast<char*>(data)) {}
+ ~WrappedIOBuffer() {
+ data_ = NULL;
+ }
+};
+
} // namespace net
#endif // NET_BASE_IO_BUFFER_H_