| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <ios> | 8 #include <ios> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 231 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 232 base::DictionaryValue* headers_dict = new base::DictionaryValue(); | 232 base::DictionaryValue* headers_dict = new base::DictionaryValue(); |
| 233 for (SpdyHeaderBlock::const_iterator it = headers->begin(); | 233 for (SpdyHeaderBlock::const_iterator it = headers->begin(); |
| 234 it != headers->end(); ++it) { | 234 it != headers->end(); ++it) { |
| 235 headers_dict->SetWithoutPathExpansion( | 235 headers_dict->SetWithoutPathExpansion( |
| 236 it->first.as_string(), | 236 it->first.as_string(), |
| 237 new base::StringValue(ElideHeaderValueForNetLog( | 237 new base::StringValue(ElideHeaderValueForNetLog( |
| 238 capture_mode, it->first.as_string(), it->second.as_string()))); | 238 capture_mode, it->first.as_string(), it->second.as_string()))); |
| 239 } | 239 } |
| 240 dict->Set("headers", headers_dict); | 240 dict->Set("headers", headers_dict); |
| 241 return dict.Pass(); | 241 return std::move(dict); |
| 242 } | 242 } |
| 243 | 243 |
| 244 bool SpdyHeaderBlockFromNetLogParam( | 244 bool SpdyHeaderBlockFromNetLogParam( |
| 245 const base::Value* event_param, | 245 const base::Value* event_param, |
| 246 SpdyHeaderBlock* headers) { | 246 SpdyHeaderBlock* headers) { |
| 247 headers->clear(); | 247 headers->clear(); |
| 248 | 248 |
| 249 const base::DictionaryValue* dict = NULL; | 249 const base::DictionaryValue* dict = NULL; |
| 250 const base::DictionaryValue* header_dict = NULL; | 250 const base::DictionaryValue* header_dict = NULL; |
| 251 | 251 |
| 252 if (!event_param || | 252 if (!event_param || |
| 253 !event_param->GetAsDictionary(&dict) || | 253 !event_param->GetAsDictionary(&dict) || |
| 254 !dict->GetDictionary("headers", &header_dict)) { | 254 !dict->GetDictionary("headers", &header_dict)) { |
| 255 return false; | 255 return false; |
| 256 } | 256 } |
| 257 | 257 |
| 258 for (base::DictionaryValue::Iterator it(*header_dict); !it.IsAtEnd(); | 258 for (base::DictionaryValue::Iterator it(*header_dict); !it.IsAtEnd(); |
| 259 it.Advance()) { | 259 it.Advance()) { |
| 260 string value; | 260 string value; |
| 261 if (!it.value().GetAsString(&value)) { | 261 if (!it.value().GetAsString(&value)) { |
| 262 headers->clear(); | 262 headers->clear(); |
| 263 return false; | 263 return false; |
| 264 } | 264 } |
| 265 (*headers)[it.key()] = value; | 265 (*headers)[it.key()] = value; |
| 266 } | 266 } |
| 267 return true; | 267 return true; |
| 268 } | 268 } |
| 269 | 269 |
| 270 } // namespace net | 270 } // namespace net |
| OLD | NEW |