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

Unified Diff: net/base/io_buffer.h

Issue 465463002: Initial implementation of ServiceWorkerCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cache2
Patch Set: Put and Match mostly work with blobs but the first few bytes are screwy Created 6 years, 4 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
Index: net/base/io_buffer.h
diff --git a/net/base/io_buffer.h b/net/base/io_buffer.h
index 0ce52e8d79c02473adabd6af98e2e9272d9b2fdb..421fa23faea48333ab3a594e707ca38ad1b34ec7 100644
--- a/net/base/io_buffer.h
+++ b/net/base/io_buffer.h
@@ -123,6 +123,24 @@ class NET_EXPORT StringIOBuffer : public IOBuffer {
std::string string_data_;
};
+// This versions allows a string to be used as the storage for a write-style
+// operation, avoiding an extra data copy.
+class NET_EXPORT ZeroCopyStringIOBuffer : public IOBuffer {
+ public:
+ ZeroCopyStringIOBuffer();
+
+ std::string* string() { return &string_; }
+
+ // Signals that we are done writing to the string and we can use it for a
+ // write-style IO operation.
+ void Done();
+
+ private:
+ virtual ~ZeroCopyStringIOBuffer();
+
+ std::string string_;
+};
+
// This version wraps an existing IOBuffer and provides convenient functions
// to progressively read all the data.
//

Powered by Google App Engine
This is Rietveld 408576698