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 #include "net/spdy/spdy_header_block.h" | 5 #include "net/spdy/spdy_header_block.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 SpdyHeaderBlock::ValueProxy::ValueProxy( | 83 SpdyHeaderBlock::ValueProxy::ValueProxy( |
84 SpdyHeaderBlock::MapType* block, | 84 SpdyHeaderBlock::MapType* block, |
85 SpdyHeaderBlock::Storage* storage, | 85 SpdyHeaderBlock::Storage* storage, |
86 SpdyHeaderBlock::MapType::iterator lookup_result, | 86 SpdyHeaderBlock::MapType::iterator lookup_result, |
87 const StringPiece key) | 87 const StringPiece key) |
88 : block_(block), | 88 : block_(block), |
89 storage_(storage), | 89 storage_(storage), |
90 lookup_result_(lookup_result), | 90 lookup_result_(lookup_result), |
91 key_(key), | 91 key_(key), |
92 valid_(true) {} | 92 valid_(true) { |
| 93 DVLOG(1) << "Constructing ValueProxy with key: " << key; |
| 94 } |
93 | 95 |
94 SpdyHeaderBlock::ValueProxy::ValueProxy(ValueProxy&& other) | 96 SpdyHeaderBlock::ValueProxy::ValueProxy(ValueProxy&& other) |
95 : block_(other.block_), | 97 : block_(other.block_), |
96 storage_(other.storage_), | 98 storage_(other.storage_), |
97 lookup_result_(other.lookup_result_), | 99 lookup_result_(other.lookup_result_), |
98 key_(other.key_), | 100 key_(other.key_), |
99 valid_(true) { | 101 valid_(true) { |
100 other.valid_ = false; | 102 other.valid_ = false; |
101 } | 103 } |
102 | 104 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 out_key = GetStorage()->Write(key); | 217 out_key = GetStorage()->Write(key); |
216 DVLOG(2) << "Key written as: " << std::hex | 218 DVLOG(2) << "Key written as: " << std::hex |
217 << static_cast<const void*>(key.data()) << ", " << std::dec | 219 << static_cast<const void*>(key.data()) << ", " << std::dec |
218 << key.size(); | 220 << key.size(); |
219 } else { | 221 } else { |
220 out_key = iter->first; | 222 out_key = iter->first; |
221 } | 223 } |
222 return ValueProxy(&block_, GetStorage(), iter, out_key); | 224 return ValueProxy(&block_, GetStorage(), iter, out_key); |
223 } | 225 } |
224 | 226 |
225 StringPiece SpdyHeaderBlock::GetHeader(const StringPiece key) const { | |
226 auto iter = block_.find(key); | |
227 return iter == block_.end() ? StringPiece() : iter->second; | |
228 } | |
229 | |
230 void SpdyHeaderBlock::AppendValueOrAddHeader(const StringPiece key, | 227 void SpdyHeaderBlock::AppendValueOrAddHeader(const StringPiece key, |
231 const StringPiece value) { | 228 const StringPiece value) { |
232 auto iter = block_.find(key); | 229 auto iter = block_.find(key); |
233 if (iter == block_.end()) { | 230 if (iter == block_.end()) { |
234 DVLOG(1) << "Inserting: (" << key << ", " << value << ")"; | 231 DVLOG(1) << "Inserting: (" << key << ", " << value << ")"; |
235 AppendHeader(key, value); | 232 AppendHeader(key, value); |
236 return; | 233 return; |
237 } | 234 } |
238 DVLOG(1) << "Updating key: " << iter->first << "; appending value: " << value; | 235 DVLOG(1) << "Updating key: " << iter->first << "; appending value: " << value; |
239 StringPiece separator("", 1); | 236 StringPiece separator("", 1); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 if (!it.value().GetAsString(&value)) { | 288 if (!it.value().GetAsString(&value)) { |
292 headers->clear(); | 289 headers->clear(); |
293 return false; | 290 return false; |
294 } | 291 } |
295 (*headers)[it.key()] = value; | 292 (*headers)[it.key()] = value; |
296 } | 293 } |
297 return true; | 294 return true; |
298 } | 295 } |
299 | 296 |
300 } // namespace net | 297 } // namespace net |
OLD | NEW |