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

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: Nits 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..df8eb5e37951e61f5f4881b2524512220492a477 100644
--- a/net/base/io_buffer.h
+++ b/net/base/io_buffer.h
@@ -123,6 +123,22 @@ class NET_EXPORT StringIOBuffer : public IOBuffer {
std::string string_data_;
};
+// This version allows a string to be used as the storage for a write-style
+// operation, avoiding an extra data copy. The string passed to the constructor
+// is std::string::swap'd with an interal string.
+class NET_EXPORT ZeroCopyStringIOBuffer : public IOBuffer {
gavinp 2014/08/14 22:02:45 Firstly, this is really cool. Well thought out and
jkarlin 2014/08/15 00:13:34 Great suggestion. Done.
+ public:
+ // The input |s| is swapped with string_.
+ ZeroCopyStringIOBuffer(std::string* s);
+
+ std::string* string() { return &string_; }
+
+ 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