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

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

Issue 2288823005: Make DOMStorageContextWrapper a client of memory coordinator (Closed)
Patch Set: Created 4 years, 4 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 | « content/browser/dom_storage/dom_storage_context_wrapper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9f52d77266e9ed750370a1f307664486fef4aa47..d646ada9754a69be1e49e2209c5dc58ff3300499 100644
--- a/content/browser/dom_storage/dom_storage_context_wrapper.cc
+++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -18,6 +18,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "components/filesystem/public/interfaces/directory.mojom.h"
#include "components/leveldb/public/interfaces/leveldb.mojom.h"
+#include "components/memory_coordinator/browser/memory_coordinator.h"
#include "content/browser/dom_storage/dom_storage_area.h"
#include "content/browser/dom_storage/dom_storage_context_impl.h"
#include "content/browser/dom_storage/dom_storage_task_runner.h"
@@ -284,8 +285,14 @@ DOMStorageContextWrapper::DOMStorageContextWrapper(
worker_pool->GetNamedSequenceToken("dom_storage_commit"),
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get()));
- memory_pressure_listener_.reset(new base::MemoryPressureListener(
- base::Bind(&DOMStorageContextWrapper::OnMemoryPressure, this)));
+ auto* memory_coordinator =
+ memory_coordinator::MemoryCoordinator::GetInstance();
+ if (memory_coordinator) {
+ memory_coordinator->RegisterClient(this);
+ } else {
+ memory_pressure_listener_.reset(new base::MemoryPressureListener(
+ base::Bind(&DOMStorageContextWrapper::OnMemoryPressure, this)));
+ }
}
DOMStorageContextWrapper::~DOMStorageContextWrapper() {}
@@ -395,4 +402,16 @@ void DOMStorageContextWrapper::OnMemoryPressure(
base::Bind(&DOMStorageContextImpl::PurgeMemory, context_, purge_option));
}
+void DOMStorageContextWrapper::OnMemoryStateChange(
+ memory_coordinator::MemoryState state) {
+ DOMStorageContextImpl::PurgeOption purge_option =
+ DOMStorageContextImpl::PURGE_UNOPENED;
+ if (state == memory_coordinator::MemoryState::SUSPENDED) {
+ 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') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698