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

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, 8 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/subprocess_metrics_provider.h
diff --git a/chrome/browser/metrics/subprocess_metrics_provider.h b/chrome/browser/metrics/subprocess_metrics_provider.h
index d47f5846a3d7438a6aebfbbd1ea8c3d9db98788e..2690aca2766bbbd8e96bee13f72089a72b87461f 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"
Ilya Sherman 2016/04/25 20:53:15 On the subject of locks: I've now researched how t
bcwhite 2016/04/26 19:51:54 I'll look into it. There are two calls, one from
Ilya Sherman 2016/04/26 20:21:58 Which base/ code are you thinking of, specifically
bcwhite 2016/04/26 21:03:30 base/metrics/statistics_recorder, which is the com
#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;
@@ -44,9 +47,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 |absolute| is true, 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,
+ bool absolute,
int id,
base::PersistentHistogramAllocator* allocator);
@@ -57,6 +66,12 @@ class SubprocessMetricsProvider : public metrics::MetricsProvider,
void RecordHistogramSnapshots(
base::HistogramSnapshotManager* snapshot_manager) override;
+ // base::StatisticsRecorder::MetricsDisplay:
Ilya Sherman 2016/04/25 20:53:15 nit: displayer
bcwhite 2016/04/26 19:51:54 Done.
+ 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 +84,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 MetricsDisplay is
Ilya Sherman 2016/04/25 20:53:15 nit: displayer
bcwhite 2016/04/26 19:51:54 Done.
+ // 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>>;
Ilya Sherman 2016/04/25 20:53:15 This change seems unrelated to the rest of the CL.
bcwhite 2016/04/26 19:51:54 IDmap allows access only from a single thread. I
AllocatorByIdMap allocators_by_id_;
// Allocators that are no longer attached to a subprocess, to be released

Powered by Google App Engine
This is Rietveld 408576698