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

Unified Diff: net/dns/host_cache.h

Issue 2943143002: Add PersistenceDelegate to HostCache (Closed)
Patch Set: check for change on clear Created 3 years, 6 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 | « no previous file | net/dns/host_cache.cc » ('j') | net/dns/host_cache.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_cache.h
diff --git a/net/dns/host_cache.h b/net/dns/host_cache.h
index efc79980c104f2f4440b5c813a452c76c506445e..b3da6dafd52cde91413052b6d9ff508b69fd1ce4 100644
--- a/net/dns/host_cache.h
+++ b/net/dns/host_cache.h
@@ -124,6 +124,15 @@ class NET_EXPORT HostCache {
int stale_hits_;
};
+ // Interface for interacting with persistent storage, to be provided by the
+ // embedder. Does not include support for writes that must happen immediately.
+ class PersistenceDelegate {
+ public:
+ // Calling ScheduleWrite() signals that data has changed and should be
+ // written to persistent storage. The write might be delayed.
+ virtual void ScheduleWrite() = 0;
+ };
+
using EntryMap = std::map<Key, Entry>;
using EvictionCallback = base::Callback<void(const Key&, const Entry&)>;
@@ -158,6 +167,10 @@ class NET_EXPORT HostCache {
eviction_callback_ = callback;
}
+ void set_persistence_delegate(PersistenceDelegate* delegate) {
+ delegate_ = delegate;
+ }
+
// Empties the cache.
void clear();
@@ -196,7 +209,8 @@ class NET_EXPORT HostCache {
void RecordSet(SetOutcome outcome,
base::TimeTicks now,
const Entry* old_entry,
- const Entry& new_entry);
+ const Entry& new_entry,
+ AddressListDeltaType delta);
void RecordUpdateStale(AddressListDeltaType delta,
const EntryStaleness& stale);
void RecordLookup(LookupOutcome outcome,
@@ -219,6 +233,8 @@ class NET_EXPORT HostCache {
int network_changes_;
EvictionCallback eviction_callback_;
+ PersistenceDelegate* delegate_;
+
THREAD_CHECKER(thread_checker_);
DISALLOW_COPY_AND_ASSIGN(HostCache);
« no previous file with comments | « no previous file | net/dns/host_cache.cc » ('j') | net/dns/host_cache.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698