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
3 // found in the LICENSE file.
5 #include "net/spdy/hpack/hpack_entry.h"
7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h"
12 using base::StringPiece
;
14 const size_t HpackEntry::kSizeOverhead
= 32;
16 HpackEntry::HpackEntry(StringPiece name
,
19 size_t insertion_index
)
20 : name_(name
.data(), name
.size()),
21 value_(value
.data(), value
.size()),
22 insertion_index_(insertion_index
),
23 type_(is_static
? STATIC
: DYNAMIC
) {}
25 HpackEntry::HpackEntry(StringPiece name
, StringPiece value
)
26 : name_(name
.data(), name
.size()),
27 value_(value
.data(), value
.size()),
31 HpackEntry::HpackEntry() : insertion_index_(0), type_(LOOKUP
) {}
33 HpackEntry::~HpackEntry() {}
36 size_t HpackEntry::Size(StringPiece name
, StringPiece value
) {
37 return name
.size() + value
.size() + kSizeOverhead
;
39 size_t HpackEntry::Size() const {
40 return Size(name(), value());
43 std::string
HpackEntry::GetDebugString() const {
44 return "{ name: \"" + name_
+ "\", value: \"" + value_
+ "\", " +
45 (IsStatic() ? "static" : "dynamic") + " }";