Update V8 to version 4.7.47.
[chromium-blink-merge.git] / net / spdy / spdy_header_block.cc
blob6e72451112d96c7d982070976b2fbbd6003f6df0
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
3 // found in the LICENSE file.
5 #include "net/spdy/spdy_header_block.h"
7 #include "base/values.h"
8 #include "net/http/http_log_util.h"
10 namespace net {
12 scoped_ptr<base::Value> SpdyHeaderBlockNetLogCallback(
13 const SpdyHeaderBlock* headers,
14 NetLogCaptureMode capture_mode) {
15 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
16 base::DictionaryValue* headers_dict = new base::DictionaryValue();
17 for (SpdyHeaderBlock::const_iterator it = headers->begin();
18 it != headers->end(); ++it) {
19 headers_dict->SetWithoutPathExpansion(
20 it->first, new base::StringValue(ElideHeaderValueForNetLog(
21 capture_mode, it->first, it->second)));
23 dict->Set("headers", headers_dict);
24 return dict.Pass();
27 bool SpdyHeaderBlockFromNetLogParam(
28 const base::Value* event_param,
29 SpdyHeaderBlock* headers) {
30 headers->clear();
32 const base::DictionaryValue* dict = NULL;
33 const base::DictionaryValue* header_dict = NULL;
35 if (!event_param ||
36 !event_param->GetAsDictionary(&dict) ||
37 !dict->GetDictionary("headers", &header_dict)) {
38 return false;
41 for (base::DictionaryValue::Iterator it(*header_dict); !it.IsAtEnd();
42 it.Advance()) {
43 if (!it.value().GetAsString(&(*headers)[it.key()])) {
44 headers->clear();
45 return false;
48 return true;
51 } // namespace net