Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: net/log/net_log_util.cc

Issue 2773023003: Add more data to net-internals view of DNS cache (Closed)
Patch Set: undefined -> empty string Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/dns/host_cache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 375 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
376 std::unique_ptr<base::Value> dns_config = 376 std::unique_ptr<base::Value> dns_config =
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 386
386 base::ListValue* entry_list = new base::ListValue(); 387 base::ListValue* entry_list = new base::ListValue();
387 388
388 for (const auto& pair : cache->entries()) { 389 for (const auto& pair : cache->entries()) {
389 const HostCache::Key& key = pair.first; 390 const HostCache::Key& key = pair.first;
390 const HostCache::Entry& entry = pair.second; 391 const HostCache::Entry& entry = pair.second;
391 392
392 std::unique_ptr<base::DictionaryValue> entry_dict( 393 std::unique_ptr<base::DictionaryValue> entry_dict(
393 new base::DictionaryValue()); 394 new base::DictionaryValue());
394 395
395 entry_dict->SetString("hostname", key.hostname); 396 entry_dict->SetString("hostname", key.hostname);
396 entry_dict->SetInteger("address_family", 397 entry_dict->SetInteger("address_family",
397 static_cast<int>(key.address_family)); 398 static_cast<int>(key.address_family));
398 entry_dict->SetString("expiration", 399 entry_dict->SetString("expiration",
399 NetLog::TickCountToString(entry.expires())); 400 NetLog::TickCountToString(entry.expires()));
401 entry_dict->SetInteger("ttl", entry.ttl().InMilliseconds());
402 entry_dict->SetInteger("network_changes", entry.network_changes());
400 403
401 if (entry.error() != OK) { 404 if (entry.error() != OK) {
402 entry_dict->SetInteger("error", entry.error()); 405 entry_dict->SetInteger("error", entry.error());
403 } else { 406 } else {
404 const AddressList& addresses = entry.addresses(); 407 const AddressList& addresses = entry.addresses();
405 // Append all of the resolved addresses. 408 // Append all of the resolved addresses.
406 base::ListValue* address_list = new base::ListValue(); 409 base::ListValue* address_list = new base::ListValue();
407 for (size_t i = 0; i < addresses.size(); ++i) 410 for (size_t i = 0; i < addresses.size(); ++i)
408 address_list->AppendString(addresses[i].ToStringWithoutPort()); 411 address_list->AppendString(addresses[i].ToStringWithoutPort());
409 entry_dict->Set("addresses", address_list); 412 entry_dict->Set("addresses", address_list);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // fine, since GetRequestStateAsValue() ignores the capture mode. 532 // fine, since GetRequestStateAsValue() ignores the capture mode.
530 NetLogEntryData entry_data( 533 NetLogEntryData entry_data(
531 NetLogEventType::REQUEST_ALIVE, request->net_log().source(), 534 NetLogEventType::REQUEST_ALIVE, request->net_log().source(),
532 NetLogEventPhase::BEGIN, request->creation_time(), &callback); 535 NetLogEventPhase::BEGIN, request->creation_time(), &callback);
533 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default()); 536 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default());
534 observer->OnAddEntry(entry); 537 observer->OnAddEntry(entry);
535 } 538 }
536 } 539 }
537 540
538 } // namespace net 541 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/host_cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698