| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/hpack/hpack_entry.h" | 5 #include "net/spdy/hpack/hpack_entry.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" | 9 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 using base::StringPiece; | 13 using base::StringPiece; |
| 14 | 14 |
| 15 const size_t HpackEntry::kSizeOverhead = 32; | 15 const size_t HpackEntry::kSizeOverhead = 32; |
| 16 | 16 |
| 17 HpackEntry::HpackEntry(StringPiece name, | 17 HpackEntry::HpackEntry(StringPiece name, |
| 18 StringPiece value, | 18 StringPiece value, |
| 19 bool is_static, | 19 bool is_static, |
| 20 size_t insertion_index) | 20 size_t insertion_index) |
| 21 : name_(name.data(), name.size()), | 21 : name_(name.data(), name.size()), |
| 22 value_(value.data(), value.size()), | 22 value_(value.data(), value.size()), |
| 23 name_ref_(name_), | 23 name_ref_(name_), |
| 24 value_ref_(value_), | 24 value_ref_(value_), |
| 25 insertion_index_(insertion_index), | 25 insertion_index_(insertion_index), |
| 26 type_(is_static ? STATIC : DYNAMIC), | 26 type_(is_static ? STATIC : DYNAMIC), |
| 27 time_added_(0) {} | 27 time_added_(0) {} |
| 28 | 28 |
| 29 HpackEntry::HpackEntry(StringPiece name, StringPiece value) | 29 HpackEntry::HpackEntry(StringPiece name, StringPiece value) |
| 30 : name_ref_(name), value_ref_(value), insertion_index_(0), type_(LOOKUP), | 30 : name_ref_(name), |
| 31 value_ref_(value), |
| 32 insertion_index_(0), |
| 33 type_(LOOKUP), |
| 31 time_added_(0) {} | 34 time_added_(0) {} |
| 32 | 35 |
| 33 HpackEntry::HpackEntry() | 36 HpackEntry::HpackEntry() : insertion_index_(0), type_(LOOKUP), time_added_(0) {} |
| 34 : insertion_index_(0), type_(LOOKUP), time_added_(0) {} | |
| 35 | 37 |
| 36 HpackEntry::HpackEntry(const HpackEntry& other) | 38 HpackEntry::HpackEntry(const HpackEntry& other) |
| 37 : insertion_index_(other.insertion_index_), type_(other.type_), | 39 : insertion_index_(other.insertion_index_), |
| 40 type_(other.type_), |
| 38 time_added_(0) { | 41 time_added_(0) { |
| 39 if (type_ == LOOKUP) { | 42 if (type_ == LOOKUP) { |
| 40 name_ref_ = other.name_ref_; | 43 name_ref_ = other.name_ref_; |
| 41 value_ref_ = other.value_ref_; | 44 value_ref_ = other.value_ref_; |
| 42 } else { | 45 } else { |
| 43 name_ = other.name_; | 46 name_ = other.name_; |
| 44 value_ = other.value_; | 47 value_ = other.value_; |
| 45 name_ref_ = StringPiece(name_.data(), name_.size()); | 48 name_ref_ = StringPiece(name_.data(), name_.size()); |
| 46 value_ref_ = StringPiece(value_.data(), value_.size()); | 49 value_ref_ = StringPiece(value_.data(), value_.size()); |
| 47 } | 50 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 base::SizeTToString(insertion_index_) + | 82 base::SizeTToString(insertion_index_) + |
| 80 (IsStatic() ? " static" : (IsLookup() ? " lookup" : " dynamic")) + | 83 (IsStatic() ? " static" : (IsLookup() ? " lookup" : " dynamic")) + |
| 81 " }"; | 84 " }"; |
| 82 } | 85 } |
| 83 | 86 |
| 84 size_t HpackEntry::EstimateMemoryUsage() const { | 87 size_t HpackEntry::EstimateMemoryUsage() const { |
| 85 return SpdyEstimateMemoryUsage(name_) + SpdyEstimateMemoryUsage(value_); | 88 return SpdyEstimateMemoryUsage(name_) + SpdyEstimateMemoryUsage(value_); |
| 86 } | 89 } |
| 87 | 90 |
| 88 } // namespace net | 91 } // namespace net |
| OLD | NEW |