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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_BASE_IO_BUFFER_H_ 5 #ifndef NET_BASE_IO_BUFFER_H_
6 #define NET_BASE_IO_BUFFER_H_ 6 #define NET_BASE_IO_BUFFER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 explicit StringIOBuffer(const std::string& s); 116 explicit StringIOBuffer(const std::string& s);
117 117
118 int size() const { return static_cast<int>(string_data_.size()); } 118 int size() const { return static_cast<int>(string_data_.size()); }
119 119
120 private: 120 private:
121 virtual ~StringIOBuffer(); 121 virtual ~StringIOBuffer();
122 122
123 std::string string_data_; 123 std::string string_data_;
124 }; 124 };
125 125
126 // This versions allows a string to be used as the storage for a write-style
127 // operation, avoiding an extra data copy.
128 class NET_EXPORT ZeroCopyStringIOBuffer : public IOBuffer {
129 public:
130 ZeroCopyStringIOBuffer();
131
132 std::string* string() { return &string_; }
133
134 // Signals that we are done writing to the string and we can use it for a
135 // write-style IO operation.
136 void Done();
137
138 private:
139 virtual ~ZeroCopyStringIOBuffer();
140
141 std::string string_;
142 };
143
126 // This version wraps an existing IOBuffer and provides convenient functions 144 // This version wraps an existing IOBuffer and provides convenient functions
127 // to progressively read all the data. 145 // to progressively read all the data.
128 // 146 //
129 // DrainableIOBuffer is useful when you have an IOBuffer that contains data 147 // DrainableIOBuffer is useful when you have an IOBuffer that contains data
130 // to be written progressively, and Write() function takes an IOBuffer rather 148 // to be written progressively, and Write() function takes an IOBuffer rather
131 // than char*. DrainableIOBuffer can be used as follows: 149 // than char*. DrainableIOBuffer can be used as follows:
132 // 150 //
133 // // payload is the IOBuffer containing the data to be written. 151 // // payload is the IOBuffer containing the data to be written.
134 // buf = new DrainableIOBuffer(payload, payload_size); 152 // buf = new DrainableIOBuffer(payload, payload_size);
135 // 153 //
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 public: 253 public:
236 explicit WrappedIOBuffer(const char* data); 254 explicit WrappedIOBuffer(const char* data);
237 255
238 protected: 256 protected:
239 virtual ~WrappedIOBuffer(); 257 virtual ~WrappedIOBuffer();
240 }; 258 };
241 259
242 } // namespace net 260 } // namespace net
243 261
244 #endif // NET_BASE_IO_BUFFER_H_ 262 #endif // NET_BASE_IO_BUFFER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698