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

Unified Diff: content/browser/dom_storage/dom_storage_context_wrapper.cc

Issue 1953703004: Purge browser cache for dom storage in a smarter way (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dom_storage
Patch Set: Fix limit and description for UMA. 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/dom_storage/dom_storage_context_wrapper.cc
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.cc b/content/browser/dom_storage/dom_storage_context_wrapper.cc
index 96e2cee81d7cfa739884aba795f18909a534aef5..5191d68a1dff16953be65a38c0dbfc1cf3f42050 100644
--- a/content/browser/dom_storage/dom_storage_context_wrapper.cc
+++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -285,6 +285,9 @@ DOMStorageContextWrapper::DOMStorageContextWrapper(
worker_pool->GetNamedSequenceToken("dom_storage_commit"),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)
.get()));
+
+ memory_pressure_listener_.reset(new base::MemoryPressureListener(
+ base::Bind(&DOMStorageContextWrapper::OnMemoryPressure, this)));
}
DOMStorageContextWrapper::~DOMStorageContextWrapper() {}
@@ -359,6 +362,7 @@ void DOMStorageContextWrapper::SetForceKeepSessionState() {
void DOMStorageContextWrapper::Shutdown() {
DCHECK(context_.get());
mojo_state_.reset();
+ memory_pressure_listener_.reset();
context_->task_runner()->PostShutdownBlockingTask(
FROM_HERE,
DOMStorageTaskRunner::PRIMARY_SEQUENCE,
@@ -380,4 +384,17 @@ void DOMStorageContextWrapper::OpenLocalStorage(
origin, std::move(observer), std::move(request));
}
+void DOMStorageContextWrapper::OnMemoryPressure(
+ base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
+ DOMStorageContextImpl::PurgeOption purge_option =
+ DOMStorageContextImpl::PURGE_UNOPENED;
+ if (memory_pressure_level ==
+ base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
+ purge_option = DOMStorageContextImpl::PURGE_AGGRESSIVE;
+ }
+ context_->task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(&DOMStorageContextImpl::PurgeMemory, context_, purge_option));
+}
+
} // namespace content
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_wrapper.h ('k') | content/browser/dom_storage/dom_storage_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698