Index: chrome/browser/chromeos/resource_reporter/resource_reporter.h |
diff --git a/chrome/browser/chromeos/resource_reporter/resource_reporter.h b/chrome/browser/chromeos/resource_reporter/resource_reporter.h |
index 763740a3fa2d124e4953c47a6f913d3d95d5602d..7b99bd289d78260dfc436dec4e014a167da5ce2d 100644 |
--- a/chrome/browser/chromeos/resource_reporter/resource_reporter.h |
+++ b/chrome/browser/chromeos/resource_reporter/resource_reporter.h |
@@ -14,6 +14,7 @@ |
#include "base/gtest_prod_util.h" |
#include "base/macros.h" |
+#include "base/memory/memory_coordinator_client.h" |
#include "base/memory/memory_pressure_listener.h" |
#include "base/memory/singleton.h" |
#include "base/time/time.h" |
@@ -27,7 +28,8 @@ namespace chromeos { |
// Chrome tasks and reports a weighted random sample of them via Rappor whenever |
// memory pressure is critical. The reporting is limited to once per |
// |kMinimumTimeBetweenReportsInMS|. |
-class ResourceReporter : public task_manager::TaskManagerObserver { |
+class ResourceReporter : public task_manager::TaskManagerObserver, |
+ public base::MemoryCoordinatorClient { |
public: |
// A collection of the data of a task manager's task that the ResourceReporter |
// is interested in. |
@@ -148,6 +150,9 @@ class ResourceReporter : public task_manager::TaskManagerObserver { |
// Gets the bucket in which the current system's number of CPU cores fall. |
static CpuCoresNumberRange GetCurrentSystemCpuCoresRange(); |
+ // base::MemoryCoordinatorClient implementation: |
+ void OnMemoryStateChange(base::MemoryState state) override; |
+ |
// Perform a weighted random sampling to select a task by its CPU or memory |
// usage weights so that we can record samples for them via Rappor. |
// They return nullptr if no TaskRecord has been selected. |
@@ -158,6 +163,9 @@ class ResourceReporter : public task_manager::TaskManagerObserver { |
using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel; |
void OnMemoryPressure(MemoryPressureLevel memory_pressure_level); |
+ // Records the current CPU and memory usage with UMA and Rappor. |
+ void RecordCurrentState(); |
+ |
// We'll use this to watch for memory pressure events so that we can trigger |
// Rappor sampling at at the critical memory pressure level. |
std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_; |