| OLD | NEW |
| 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 "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // The maximum level of onTrimMemory (TRIM_MEMORY_COMPLETE). | 67 // The maximum level of onTrimMemory (TRIM_MEMORY_COMPLETE). |
| 68 const int kTrimMemoryLevelMax = 0x80; | 68 const int kTrimMemoryLevelMax = 0x80; |
| 69 const int kTrimMemoryRunningLow = 0x10; | 69 const int kTrimMemoryRunningLow = 0x10; |
| 70 const int kTrimMemoryRunningCritical = 0x15; | 70 const int kTrimMemoryRunningCritical = 0x15; |
| 71 | 71 |
| 72 // Called by JNI. | 72 // Called by JNI. |
| 73 static void OnTrimMemory(JNIEnv* env, | 73 static void OnTrimMemory(JNIEnv* env, |
| 74 const base::android::JavaParamRef<jclass>& jcaller, | 74 const base::android::JavaParamRef<jclass>& jcaller, |
| 75 jint level) { | 75 jint level) { |
| 76 DCHECK(level >= 0 && level <= kTrimMemoryLevelMax); | 76 DCHECK(level >= 0 && level <= kTrimMemoryLevelMax); |
| 77 auto* coordinator = | 77 auto* coordinator = MemoryCoordinatorImpl::GetInstance(); |
| 78 static_cast<MemoryCoordinatorImpl*>(MemoryCoordinator::GetInstance()); | |
| 79 | 78 |
| 80 auto state = coordinator->GetGlobalMemoryState(); | 79 auto state = coordinator->GetGlobalMemoryState(); |
| 81 switch (state) { | 80 switch (state) { |
| 82 case base::MemoryState::NORMAL: | 81 case base::MemoryState::NORMAL: |
| 83 UMA_HISTOGRAM_ENUMERATION("Memory.Coordinator.TrimMemoryLevel.Normal", | 82 UMA_HISTOGRAM_ENUMERATION("Memory.Coordinator.TrimMemoryLevel.Normal", |
| 84 level, kTrimMemoryLevelMax); | 83 level, kTrimMemoryLevelMax); |
| 85 break; | 84 break; |
| 86 case base::MemoryState::THROTTLED: | 85 case base::MemoryState::THROTTLED: |
| 87 UMA_HISTOGRAM_ENUMERATION("Memory.Coordinator.TrimMemoryLevel.Throttled", | 86 UMA_HISTOGRAM_ENUMERATION("Memory.Coordinator.TrimMemoryLevel.Throttled", |
| 88 level, kTrimMemoryLevelMax); | 87 level, kTrimMemoryLevelMax); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 void MemoryMonitorAndroid::GetMemoryInfo(MemoryInfo* out) { | 132 void MemoryMonitorAndroid::GetMemoryInfo(MemoryInfo* out) { |
| 134 delegate_->GetMemoryInfo(out); | 133 delegate_->GetMemoryInfo(out); |
| 135 } | 134 } |
| 136 | 135 |
| 137 // Implementation of a factory function defined in memory_monitor.h. | 136 // Implementation of a factory function defined in memory_monitor.h. |
| 138 std::unique_ptr<MemoryMonitor> CreateMemoryMonitor() { | 137 std::unique_ptr<MemoryMonitor> CreateMemoryMonitor() { |
| 139 return MemoryMonitorAndroid::Create(); | 138 return MemoryMonitorAndroid::Create(); |
| 140 } | 139 } |
| 141 | 140 |
| 142 } // namespace content | 141 } // namespace content |
| OLD | NEW |