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/core/spdy_header_block.h" | 5 #include "net/spdy/core/spdy_header_block.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "net/base/arena.h" | 16 #include "net/base/arena.h" |
16 #include "net/http/http_log_util.h" | 17 #include "net/http/http_log_util.h" |
17 #include "net/log/net_log_capture_mode.h" | 18 #include "net/log/net_log_capture_mode.h" |
18 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" | 19 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" |
19 #include "net/spdy/platform/api/spdy_string_utils.h" | 20 #include "net/spdy/platform/api/spdy_string_utils.h" |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 namespace { | 23 namespace { |
23 | 24 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 SpdyHeaderBlock::Storage* SpdyHeaderBlock::GetStorage() { | 324 SpdyHeaderBlock::Storage* SpdyHeaderBlock::GetStorage() { |
324 if (!storage_) { | 325 if (!storage_) { |
325 storage_.reset(new Storage); | 326 storage_.reset(new Storage); |
326 } | 327 } |
327 return storage_.get(); | 328 return storage_.get(); |
328 } | 329 } |
329 | 330 |
330 std::unique_ptr<base::Value> SpdyHeaderBlockNetLogCallback( | 331 std::unique_ptr<base::Value> SpdyHeaderBlockNetLogCallback( |
331 const SpdyHeaderBlock* headers, | 332 const SpdyHeaderBlock* headers, |
332 NetLogCaptureMode capture_mode) { | 333 NetLogCaptureMode capture_mode) { |
333 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 334 auto dict = base::MakeUnique<base::DictionaryValue>(); |
334 base::DictionaryValue* headers_dict = new base::DictionaryValue(); | 335 auto headers_dict = base::MakeUnique<base::DictionaryValue>(); |
335 for (SpdyHeaderBlock::const_iterator it = headers->begin(); | 336 for (SpdyHeaderBlock::const_iterator it = headers->begin(); |
336 it != headers->end(); ++it) { | 337 it != headers->end(); ++it) { |
337 headers_dict->SetWithoutPathExpansion( | 338 headers_dict->SetStringWithoutPathExpansion( |
338 it->first.as_string(), | 339 it->first.as_string(), |
339 new base::Value(ElideHeaderValueForNetLog( | 340 ElideHeaderValueForNetLog(capture_mode, it->first.as_string(), |
340 capture_mode, it->first.as_string(), it->second.as_string()))); | 341 it->second.as_string())); |
341 } | 342 } |
342 dict->Set("headers", headers_dict); | 343 dict->Set("headers", std::move(headers_dict)); |
343 return std::move(dict); | 344 return std::move(dict); |
344 } | 345 } |
345 | 346 |
346 bool SpdyHeaderBlockFromNetLogParam( | 347 bool SpdyHeaderBlockFromNetLogParam( |
347 const base::Value* event_param, | 348 const base::Value* event_param, |
348 SpdyHeaderBlock* headers) { | 349 SpdyHeaderBlock* headers) { |
349 headers->clear(); | 350 headers->clear(); |
350 | 351 |
351 const base::DictionaryValue* dict = NULL; | 352 const base::DictionaryValue* dict = NULL; |
352 const base::DictionaryValue* header_dict = NULL; | 353 const base::DictionaryValue* header_dict = NULL; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 for (++it; it != fragments.end(); ++it) { | 391 for (++it; it != fragments.end(); ++it) { |
391 memcpy(dst, separator.data(), separator.size()); | 392 memcpy(dst, separator.data(), separator.size()); |
392 dst += separator.size(); | 393 dst += separator.size(); |
393 memcpy(dst, it->data(), it->size()); | 394 memcpy(dst, it->data(), it->size()); |
394 dst += it->size(); | 395 dst += it->size(); |
395 } | 396 } |
396 return dst - original_dst; | 397 return dst - original_dst; |
397 } | 398 } |
398 | 399 |
399 } // namespace net | 400 } // namespace net |
OLD | NEW |