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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 host_resolver->GetDnsConfigAsValue(); | 377 host_resolver->GetDnsConfigAsValue(); |
378 if (dns_config) | 378 if (dns_config) |
379 dict->Set("dns_config", std::move(dns_config)); | 379 dict->Set("dns_config", std::move(dns_config)); |
380 | 380 |
381 base::DictionaryValue* cache_info_dict = new base::DictionaryValue(); | 381 base::DictionaryValue* cache_info_dict = new base::DictionaryValue(); |
382 | 382 |
383 cache_info_dict->SetInteger("capacity", | 383 cache_info_dict->SetInteger("capacity", |
384 static_cast<int>(cache->max_entries())); | 384 static_cast<int>(cache->max_entries())); |
385 cache_info_dict->SetInteger("network_changes", cache->network_changes()); | 385 cache_info_dict->SetInteger("network_changes", cache->network_changes()); |
386 | 386 |
387 base::ListValue* entry_list = new base::ListValue(); | 387 cache_info_dict->Set("entries", |
388 | 388 cache->GetAsListValue(/*include_staleness=*/true)); |
389 for (const auto& pair : cache->entries()) { | |
390 const HostCache::Key& key = pair.first; | |
391 const HostCache::Entry& entry = pair.second; | |
392 | |
393 std::unique_ptr<base::DictionaryValue> entry_dict( | |
394 new base::DictionaryValue()); | |
395 | |
396 entry_dict->SetString("hostname", key.hostname); | |
397 entry_dict->SetInteger("address_family", | |
398 static_cast<int>(key.address_family)); | |
399 entry_dict->SetString("expiration", | |
400 NetLog::TickCountToString(entry.expires())); | |
401 entry_dict->SetInteger("ttl", entry.ttl().InMilliseconds()); | |
402 entry_dict->SetInteger("network_changes", entry.network_changes()); | |
403 | |
404 if (entry.error() != OK) { | |
405 entry_dict->SetInteger("error", entry.error()); | |
406 } else { | |
407 const AddressList& addresses = entry.addresses(); | |
408 // Append all of the resolved addresses. | |
409 base::ListValue* address_list = new base::ListValue(); | |
410 for (size_t i = 0; i < addresses.size(); ++i) | |
411 address_list->AppendString(addresses[i].ToStringWithoutPort()); | |
412 entry_dict->Set("addresses", address_list); | |
413 } | |
414 | |
415 entry_list->Append(std::move(entry_dict)); | |
416 } | |
417 | |
418 cache_info_dict->Set("entries", entry_list); | |
419 dict->Set("cache", cache_info_dict); | 389 dict->Set("cache", cache_info_dict); |
420 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER), | 390 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER), |
421 std::move(dict)); | 391 std::move(dict)); |
422 } | 392 } |
423 } | 393 } |
424 | 394 |
425 HttpNetworkSession* http_network_session = | 395 HttpNetworkSession* http_network_session = |
426 context->http_transaction_factory()->GetSession(); | 396 context->http_transaction_factory()->GetSession(); |
427 | 397 |
428 if (info_sources & NET_INFO_SOCKET_POOL) { | 398 if (info_sources & NET_INFO_SOCKET_POOL) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 // fine, since GetRequestStateAsValue() ignores the capture mode. | 502 // fine, since GetRequestStateAsValue() ignores the capture mode. |
533 NetLogEntryData entry_data( | 503 NetLogEntryData entry_data( |
534 NetLogEventType::REQUEST_ALIVE, request->net_log().source(), | 504 NetLogEventType::REQUEST_ALIVE, request->net_log().source(), |
535 NetLogEventPhase::BEGIN, request->creation_time(), &callback); | 505 NetLogEventPhase::BEGIN, request->creation_time(), &callback); |
536 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default()); | 506 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default()); |
537 observer->OnAddEntry(entry); | 507 observer->OnAddEntry(entry); |
538 } | 508 } |
539 } | 509 } |
540 | 510 |
541 } // namespace net | 511 } // namespace net |
OLD | NEW |