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

Unified Diff: chrome/browser/chromeos/resource_reporter/resource_reporter.h

Issue 2388933003: Make ResourceReporter a client of memory coordinator (Closed)
Patch Set: Address on afakhry's review Created 4 years, 2 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 | « no previous file | chrome/browser/chromeos/resource_reporter/resource_reporter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 405a2d799c89fe874ff55a8847b1ab9b06260d3a..f180a41faf8a6fb0a9d1b696cf5a3e8a8360252b 100644
--- a/chrome/browser/chromeos/resource_reporter/resource_reporter.h
+++ b/chrome/browser/chromeos/resource_reporter/resource_reporter.h
@@ -13,6 +13,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 "chrome/browser/task_manager/task_manager_observer.h"
@@ -26,7 +27,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.
@@ -149,6 +151,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:
+ 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.
@@ -162,6 +167,9 @@ class ResourceReporter : public task_manager::TaskManagerObserver {
using MemoryPressureLevel = base::MemoryPressureListener::MemoryPressureLevel;
void OnMemoryPressure(MemoryPressureLevel memory_pressure_level);
+ void StartRecordingCurrentState();
+ void StopRecordingCurrentState();
+
// Monitor memory pressure events.
std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
« no previous file with comments | « no previous file | chrome/browser/chromeos/resource_reporter/resource_reporter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698