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

Side by Side Diff: content/browser/memory/memory_monitor_android.cc

Issue 2718963002: Drop the global memory state from memory coordinator (Closed)
Patch Set: format Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/memory/memory_monitor_android.h" 5 #include "content/browser/memory/memory_monitor_android.h"
6 6
7 #include "base/android/context_utils.h" 7 #include "base/android/context_utils.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/browser/memory/memory_coordinator_impl.h" 10 #include "content/browser/memory/memory_coordinator_impl.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const int kTrimMemoryRunningCritical = 15; 69 const int kTrimMemoryRunningCritical = 15;
70 70
71 // Called by JNI. 71 // Called by JNI.
72 static void OnTrimMemory(JNIEnv* env, 72 static void OnTrimMemory(JNIEnv* env,
73 const base::android::JavaParamRef<jclass>& jcaller, 73 const base::android::JavaParamRef<jclass>& jcaller,
74 jint level) { 74 jint level) {
75 DCHECK(level >= 0 && level <= kTrimMemoryLevelMax); 75 DCHECK(level >= 0 && level <= kTrimMemoryLevelMax);
76 auto* coordinator = MemoryCoordinatorImpl::GetInstance(); 76 auto* coordinator = MemoryCoordinatorImpl::GetInstance();
77 77
78 if (level >= kTrimMemoryRunningCritical) { 78 if (level >= kTrimMemoryRunningCritical) {
79 coordinator->ForceSetGlobalState(base::MemoryState::SUSPENDED, 79 coordinator->ForceSetMemoryCondition(MemoryCondition::WARNING,
haraken 2017/02/28 11:33:45 Shouldn't this be CRITICAL?
bashi 2017/03/02 04:01:45 Oops. Done. Thanks!
80 base::TimeDelta::FromMinutes(1)); 80 base::TimeDelta::FromMinutes(1));
81 } else if (level >= kTrimMemoryRunningLow) { 81 } else if (level >= kTrimMemoryRunningLow) {
82 coordinator->ForceSetGlobalState(base::MemoryState::THROTTLED, 82 coordinator->ForceSetMemoryCondition(MemoryCondition::CRITICAL,
haraken 2017/02/28 11:33:45 WARNING?
bashi 2017/03/02 04:01:45 Done.
83 base::TimeDelta::FromMinutes(1)); 83 base::TimeDelta::FromMinutes(1));
84 } 84 }
85 } 85 }
86 86
87 // static 87 // static
88 std::unique_ptr<MemoryMonitorAndroid> MemoryMonitorAndroid::Create() { 88 std::unique_ptr<MemoryMonitorAndroid> MemoryMonitorAndroid::Create() {
89 auto delegate = base::WrapUnique(new MemoryMonitorAndroidDelegateImpl); 89 auto delegate = base::WrapUnique(new MemoryMonitorAndroidDelegateImpl);
90 return base::WrapUnique(new MemoryMonitorAndroid(std::move(delegate))); 90 return base::WrapUnique(new MemoryMonitorAndroid(std::move(delegate)));
91 } 91 }
92 92
93 // static 93 // static
(...skipping 18 matching lines...) Expand all
112 void MemoryMonitorAndroid::GetMemoryInfo(MemoryInfo* out) { 112 void MemoryMonitorAndroid::GetMemoryInfo(MemoryInfo* out) {
113 delegate_->GetMemoryInfo(out); 113 delegate_->GetMemoryInfo(out);
114 } 114 }
115 115
116 // Implementation of a factory function defined in memory_monitor.h. 116 // Implementation of a factory function defined in memory_monitor.h.
117 std::unique_ptr<MemoryMonitor> CreateMemoryMonitor() { 117 std::unique_ptr<MemoryMonitor> CreateMemoryMonitor() {
118 return MemoryMonitorAndroid::Create(); 118 return MemoryMonitorAndroid::Create();
119 } 119 }
120 120
121 } // namespace content 121 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698