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 #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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 auto iter = block_.find(key); | 292 auto iter = block_.find(key); |
| 293 if (iter == block_.end()) { | 293 if (iter == block_.end()) { |
| 294 DVLOG(1) << "Inserting: (" << key << ", " << value << ")"; | 294 DVLOG(1) << "Inserting: (" << key << ", " << value << ")"; |
| 295 AppendHeader(key, value); | 295 AppendHeader(key, value); |
| 296 return; | 296 return; |
| 297 } | 297 } |
| 298 DVLOG(1) << "Updating key: " << iter->first << "; appending value: " << value; | 298 DVLOG(1) << "Updating key: " << iter->first << "; appending value: " << value; |
| 299 iter->second.Append(GetStorage()->Write(value)); | 299 iter->second.Append(GetStorage()->Write(value)); |
| 300 } | 300 } |
| 301 | 301 |
| 302 size_t SpdyHeaderBlock::EstimateMemoryUsage() const { | |
|
DmitrySkiba
2017/02/02 18:16:27
I think block_ should also be estimated.
xunjieli
2017/02/03 22:25:09
I don't think EMU has support for linked_hash_map?
| |
| 303 return bytes_allocated(); | |
| 304 } | |
| 305 | |
| 302 void SpdyHeaderBlock::AppendHeader(const StringPiece key, | 306 void SpdyHeaderBlock::AppendHeader(const StringPiece key, |
| 303 const StringPiece value) { | 307 const StringPiece value) { |
| 304 auto storage = GetStorage(); | 308 auto storage = GetStorage(); |
| 305 auto backed_key = storage->Write(key); | 309 auto backed_key = storage->Write(key); |
| 306 block_.emplace(make_pair( | 310 block_.emplace(make_pair( |
| 307 backed_key, HeaderValue(storage, backed_key, storage->Write(value)))); | 311 backed_key, HeaderValue(storage, backed_key, storage->Write(value)))); |
| 308 } | 312 } |
| 309 | 313 |
| 310 SpdyHeaderBlock::Storage* SpdyHeaderBlock::GetStorage() { | 314 SpdyHeaderBlock::Storage* SpdyHeaderBlock::GetStorage() { |
| 311 if (!storage_) { | 315 if (!storage_) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 for (++it; it != fragments.end(); ++it) { | 381 for (++it; it != fragments.end(); ++it) { |
| 378 memcpy(dst, separator.data(), separator.size()); | 382 memcpy(dst, separator.data(), separator.size()); |
| 379 dst += separator.size(); | 383 dst += separator.size(); |
| 380 memcpy(dst, it->data(), it->size()); | 384 memcpy(dst, it->data(), it->size()); |
| 381 dst += it->size(); | 385 dst += it->size(); |
| 382 } | 386 } |
| 383 return dst - original_dst; | 387 return dst - original_dst; |
| 384 } | 388 } |
| 385 | 389 |
| 386 } // namespace net | 390 } // namespace net |
| OLD | NEW |