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

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

Issue 1908543002: DNS: Retain stale entries in HostCache and return when requested (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, make all members of Entry private Created 4 years, 7 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/mock_host_resolver.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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 HostCache::EntryMap::Iterator it(cache->entries()); 384 for (const auto& pair : cache->entries()) {
385 for (; it.HasNext(); it.Advance()) { 385 const HostCache::Key& key = pair.first;
386 const HostCache::Key& key = it.key(); 386 const HostCache::Entry& entry = pair.second;
387 const HostCache::Entry& entry = it.value();
388 387
389 base::DictionaryValue* entry_dict = new base::DictionaryValue(); 388 base::DictionaryValue* entry_dict = new base::DictionaryValue();
390 389
391 entry_dict->SetString("hostname", key.hostname); 390 entry_dict->SetString("hostname", key.hostname);
392 entry_dict->SetInteger("address_family", 391 entry_dict->SetInteger("address_family",
393 static_cast<int>(key.address_family)); 392 static_cast<int>(key.address_family));
394 entry_dict->SetString("expiration", 393 entry_dict->SetString("expiration",
395 NetLog::TickCountToString(it.expiration())); 394 NetLog::TickCountToString(entry.expires()));
396 395
397 if (entry.error != OK) { 396 if (entry.error() != OK) {
398 entry_dict->SetInteger("error", entry.error); 397 entry_dict->SetInteger("error", entry.error());
399 } else { 398 } else {
399 const AddressList& addresses = entry.addresses();
400 // Append all of the resolved addresses. 400 // Append all of the resolved addresses.
401 base::ListValue* address_list = new base::ListValue(); 401 base::ListValue* address_list = new base::ListValue();
402 for (size_t i = 0; i < entry.addrlist.size(); ++i) { 402 for (size_t i = 0; i < addresses.size(); ++i)
403 address_list->AppendString(entry.addrlist[i].ToStringWithoutPort()); 403 address_list->AppendString(addresses[i].ToStringWithoutPort());
404 }
405 entry_dict->Set("addresses", address_list); 404 entry_dict->Set("addresses", address_list);
406 } 405 }
407 406
408 entry_list->Append(entry_dict); 407 entry_list->Append(entry_dict);
409 } 408 }
410 409
411 cache_info_dict->Set("entries", entry_list); 410 cache_info_dict->Set("entries", entry_list);
412 dict->Set("cache", cache_info_dict); 411 dict->Set("cache", cache_info_dict);
413 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER), 412 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER),
414 std::move(dict)); 413 std::move(dict));
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 // fine, since GetRequestStateAsValue() ignores the capture mode. 543 // fine, since GetRequestStateAsValue() ignores the capture mode.
545 NetLog::EntryData entry_data( 544 NetLog::EntryData entry_data(
546 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), 545 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(),
547 NetLog::PHASE_BEGIN, request->creation_time(), &callback); 546 NetLog::PHASE_BEGIN, request->creation_time(), &callback);
548 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); 547 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default());
549 observer->OnAddEntry(entry); 548 observer->OnAddEntry(entry);
550 } 549 }
551 } 550 }
552 551
553 } // namespace net 552 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/mock_host_resolver.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698