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

Unified Diff: net/dns/host_cache.cc

Issue 2953483003: Add HostCachePersistenceManager for Cronet (Closed)
Patch Set: move constant 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 | « net/dns/host_cache.h ('k') | net/dns/host_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_cache.cc
diff --git a/net/dns/host_cache.cc b/net/dns/host_cache.cc
index 19a2192698fb8f85b70ad92212c4e4acc0719696..ce95a3143a3c454683978f36ee1b2221dadb71f7 100644
--- a/net/dns/host_cache.cc
+++ b/net/dns/host_cache.cc
@@ -248,6 +248,13 @@ void HostCache::OnNetworkChange() {
++network_changes_;
}
+void HostCache::set_persistence_delegate(PersistenceDelegate* delegate) {
+ // A PersistenceDelegate shouldn't be added if there already was one, and
+ // shouldn't be removed (by setting to nullptr) if it wasn't previously there.
+ DCHECK_NE(delegate == nullptr, delegate_ == nullptr);
+ delegate_ = delegate;
+}
+
void HostCache::clear() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
RecordEraseAll(ERASE_CLEAR, base::TimeTicks::Now());
@@ -288,9 +295,10 @@ void HostCache::ClearForHosts(
delegate_->ScheduleWrite();
}
-std::unique_ptr<base::ListValue> HostCache::GetAsListValue(
- bool include_staleness) const {
- std::unique_ptr<base::ListValue> entry_list(new base::ListValue());
+void HostCache::GetAsListValue(base::ListValue* entry_list,
+ bool include_staleness) const {
+ DCHECK(entry_list);
+ entry_list->Clear();
for (const auto& pair : entries_) {
const Key& key = pair.first;
@@ -332,8 +340,6 @@ std::unique_ptr<base::ListValue> HostCache::GetAsListValue(
entry_list->Append(std::move(entry_dict));
}
-
- return entry_list;
}
// TODO(mgersh): Add histograms to track failures.
« no previous file with comments | « net/dns/host_cache.h ('k') | net/dns/host_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698