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

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

Issue 1880803003: Display histograms from subprocesses in chrome://histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 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
« no previous file with comments | « base/metrics/statistics_recorder.cc ('k') | chrome/browser/metrics/subprocess_metrics_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/subprocess_metrics_provider.h
diff --git a/chrome/browser/metrics/subprocess_metrics_provider.h b/chrome/browser/metrics/subprocess_metrics_provider.h
index d47f5846a3d7438a6aebfbbd1ea8c3d9db98788e..cbdeebb6da794926f3debb0624451a6a4777f459 100644
--- a/chrome/browser/metrics/subprocess_metrics_provider.h
+++ b/chrome/browser/metrics/subprocess_metrics_provider.h
@@ -5,13 +5,14 @@
#ifndef CHROME_BROWSER_METRICS_SUBPROCESS_METRICS_PROVIDER_H_
#define CHROME_BROWSER_METRICS_SUBPROCESS_METRICS_PROVIDER_H_
+#include <map>
#include <memory>
-#include <set>
+#include <vector>
#include "base/gtest_prod_util.h"
-#include "base/id_map.h"
+#include "base/metrics/statistics_recorder.h"
#include "base/scoped_observer.h"
-#include "base/threading/thread_checker.h"
+#include "base/synchronization/lock.h"
#include "components/metrics/metrics_provider.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -24,9 +25,11 @@ class SharedPersistentMemoryAllocator;
// SubprocessMetricsProvider gathers and logs histograms stored in shared
// memory segments between processes.
-class SubprocessMetricsProvider : public metrics::MetricsProvider,
- public content::NotificationObserver,
- public content::RenderProcessHostObserver {
+class SubprocessMetricsProvider
+ : public metrics::MetricsProvider,
+ public base::StatisticsRecorder::MetricsDisplayer,
+ public content::NotificationObserver,
+ public content::RenderProcessHostObserver {
public:
SubprocessMetricsProvider();
~SubprocessMetricsProvider() override;
@@ -34,6 +37,11 @@ class SubprocessMetricsProvider : public metrics::MetricsProvider,
private:
friend class SubprocessMetricsProviderTest;
+ enum SnapshotType {
+ SNAPSHOT_DELTA,
+ SNAPSHOT_ABSOLUTE,
+ };
+
// Indicates subprocess to be monitored with unique id for later reference.
// Metrics reporting will read histograms from it and upload them to UMA.
void RegisterSubprocessAllocator(
@@ -44,9 +52,15 @@ class SubprocessMetricsProvider : public metrics::MetricsProvider,
// allocator it was using.
void DeregisterSubprocessAllocator(int id);
- // Report all histograms of a given allocator to the snapshot-manager.
+ // Report histograms of a given allocator to the snapshot-manager. If
+ // |query| is not empty, only histograms that contain that string will
+ // be recorded. If |snapshot_type| is ABSOLUTE, no delta from the previous
+ // snapshot will be done. Only one caller, the caller that uploads to UMA,
+ // is allowed to calcuate deltas because they are not independent.
void RecordHistogramSnapshotsFromAllocator(
base::HistogramSnapshotManager* snapshot_manager,
+ const std::string& query,
+ SnapshotType snapshot_type,
int id,
base::PersistentHistogramAllocator* allocator);
@@ -57,6 +71,12 @@ class SubprocessMetricsProvider : public metrics::MetricsProvider,
void RecordHistogramSnapshots(
base::HistogramSnapshotManager* snapshot_manager) override;
+ // base::StatisticsRecorder::MetricsDisplayer:
+ void WriteTitleString(std::string* output) override;
+ void WriteGraphs(const std::string& query,
+ DisplayType format,
+ std::string* output) override;
+
// content::NotificationObserver:
void Observe(int type,
const content::NotificationSource& source,
@@ -69,14 +89,16 @@ class SubprocessMetricsProvider : public metrics::MetricsProvider,
int exit_code) override;
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
- base::ThreadChecker thread_checker_;
+ // Lock for accessing objects. This is required because MetricsDisplayer is
+ // typically called by a background thread.
+ base::Lock lock_;
// Object for registing notification requests.
content::NotificationRegistrar registrar_;
// All of the shared-persistent-allocators for known sub-processes.
using AllocatorByIdMap =
- IDMap<base::PersistentHistogramAllocator, IDMapOwnPointer, int>;
+ std::map<int, std::unique_ptr<base::PersistentHistogramAllocator>>;
AllocatorByIdMap allocators_by_id_;
// Allocators that are no longer attached to a subprocess, to be released
« no previous file with comments | « base/metrics/statistics_recorder.cc ('k') | chrome/browser/metrics/subprocess_metrics_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698