Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / net / spdy / spdy_header_block.cc
blob92c6234b9446d885c5160ade6a423a58e354e130
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 base::Value* SpdyHeaderBlockNetLogCallback(const SpdyHeaderBlock* headers,
13 NetLogCaptureMode capture_mode) {
14 base::DictionaryValue* dict = new base::DictionaryValue();
15 base::DictionaryValue* headers_dict = new base::DictionaryValue();
16 for (SpdyHeaderBlock::const_iterator it = headers->begin();
17 it != headers->end(); ++it) {
18 headers_dict->SetWithoutPathExpansion(
19 it->first, new base::StringValue(ElideHeaderValueForNetLog(
20 capture_mode, it->first, it->second)));
22 dict->Set("headers", headers_dict);
23 return dict;
26 bool SpdyHeaderBlockFromNetLogParam(
27 const base::Value* event_param,
28 SpdyHeaderBlock* headers) {
29 headers->clear();
31 const base::DictionaryValue* dict = NULL;
32 const base::DictionaryValue* header_dict = NULL;
34 if (!event_param ||
35 !event_param->GetAsDictionary(&dict) ||
36 !dict->GetDictionary("headers", &header_dict)) {
37 return false;
40 for (base::DictionaryValue::Iterator it(*header_dict); !it.IsAtEnd();
41 it.Advance()) {
42 if (!it.value().GetAsString(&(*headers)[it.key()])) {
43 headers->clear();
44 return false;
47 return true;
50 } // namespace net