OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/log/net_log_util.h" | 5 #include "net/log/net_log_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 cache_info_dict->SetInteger("capacity", | 379 cache_info_dict->SetInteger("capacity", |
380 static_cast<int>(cache->max_entries())); | 380 static_cast<int>(cache->max_entries())); |
381 | 381 |
382 base::ListValue* entry_list = new base::ListValue(); | 382 base::ListValue* entry_list = new base::ListValue(); |
383 | 383 |
384 for (const auto& pair : cache->entries()) { | 384 for (const auto& pair : cache->entries()) { |
385 const HostCache::Key& key = pair.first; | 385 const HostCache::Key& key = pair.first; |
386 const HostCache::Entry& entry = pair.second; | 386 const HostCache::Entry& entry = pair.second; |
387 | 387 |
388 base::DictionaryValue* entry_dict = new base::DictionaryValue(); | 388 std::unique_ptr<base::DictionaryValue> entry_dict( |
| 389 new base::DictionaryValue()); |
389 | 390 |
390 entry_dict->SetString("hostname", key.hostname); | 391 entry_dict->SetString("hostname", key.hostname); |
391 entry_dict->SetInteger("address_family", | 392 entry_dict->SetInteger("address_family", |
392 static_cast<int>(key.address_family)); | 393 static_cast<int>(key.address_family)); |
393 entry_dict->SetString("expiration", | 394 entry_dict->SetString("expiration", |
394 NetLog::TickCountToString(entry.expires())); | 395 NetLog::TickCountToString(entry.expires())); |
395 | 396 |
396 if (entry.error() != OK) { | 397 if (entry.error() != OK) { |
397 entry_dict->SetInteger("error", entry.error()); | 398 entry_dict->SetInteger("error", entry.error()); |
398 } else { | 399 } else { |
399 const AddressList& addresses = entry.addresses(); | 400 const AddressList& addresses = entry.addresses(); |
400 // Append all of the resolved addresses. | 401 // Append all of the resolved addresses. |
401 base::ListValue* address_list = new base::ListValue(); | 402 base::ListValue* address_list = new base::ListValue(); |
402 for (size_t i = 0; i < addresses.size(); ++i) | 403 for (size_t i = 0; i < addresses.size(); ++i) |
403 address_list->AppendString(addresses[i].ToStringWithoutPort()); | 404 address_list->AppendString(addresses[i].ToStringWithoutPort()); |
404 entry_dict->Set("addresses", address_list); | 405 entry_dict->Set("addresses", address_list); |
405 } | 406 } |
406 | 407 |
407 entry_list->Append(entry_dict); | 408 entry_list->Append(std::move(entry_dict)); |
408 } | 409 } |
409 | 410 |
410 cache_info_dict->Set("entries", entry_list); | 411 cache_info_dict->Set("entries", entry_list); |
411 dict->Set("cache", cache_info_dict); | 412 dict->Set("cache", cache_info_dict); |
412 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER), | 413 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER), |
413 std::move(dict)); | 414 std::move(dict)); |
414 } | 415 } |
415 } | 416 } |
416 | 417 |
417 HttpNetworkSession* http_network_session = | 418 HttpNetworkSession* http_network_session = |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 // fine, since GetRequestStateAsValue() ignores the capture mode. | 541 // fine, since GetRequestStateAsValue() ignores the capture mode. |
541 NetLog::EntryData entry_data( | 542 NetLog::EntryData entry_data( |
542 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), | 543 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), |
543 NetLog::PHASE_BEGIN, request->creation_time(), &callback); | 544 NetLog::PHASE_BEGIN, request->creation_time(), &callback); |
544 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); | 545 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); |
545 observer->OnAddEntry(entry); | 546 observer->OnAddEntry(entry); |
546 } | 547 } |
547 } | 548 } |
548 | 549 |
549 } // namespace net | 550 } // namespace net |
OLD | NEW |