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

Unified Diff: base/chromeos/memory_pressure_observer_chromeos.cc

Issue 903273002: Update from https://crrev.com/315085 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 | « base/chromeos/memory_pressure_observer_chromeos.h ('k') | base/containers/hash_tables.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/chromeos/memory_pressure_observer_chromeos.cc
diff --git a/base/chromeos/memory_pressure_observer_chromeos.cc b/base/chromeos/memory_pressure_observer_chromeos.cc
index 8112c761e5e713e747cb015d8226e62a754c87a8..5691eb8b4ed1dbd626e85ef1ea617886396eeafd 100644
--- a/base/chromeos/memory_pressure_observer_chromeos.cc
+++ b/base/chromeos/memory_pressure_observer_chromeos.cc
@@ -5,6 +5,7 @@
#include "base/chromeos/memory_pressure_observer_chromeos.h"
#include "base/message_loop/message_loop.h"
+#include "base/metrics/histogram_macros.h"
#include "base/process/process_metrics.h"
#include "base/time/time.h"
@@ -29,6 +30,16 @@ const int kNormalMemoryPressureCriticalThresholdPercent = 90;
const int kAggressiveMemoryPressureModerateThresholdPercent = 35;
const int kAggressiveMemoryPressureCriticalThresholdPercent = 70;
+// The possible state for memory pressure level. The values should be in line
+// with values in MemoryPressureListener::MemoryPressureLevel and should be
+// updated if more memory pressure levels are introduced.
+enum MemoryPressureLevelUMA {
+ MEMORY_PRESSURE_LEVEL_NONE = 0,
+ MEMORY_PRESSURE_LEVEL_MODERATE,
+ MEMORY_PRESSURE_LEVEL_CRITICAL,
+ NUM_MEMORY_PRESSURE_LEVELS
+};
+
// Converts a |MemoryPressureThreshold| value into a used memory percentage for
// the moderate pressure event.
int GetModerateMemoryThresholdInPercent(
@@ -92,7 +103,8 @@ void MemoryPressureObserverChromeOS::ScheduleEarlyCheck() {
void MemoryPressureObserverChromeOS::StartObserving() {
timer_.Start(FROM_HERE,
TimeDelta::FromMilliseconds(kMemoryPressureIntervalMs),
- Bind(&MemoryPressureObserverChromeOS::CheckMemoryPressure,
+ Bind(&MemoryPressureObserverChromeOS::
+ CheckMemoryPressureAndRecordStatistics,
weak_ptr_factory_.GetWeakPtr()));
}
@@ -101,6 +113,28 @@ void MemoryPressureObserverChromeOS::StopObserving() {
timer_.Stop();
}
+void MemoryPressureObserverChromeOS::CheckMemoryPressureAndRecordStatistics() {
+ CheckMemoryPressure();
+
+ // Record UMA histogram statistics for the current memory pressure level.
+ MemoryPressureLevelUMA memory_pressure_level_uma(MEMORY_PRESSURE_LEVEL_NONE);
+ switch (current_memory_pressure_level_) {
+ case MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE:
+ memory_pressure_level_uma = MEMORY_PRESSURE_LEVEL_NONE;
+ break;
+ case MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE:
+ memory_pressure_level_uma = MEMORY_PRESSURE_LEVEL_MODERATE;
+ break;
+ case MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL:
+ memory_pressure_level_uma = MEMORY_PRESSURE_LEVEL_CRITICAL;
+ break;
+ }
+
+ UMA_HISTOGRAM_ENUMERATION("ChromeOS.MemoryPressureLevel",
+ memory_pressure_level_uma,
+ NUM_MEMORY_PRESSURE_LEVELS);
+}
+
void MemoryPressureObserverChromeOS::CheckMemoryPressure() {
MemoryPressureListener::MemoryPressureLevel old_pressure =
current_memory_pressure_level_;
« no previous file with comments | « base/chromeos/memory_pressure_observer_chromeos.h ('k') | base/containers/hash_tables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698