Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Unified Diff: net/base/io_buffer.h

Issue 126179: Disk cache: First pass to add support for sparse entries.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/io_buffer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/io_buffer.h
===================================================================
--- net/base/io_buffer.h (revision 18456)
+++ net/base/io_buffer.h (working copy)
@@ -28,15 +28,50 @@
char* data_;
};
+// This version stores the size of the buffer so that the creator of the object
+// doesn't have to keep track of that value.
+// NOTE: This doesn't mean that we want to stop sending the size as an explictit
+// argument to IO functions. Please keep using IOBuffer* for API declarations.
+class IOBufferWithSize : public IOBuffer {
+ public:
+ explicit IOBufferWithSize(int size) : IOBuffer(size), size_(size) {}
+ ~IOBufferWithSize() {}
+
+ int size() const { return size_; }
+
+ private:
+ int size_;
+};
+
+// This version allows the caller to do multiple IO operations reusing a given
+// IOBuffer. We don't own data_, we simply make it point to the buffer of the
+// passed in IOBuffer, plus the desired offset.
+class ReusedIOBuffer : public IOBuffer {
+ public:
+ ReusedIOBuffer(IOBuffer* base, int size)
+ : IOBuffer(base->data()), base_(base), size_(size) {}
+ ~ReusedIOBuffer() {
+ // We don't really own a buffer.
+ data_ = NULL;
+ }
+
+ int size() const { return size_; }
+ void SetOffset(int offset);
+
+ private:
+ scoped_refptr<IOBuffer> base_;
+ int size_;
+};
+
// 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 {
+class WrappedIOBuffer : public IOBuffer {
public:
explicit WrappedIOBuffer(const char* data)
- : net::IOBuffer(const_cast<char*>(data)) {}
+ : IOBuffer(const_cast<char*>(data)) {}
~WrappedIOBuffer() {
data_ = NULL;
}
« no previous file with comments | « no previous file | net/base/io_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698