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

Side by Side Diff: net/spdy/spdy_header_block.h

Issue 2801603003: Add SpdyString alias for std::string in net/spdy. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « net/spdy/spdy_framer_test.cc ('k') | net/spdy/spdy_header_block.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SPDY_SPDY_HEADER_BLOCK_H_ 5 #ifndef NET_SPDY_SPDY_HEADER_BLOCK_H_
6 #define NET_SPDY_SPDY_HEADER_BLOCK_H_ 6 #define NET_SPDY_SPDY_HEADER_BLOCK_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <list> 10 #include <list>
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <string>
14 #include <vector> 13 #include <vector>
15 14
16 #include "base/macros.h" 15 #include "base/macros.h"
17 #include "net/base/linked_hash_map.h" 16 #include "net/base/linked_hash_map.h"
18 #include "net/base/net_export.h" 17 #include "net/base/net_export.h"
19 #include "net/log/net_log.h" 18 #include "net/log/net_log.h"
19 #include "net/spdy/platform/api/spdy_string.h"
20 #include "net/spdy/platform/api/spdy_string_piece.h" 20 #include "net/spdy/platform/api/spdy_string_piece.h"
21 21
22 namespace base { 22 namespace base {
23 class Value; 23 class Value;
24 } 24 }
25 25
26 namespace net { 26 namespace net {
27 27
28 class NetLogCaptureMode; 28 class NetLogCaptureMode;
29 29
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 SpdyHeaderBlock& operator=(const SpdyHeaderBlock& other) = delete; 144 SpdyHeaderBlock& operator=(const SpdyHeaderBlock& other) = delete;
145 SpdyHeaderBlock& operator=(SpdyHeaderBlock&& other); 145 SpdyHeaderBlock& operator=(SpdyHeaderBlock&& other);
146 SpdyHeaderBlock Clone() const; 146 SpdyHeaderBlock Clone() const;
147 147
148 bool operator==(const SpdyHeaderBlock& other) const; 148 bool operator==(const SpdyHeaderBlock& other) const;
149 bool operator!=(const SpdyHeaderBlock& other) const; 149 bool operator!=(const SpdyHeaderBlock& other) const;
150 150
151 // Provides a human readable multi-line representation of the stored header 151 // Provides a human readable multi-line representation of the stored header
152 // keys and values. 152 // keys and values.
153 std::string DebugString() const; 153 SpdyString DebugString() const;
154 154
155 iterator begin() { return iterator(block_.begin()); } 155 iterator begin() { return iterator(block_.begin()); }
156 iterator end() { return iterator(block_.end()); } 156 iterator end() { return iterator(block_.end()); }
157 const_iterator begin() const { return const_iterator(block_.begin()); } 157 const_iterator begin() const { return const_iterator(block_.begin()); }
158 const_iterator end() const { return const_iterator(block_.end()); } 158 const_iterator end() const { return const_iterator(block_.end()); }
159 bool empty() const { return block_.empty(); } 159 bool empty() const { return block_.empty(); }
160 size_t size() const { return block_.size(); } 160 size_t size() const { return block_.size(); }
161 iterator find(SpdyStringPiece key) { return iterator(block_.find(key)); } 161 iterator find(SpdyStringPiece key) { return iterator(block_.find(key)); }
162 const_iterator find(SpdyStringPiece key) const { 162 const_iterator find(SpdyStringPiece key) const {
163 return const_iterator(block_.find(key)); 163 return const_iterator(block_.find(key));
(...skipping 13 matching lines...) Expand all
177 // existing header value, NUL ("\0") separated unless the key is cookie, in 177 // existing header value, NUL ("\0") separated unless the key is cookie, in
178 // which case the separator is "; ". 178 // which case the separator is "; ".
179 // If there is no such key, a new header with the key and value is added. 179 // If there is no such key, a new header with the key and value is added.
180 void AppendValueOrAddHeader(const SpdyStringPiece key, 180 void AppendValueOrAddHeader(const SpdyStringPiece key,
181 const SpdyStringPiece value); 181 const SpdyStringPiece value);
182 182
183 // Allows either lookup or mutation of the value associated with a key. 183 // Allows either lookup or mutation of the value associated with a key.
184 ValueProxy operator[](const SpdyStringPiece key); 184 ValueProxy operator[](const SpdyStringPiece key);
185 185
186 // This object provides automatic conversions that allow SpdyHeaderBlock to be 186 // This object provides automatic conversions that allow SpdyHeaderBlock to be
187 // nearly a drop-in replacement for linked_hash_map<string, string>. It reads 187 // nearly a drop-in replacement for linked_hash_map<SpdyString, SpdyString>.
188 // data from or writes data to a SpdyHeaderBlock::Storage. 188 // It reads data from or writes data to a SpdyHeaderBlock::Storage.
189 class NET_EXPORT ValueProxy { 189 class NET_EXPORT ValueProxy {
190 public: 190 public:
191 ~ValueProxy(); 191 ~ValueProxy();
192 192
193 // Moves are allowed. 193 // Moves are allowed.
194 ValueProxy(ValueProxy&& other); 194 ValueProxy(ValueProxy&& other);
195 ValueProxy& operator=(ValueProxy&& other); 195 ValueProxy& operator=(ValueProxy&& other);
196 196
197 // Copies are not. 197 // Copies are not.
198 ValueProxy(const ValueProxy& other) = delete; 198 ValueProxy(const ValueProxy& other) = delete;
199 ValueProxy& operator=(const ValueProxy& other) = delete; 199 ValueProxy& operator=(const ValueProxy& other) = delete;
200 200
201 // Assignment modifies the underlying SpdyHeaderBlock. 201 // Assignment modifies the underlying SpdyHeaderBlock.
202 ValueProxy& operator=(const SpdyStringPiece other); 202 ValueProxy& operator=(const SpdyStringPiece other);
203 203
204 std::string as_string() const; 204 SpdyString as_string() const;
205 205
206 private: 206 private:
207 friend class SpdyHeaderBlock; 207 friend class SpdyHeaderBlock;
208 friend class test::ValueProxyPeer; 208 friend class test::ValueProxyPeer;
209 209
210 ValueProxy(SpdyHeaderBlock::MapType* block, 210 ValueProxy(SpdyHeaderBlock::MapType* block,
211 SpdyHeaderBlock::Storage* storage, 211 SpdyHeaderBlock::Storage* storage,
212 SpdyHeaderBlock::MapType::iterator lookup_result, 212 SpdyHeaderBlock::MapType::iterator lookup_result,
213 const SpdyStringPiece key); 213 const SpdyStringPiece key);
214 214
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // to |headers|. |event_param| must have been created by 250 // to |headers|. |event_param| must have been created by
251 // SpdyHeaderBlockNetLogCallback. On failure, returns false and clears 251 // SpdyHeaderBlockNetLogCallback. On failure, returns false and clears
252 // |headers|. 252 // |headers|.
253 NET_EXPORT bool SpdyHeaderBlockFromNetLogParam( 253 NET_EXPORT bool SpdyHeaderBlockFromNetLogParam(
254 const base::Value* event_param, 254 const base::Value* event_param,
255 SpdyHeaderBlock* headers); 255 SpdyHeaderBlock* headers);
256 256
257 } // namespace net 257 } // namespace net
258 258
259 #endif // NET_SPDY_SPDY_HEADER_BLOCK_H_ 259 #endif // NET_SPDY_SPDY_HEADER_BLOCK_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer_test.cc ('k') | net/spdy/spdy_header_block.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698