| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/spdy_header_block.h" | 5 #include "net/spdy/spdy_header_block.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "net/http/http_log_util.h" | 8 #include "net/http/http_log_util.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 | 11 |
| 12 base::Value* SpdyHeaderBlockNetLogCallback(const SpdyHeaderBlock* headers, | 12 scoped_ptr<base::Value> SpdyHeaderBlockNetLogCallback( |
| 13 NetLogCaptureMode capture_mode) { | 13 const SpdyHeaderBlock* headers, |
| 14 base::DictionaryValue* dict = new base::DictionaryValue(); | 14 NetLogCaptureMode capture_mode) { |
| 15 base::DictionaryValue* headers_dict = new base::DictionaryValue(); | 15 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 16 scoped_ptr<base::DictionaryValue> headers_dict(new base::DictionaryValue()); |
| 16 for (SpdyHeaderBlock::const_iterator it = headers->begin(); | 17 for (SpdyHeaderBlock::const_iterator it = headers->begin(); |
| 17 it != headers->end(); ++it) { | 18 it != headers->end(); ++it) { |
| 18 headers_dict->SetWithoutPathExpansion( | 19 headers_dict->SetWithoutPathExpansion( |
| 19 it->first, new base::StringValue(ElideHeaderValueForNetLog( | 20 it->first, new base::StringValue(ElideHeaderValueForNetLog( |
| 20 capture_mode, it->first, it->second))); | 21 capture_mode, it->first, it->second))); |
| 21 } | 22 } |
| 22 dict->Set("headers", headers_dict); | 23 dict->Set("headers", headers_dict.Pass()); |
| 23 return dict; | 24 return dict.Pass(); |
| 24 } | 25 } |
| 25 | 26 |
| 26 bool SpdyHeaderBlockFromNetLogParam( | 27 bool SpdyHeaderBlockFromNetLogParam( |
| 27 const base::Value* event_param, | 28 const base::Value* event_param, |
| 28 SpdyHeaderBlock* headers) { | 29 SpdyHeaderBlock* headers) { |
| 29 headers->clear(); | 30 headers->clear(); |
| 30 | 31 |
| 31 const base::DictionaryValue* dict = NULL; | 32 const base::DictionaryValue* dict = NULL; |
| 32 const base::DictionaryValue* header_dict = NULL; | 33 const base::DictionaryValue* header_dict = NULL; |
| 33 | 34 |
| 34 if (!event_param || | 35 if (!event_param || |
| 35 !event_param->GetAsDictionary(&dict) || | 36 !event_param->GetAsDictionary(&dict) || |
| 36 !dict->GetDictionary("headers", &header_dict)) { | 37 !dict->GetDictionary("headers", &header_dict)) { |
| 37 return false; | 38 return false; |
| 38 } | 39 } |
| 39 | 40 |
| 40 for (base::DictionaryValue::Iterator it(*header_dict); !it.IsAtEnd(); | 41 for (base::DictionaryValue::Iterator it(*header_dict); !it.IsAtEnd(); |
| 41 it.Advance()) { | 42 it.Advance()) { |
| 42 if (!it.value().GetAsString(&(*headers)[it.key()])) { | 43 if (!it.value().GetAsString(&(*headers)[it.key()])) { |
| 43 headers->clear(); | 44 headers->clear(); |
| 44 return false; | 45 return false; |
| 45 } | 46 } |
| 46 } | 47 } |
| 47 return true; | 48 return true; |
| 48 } | 49 } |
| 49 | 50 |
| 50 } // namespace net | 51 } // namespace net |
| OLD | NEW |