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

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

Issue 253203002: Log operator code histogram on new metric log (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@api_move
Patch Set: remove incorrect NotifyOnDidCreateMetricsLog call. Created 6 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/metrics_service.h
diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h
index 1499ddf9528af66c8d55f7b588e22e02402f31a3..b1112e2eab1844df4a7c86e5ce250bbc9b5be981 100644
--- a/chrome/browser/metrics/metrics_service.h
+++ b/chrome/browser/metrics/metrics_service.h
@@ -18,9 +18,12 @@
#include "base/memory/weak_ptr.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/user_metrics.h"
+#include "base/observer_list.h"
#include "base/process/kill.h"
+#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "chrome/browser/metrics/metrics_log.h"
+#include "chrome/browser/metrics/metrics_service_observer.h"
#include "chrome/browser/metrics/tracking_synchronizer_observer.h"
#include "chrome/common/metrics/metrics_service_base.h"
#include "chrome/installer/util/google_update_settings.h"
@@ -36,6 +39,7 @@
#include "chrome/browser/chromeos/external_metrics.h"
#endif
+class ChromeBrowserMetricsServiceObserver;
class MetricsReportingScheduler;
class PrefService;
class PrefRegistrySimple;
@@ -361,6 +365,11 @@ class MetricsService
// Set up client ID, session ID, etc.
void InitializeMetricsState();
+ // Registers/unregisters |observer| to receive MetricsLog notifications.
+ void AddObserver(MetricsServiceObserver* observer);
+ void RemoveObserver(MetricsServiceObserver* observer);
+ void NotifyOnDidCreateMetricsLog();
+
// Schedule the next save of LocalState information. This is called
// automatically by the task that performs each save to schedule the next one.
void ScheduleNextStateSave();
@@ -582,7 +591,15 @@ class MetricsService
// Field trial groups that map to Chrome configuration states.
SyntheticTrialGroups synthetic_trial_groups_;
+ ObserverList<MetricsServiceObserver> observers_;
+
+ // Confirms single-threaded access to |observers_| in debug builds.
+ base::ThreadChecker thread_checker_;
+
+ friend class MetricsServiceHelper;
+
FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess);
+ FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsServiceObserver);
FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest,
PermutedEntropyCacheClearedWhenLowEntropyReset);
FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial);
@@ -590,12 +607,13 @@ class MetricsService
DISALLOW_COPY_AND_ASSIGN(MetricsService);
};
-// This class limits and documents access to the IsMetricsReportingEnabled() and
-// IsCrashReportingEnabled() methods. Since these methods are private, each user
-// has to be explicitly declared as a 'friend' below.
+// This class limits and documents access to metrics service helper methods.
+// Since these methods are private, each user has to be explicitly declared
+// as a 'friend' below.
class MetricsServiceHelper {
private:
friend bool prerender::IsOmniboxEnabled(Profile* profile);
+ friend class ::ChromeBrowserMetricsServiceObserver;
friend class ChromeRenderMessageFilter;
friend class ::CrashesDOMHandler;
friend class extensions::ExtensionDownloader;
@@ -617,6 +635,11 @@ class MetricsServiceHelper {
// IsMetricsReportingEnabled for desktop Chrome.
static bool IsCrashReportingEnabled();
+ // Registers/unregisters |observer| to receive MetricsLog notifications
+ // from metrics service.
+ static void AddMetricsServiceObserver(MetricsServiceObserver* observer);
+ static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer);
+
DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper);
};

Powered by Google App Engine
This is Rietveld 408576698