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

Unified Diff: components/memory_coordinator/child/child_memory_coordinator_impl_android.cc

Issue 2259743002: Add MemoryStateListenerAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: native Created 4 years, 3 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: components/memory_coordinator/child/child_memory_coordinator_impl_android.cc
diff --git a/components/memory_coordinator/child/child_memory_coordinator_impl_android.cc b/components/memory_coordinator/child/child_memory_coordinator_impl_android.cc
index 976994c19850e5cc3030a9461a7dc9c246a4d861..c06adacda46b54dacff2d465a713726f7b24c292 100644
--- a/components/memory_coordinator/child/child_memory_coordinator_impl_android.cc
+++ b/components/memory_coordinator/child/child_memory_coordinator_impl_android.cc
@@ -6,17 +6,25 @@
namespace memory_coordinator {
+// The same value as TRIM_MEMORY_RUNNING_CRITICAL defined in
+// ComponentCallback2
+static const int kTrimMemoryRunningCritical = 15;
+
ChildMemoryCoordinatorImplAndroid::ChildMemoryCoordinatorImplAndroid(
mojom::MemoryCoordinatorHandlePtr parent,
ChildMemoryCoordinatorDelegate* delegate)
- : ChildMemoryCoordinatorImpl(std::move(parent), delegate) {}
+ : ChildMemoryCoordinatorImpl(std::move(parent), delegate) {
+ MemoryStateListenerAndroid::Start(this);
+}
-ChildMemoryCoordinatorImplAndroid::~ChildMemoryCoordinatorImplAndroid() {}
+ChildMemoryCoordinatorImplAndroid::~ChildMemoryCoordinatorImplAndroid() {
+ MemoryStateListenerAndroid::Stop();
+}
void ChildMemoryCoordinatorImplAndroid::OnTrimMemory(int level) {
- // TODO(bashi): Compare |level| with levels defined in
- // ComponentCallbacks2 when JNI bindings are implemented.
- delegate()->OnTrimMemoryImmediately();
+ if (level >= kTrimMemoryRunningCritical) {
+ delegate()->OnTrimMemoryImmediately();
+ }
}
std::unique_ptr<ChildMemoryCoordinatorImpl> CreateChildMemoryCoordinator(

Powered by Google App Engine
This is Rietveld 408576698