OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_METRICS_PROCESS_MEMORY_METRICS_EMITTER_H_ |
| 6 #define CHROME_BROWSER_METRICS_PROCESS_MEMORY_METRICS_EMITTER_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume
ntation.mojom.h" |
| 10 |
| 11 // This class asynchronously fetches memory metrics for each process, and then |
| 12 // emits UMA metrics from those metrics. |
| 13 // Each instance is self-owned, and will delete itself once it has finished |
| 14 // emitting metrics. |
| 15 // This class is an analog to MetricsMemoryDetails, but uses the resource |
| 16 // coordinator service to fetch data, rather than doing all the processing |
| 17 // manually. |
| 18 class ProcessMemoryMetricsEmitter |
| 19 : public base::RefCountedThreadSafe<ProcessMemoryMetricsEmitter> { |
| 20 public: |
| 21 ProcessMemoryMetricsEmitter(); |
| 22 |
| 23 // This must be called on the main thread of the browser process. |
| 24 void FetchAndEmitProcessMemoryMetrics(); |
| 25 |
| 26 protected: |
| 27 virtual ~ProcessMemoryMetricsEmitter(); |
| 28 |
| 29 // Virtual for testing. |
| 30 virtual void ReceivedMemoryDump( |
| 31 uint64_t dump_guid, |
| 32 bool success, |
| 33 memory_instrumentation::mojom::GlobalMemoryDumpPtr ptr); |
| 34 |
| 35 private: |
| 36 friend class base::RefCountedThreadSafe<ProcessMemoryMetricsEmitter>; |
| 37 |
| 38 memory_instrumentation::mojom::CoordinatorPtr coordinator_; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryMetricsEmitter); |
| 41 }; |
| 42 |
| 43 #endif // CHROME_BROWSER_METRICS_PROCESS_MEMORY_METRICS_EMITTER_H_ |
OLD | NEW |