| 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_entry.h" | 5 #include "net/spdy/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/hpack_string_util.h" | 9 #include "net/spdy/hpack_string_util.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 insertion_index_(insertion_index), | 23 insertion_index_(insertion_index), |
| 24 state_(0), | |
| 25 type_(is_static ? STATIC : DYNAMIC) { | 24 type_(is_static ? STATIC : DYNAMIC) { |
| 26 } | 25 } |
| 27 | 26 |
| 28 HpackEntry::HpackEntry(StringPiece name, StringPiece value) | 27 HpackEntry::HpackEntry(StringPiece name, StringPiece value) |
| 29 : name_(name.data(), name.size()), | 28 : name_(name.data(), name.size()), |
| 30 value_(value.data(), value.size()), | 29 value_(value.data(), value.size()), |
| 31 insertion_index_(0), | 30 insertion_index_(0), |
| 32 state_(0), | |
| 33 type_(LOOKUP) { | 31 type_(LOOKUP) { |
| 34 } | 32 } |
| 35 | 33 |
| 36 HpackEntry::HpackEntry() | 34 HpackEntry::HpackEntry() |
| 37 : insertion_index_(0), | 35 : insertion_index_(0), |
| 38 state_(0), | |
| 39 type_(LOOKUP) { | 36 type_(LOOKUP) { |
| 40 } | 37 } |
| 41 | 38 |
| 42 HpackEntry::~HpackEntry() {} | 39 HpackEntry::~HpackEntry() {} |
| 43 | 40 |
| 44 // static | 41 // static |
| 45 size_t HpackEntry::Size(StringPiece name, StringPiece value) { | 42 size_t HpackEntry::Size(StringPiece name, StringPiece value) { |
| 46 return name.size() + value.size() + kSizeOverhead; | 43 return name.size() + value.size() + kSizeOverhead; |
| 47 } | 44 } |
| 48 size_t HpackEntry::Size() const { | 45 size_t HpackEntry::Size() const { |
| 49 return Size(name(), value()); | 46 return Size(name(), value()); |
| 50 } | 47 } |
| 51 | 48 |
| 52 std::string HpackEntry::GetDebugString() const { | 49 std::string HpackEntry::GetDebugString() const { |
| 53 return "{ name: \"" + name_ + | 50 return "{ name: \"" + name_ + |
| 54 "\", value: \"" + value_ + | 51 "\", value: \"" + value_ + |
| 55 "\", " + (IsStatic() ? "static" : "dynamic") + | 52 "\", " + (IsStatic() ? "static" : "dynamic") + " }"; |
| 56 ", state: " + base::IntToString(state_) + " }"; | |
| 57 } | 53 } |
| 58 | 54 |
| 59 } // namespace net | 55 } // namespace net |
| OLD | NEW |