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

Unified Diff: chrome/browser/metrics/process_memory_metrics_emitter.h

Issue 2876693002: Emit UMAs for metrics from memory instrumentation service. (Closed)
Patch Set: comments from ssid. Created 3 years, 7 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
Index: chrome/browser/metrics/process_memory_metrics_emitter.h
diff --git a/chrome/browser/metrics/process_memory_metrics_emitter.h b/chrome/browser/metrics/process_memory_metrics_emitter.h
new file mode 100644
index 0000000000000000000000000000000000000000..9edcd027bd2a44158770d4861e494ce59b72d110
--- /dev/null
+++ b/chrome/browser/metrics/process_memory_metrics_emitter.h
@@ -0,0 +1,43 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_METRICS_PROCESS_MEMORY_METRICS_EMITTER_H_
+#define CHROME_BROWSER_METRICS_PROCESS_MEMORY_METRICS_EMITTER_H_
+
+#include "base/memory/ref_counted.h"
+#include "services/resource_coordinator/public/interfaces/memory/memory_instrumentation.mojom.h"
+
+// This class asynchronously fetches memory metrics for each process, and then
+// emits UMA metrics from those metrics.
+// Each instance is self-owned, and will delete itself once it has finished
+// emitting metrics.
+// This class is an analog to MetricsMemoryDetails, but uses the resource
+// coordinator service to fetch data, rather than doing all the processing
+// manually.
+class ProcessMemoryMetricsEmitter
+ : public base::RefCountedThreadSafe<ProcessMemoryMetricsEmitter> {
+ public:
+ ProcessMemoryMetricsEmitter();
+
+ // This must be called on the main thread of the browser process.
+ void FetchAndEmitProcessMemoryMetrics();
+
+ protected:
+ virtual ~ProcessMemoryMetricsEmitter();
+
+ // Virtual for testing.
+ virtual void ReceivedMemoryDump(
+ uint64_t dump_guid,
+ bool success,
+ memory_instrumentation::mojom::GlobalMemoryDumpPtr ptr);
+
+ private:
+ friend class base::RefCountedThreadSafe<ProcessMemoryMetricsEmitter>;
+
+ memory_instrumentation::mojom::CoordinatorPtr coordinator_;
+
+ DISALLOW_COPY_AND_ASSIGN(ProcessMemoryMetricsEmitter);
+};
+
+#endif // CHROME_BROWSER_METRICS_PROCESS_MEMORY_METRICS_EMITTER_H_

Powered by Google App Engine
This is Rietveld 408576698