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

Unified Diff: net/log/net_log_util.cc

Issue 2791653002: Serialize and deserialize HostCache for persistence (Closed)
Patch Set: fix warning Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/dns/host_cache_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/log/net_log_util.cc
diff --git a/net/log/net_log_util.cc b/net/log/net_log_util.cc
index 85b546043c83bb470774f0730564c88eae2fe443..cc426455ccabc464e27c6d85e8f955e2910134b8 100644
--- a/net/log/net_log_util.cc
+++ b/net/log/net_log_util.cc
@@ -384,38 +384,8 @@ NET_EXPORT std::unique_ptr<base::DictionaryValue> GetNetInfo(
static_cast<int>(cache->max_entries()));
cache_info_dict->SetInteger("network_changes", cache->network_changes());
- base::ListValue* entry_list = new base::ListValue();
-
- for (const auto& pair : cache->entries()) {
- const HostCache::Key& key = pair.first;
- const HostCache::Entry& entry = pair.second;
-
- std::unique_ptr<base::DictionaryValue> entry_dict(
- new base::DictionaryValue());
-
- entry_dict->SetString("hostname", key.hostname);
- entry_dict->SetInteger("address_family",
- static_cast<int>(key.address_family));
- entry_dict->SetString("expiration",
- NetLog::TickCountToString(entry.expires()));
- entry_dict->SetInteger("ttl", entry.ttl().InMilliseconds());
- entry_dict->SetInteger("network_changes", entry.network_changes());
-
- if (entry.error() != OK) {
- entry_dict->SetInteger("error", entry.error());
- } else {
- const AddressList& addresses = entry.addresses();
- // Append all of the resolved addresses.
- base::ListValue* address_list = new base::ListValue();
- for (size_t i = 0; i < addresses.size(); ++i)
- address_list->AppendString(addresses[i].ToStringWithoutPort());
- entry_dict->Set("addresses", address_list);
- }
-
- entry_list->Append(std::move(entry_dict));
- }
-
- cache_info_dict->Set("entries", entry_list);
+ cache_info_dict->Set("entries",
+ cache->GetAsListValue(/*include_staleness=*/true));
dict->Set("cache", cache_info_dict);
net_info_dict->Set(NetInfoSourceToString(NET_INFO_HOST_RESOLVER),
std::move(dict));
« no previous file with comments | « net/dns/host_cache_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698