Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / net / spdy / hpack / hpack_entry.cc
blobaad3bba394c52c28c48f413aff032d46a553e6fa
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"
10 namespace net {
12 using base::StringPiece;
14 const size_t HpackEntry::kSizeOverhead = 32;
16 HpackEntry::HpackEntry(StringPiece name,
17 StringPiece value,
18 bool is_static,
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()),
28 insertion_index_(0),
29 type_(LOOKUP) {}
31 HpackEntry::HpackEntry() : insertion_index_(0), type_(LOOKUP) {}
33 HpackEntry::~HpackEntry() {}
35 // static
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") + " }";
48 } // namespace net