Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 108 |
| 109 int size_; | 109 int size_; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 // This is a read only IOBuffer. The data is stored in a string and | 112 // This is a read only IOBuffer. The data is stored in a string and |
| 113 // the IOBuffer interface does not provide a proper way to modify it. | 113 // the IOBuffer interface does not provide a proper way to modify it. |
| 114 class NET_EXPORT StringIOBuffer : public IOBuffer { | 114 class NET_EXPORT StringIOBuffer : public IOBuffer { |
| 115 public: | 115 public: |
| 116 explicit StringIOBuffer(const std::string& s); | 116 explicit StringIOBuffer(const std::string& s); |
| 117 | 117 |
| 118 // The string passed to this constructor is std::string::swap'd with the | |
|
michaeln
2014/08/21 01:46:15
Given the scoped_ptr<> input, the xfer of ownershi
jkarlin
2014/08/21 18:31:21
Done.
| |
| 119 // internal string. This is a low cost way to prevent a copy for strings that | |
| 120 // don't provide copy-on-write semantics. | |
| 121 explicit StringIOBuffer(scoped_ptr<std::string> s); | |
| 122 | |
| 118 int size() const { return static_cast<int>(string_data_.size()); } | 123 int size() const { return static_cast<int>(string_data_.size()); } |
| 119 | 124 |
| 120 private: | 125 private: |
| 121 virtual ~StringIOBuffer(); | 126 virtual ~StringIOBuffer(); |
| 122 | 127 |
| 123 std::string string_data_; | 128 std::string string_data_; |
| 124 }; | 129 }; |
| 125 | 130 |
| 126 // This version wraps an existing IOBuffer and provides convenient functions | 131 // This version wraps an existing IOBuffer and provides convenient functions |
| 127 // to progressively read all the data. | 132 // to progressively read all the data. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 public: | 240 public: |
| 236 explicit WrappedIOBuffer(const char* data); | 241 explicit WrappedIOBuffer(const char* data); |
| 237 | 242 |
| 238 protected: | 243 protected: |
| 239 virtual ~WrappedIOBuffer(); | 244 virtual ~WrappedIOBuffer(); |
| 240 }; | 245 }; |
| 241 | 246 |
| 242 } // namespace net | 247 } // namespace net |
| 243 | 248 |
| 244 #endif // NET_BASE_IO_BUFFER_H_ | 249 #endif // NET_BASE_IO_BUFFER_H_ |
| OLD | NEW |