| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 DCHECK(host_resolver); | 368 DCHECK(host_resolver); |
| 369 HostCache* cache = host_resolver->GetHostCache(); | 369 HostCache* cache = host_resolver->GetHostCache(); |
| 370 if (cache) { | 370 if (cache) { |
| 371 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 371 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 372 std::unique_ptr<base::Value> dns_config = | 372 std::unique_ptr<base::Value> dns_config = |
| 373 host_resolver->GetDnsConfigAsValue(); | 373 host_resolver->GetDnsConfigAsValue(); |
| 374 if (dns_config) | 374 if (dns_config) |
| 375 dict->Set("dns_config", std::move(dns_config)); | 375 dict->Set("dns_config", std::move(dns_config)); |
| 376 | 376 |
| 377 base::DictionaryValue* cache_info_dict = new base::DictionaryValue(); | 377 base::DictionaryValue* cache_info_dict = new base::DictionaryValue(); |
| 378 | |
| 379 cache_info_dict->SetInteger("capacity", | 378 cache_info_dict->SetInteger("capacity", |
| 380 static_cast<int>(cache->max_entries())); | 379 static_cast<int>(cache->max_entries())); |
| 380 cache_info_dict->Set("entries", cache->GetEntriesAsValue()); |
| 381 dict->Set("cache", cache_info_dict); |
| 381 | 382 |
| 382 base::ListValue* entry_list = new base::ListValue(); | |
| 383 | |
| 384 HostCache::EntryMap::Iterator it(cache->entries()); | |
| 385 for (; it.HasNext(); it.Advance()) { | |
| 386 const HostCache::Key& key = it.key(); | |
| 387 const HostCache::Entry& entry = it.value(); | |
| 388 | |
| 389 base::DictionaryValue* entry_dict = new base::DictionaryValue(); | |
| 390 | |
| 391 entry_dict->SetString("hostname", key.hostname); | |
| 392 entry_dict->SetInteger("address_family", | |
| 393 static_cast<int>(key.address_family)); | |
| 394 entry_dict->SetString("expiration", | |
| 395 NetLog::TickCountToString(it.expiration())); | |
| 396 | |
| 397 if (entry.error != OK) { | |
| 398 entry_dict->SetInteger("error", entry.error); | |
| 399 } else { | |
| 400 // Append all of the resolved addresses. | |
| 401 base::ListValue* address_list = new base::ListValue(); | |
| 402 for (size_t i = 0; i < entry.addrlist.size(); ++i) { | |
| 403 address_list->AppendString(entry.addrlist[i].ToStringWithoutPort()); | |
| 404 } | |
| 405 entry_dict->Set("addresses", address_list); | |
| 406 } | |
| 407 | |
| 408 entry_list->Append(entry_dict); | |
| 409 } | |
| 410 | |
| 411 cache_info_dict->Set("entries", entry_list); | |
| 412 dict->Set("cache", cache_info_dict); | |
| 413 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER), | 383 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER), |
| 414 std::move(dict)); | 384 std::move(dict)); |
| 415 } | 385 } |
| 416 } | 386 } |
| 417 | 387 |
| 418 HttpNetworkSession* http_network_session = | 388 HttpNetworkSession* http_network_session = |
| 419 context->http_transaction_factory()->GetSession(); | 389 context->http_transaction_factory()->GetSession(); |
| 420 | 390 |
| 421 if (info_sources & NET_INFO_SOCKET_POOL) { | 391 if (info_sources & NET_INFO_SOCKET_POOL) { |
| 422 net_info_dict->Set(NetInfoSourceToString(NET_INFO_SOCKET_POOL), | 392 net_info_dict->Set(NetInfoSourceToString(NET_INFO_SOCKET_POOL), |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 // fine, since GetRequestStateAsValue() ignores the capture mode. | 514 // fine, since GetRequestStateAsValue() ignores the capture mode. |
| 545 NetLog::EntryData entry_data( | 515 NetLog::EntryData entry_data( |
| 546 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), | 516 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), |
| 547 NetLog::PHASE_BEGIN, request->creation_time(), &callback); | 517 NetLog::PHASE_BEGIN, request->creation_time(), &callback); |
| 548 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); | 518 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); |
| 549 observer->OnAddEntry(entry); | 519 observer->OnAddEntry(entry); |
| 550 } | 520 } |
| 551 } | 521 } |
| 552 | 522 |
| 553 } // namespace net | 523 } // namespace net |
| OLD | NEW |