Index: net/dns/host_cache.h |
diff --git a/net/dns/host_cache.h b/net/dns/host_cache.h |
index 37cf204e3ccb653aa3d642ad560a4ed361d7d5d9..c0ba45674d3890b27bffe2db661f7d70b60b3327 100644 |
--- a/net/dns/host_cache.h |
+++ b/net/dns/host_cache.h |
@@ -8,6 +8,7 @@ |
#include <stddef.h> |
#include <functional> |
+#include <map> |
#include <memory> |
#include <string> |
#include <tuple> |
@@ -22,6 +23,10 @@ |
#include "net/base/net_export.h" |
#include "net/dns/dns_util.h" |
+namespace base { |
+class ListValue; |
+} |
+ |
namespace net { |
// Cache used by HostResolver to map hostnames to their resolved result. |
@@ -90,6 +95,11 @@ class NET_EXPORT HostCache : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
base::TimeDelta ttl, |
int network_changes); |
+ Entry(int error, |
+ const AddressList& addresses, |
+ base::TimeTicks expires, |
+ int network_changes); |
+ |
int total_hits() const { return total_hits_; } |
int stale_hits() const { return stale_hits_; } |
@@ -155,6 +165,14 @@ class NET_EXPORT HostCache : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
void ClearForHosts( |
const base::Callback<bool(const std::string&)>& host_filter); |
+ // Returns the contents of the cache represented as a base::ListValue for |
+ // serialization. |
+ std::unique_ptr<base::ListValue> GetAsListValue(bool include_staleness) const; |
+ // Takes a base::ListValue representing cache entries and stores them in the |
+ // cache, skipping any that already have entries. Returns true on success, |
+ // false on failure. |
+ bool RestoreFromListValue(base::ListValue& old_cache); |
+ |
// Returns the number of entries in the cache. |
size_t size() const; |
@@ -191,6 +209,8 @@ class NET_EXPORT HostCache : NON_EXPORTED_BASE(public base::NonThreadSafe) { |
bool caching_is_disabled() const { return max_entries_ == 0; } |
void EvictOneEntry(base::TimeTicks now); |
+ // Helper to insert an Entry into the cache. |
+ void AddEntry(const Key& key, const Entry& entry); |
// Map from hostname (presumably in lowercase canonicalized format) to |
// a resolved result entry. |