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

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: sync'ed to head, added test. 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..a54b69b71d692570afd658beabdc7c1f05e630de 100644
--- a/chrome/browser/metrics/metrics_service.h
+++ b/chrome/browser/metrics/metrics_service.h
@@ -18,6 +18,7 @@
#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/time/time.h"
#include "chrome/browser/metrics/metrics_log.h"
@@ -36,6 +37,7 @@
#include "chrome/browser/chromeos/external_metrics.h"
#endif
+class ChromeBrowserMetricsLogObserver;
class MetricsReportingScheduler;
class PrefService;
class PrefRegistrySimple;
@@ -108,6 +110,19 @@ struct SyntheticTrialGroup {
SyntheticTrialGroup(uint32 trial, uint32 group);
};
+class MetricsLogObserver {
Ilya Sherman 2014/05/07 01:03:16 nit: I think "MetricsServiceObserver" is more accu
bolian 2014/05/07 02:20:26 Done.
+ public:
+ // Will be called when a new MetricsLog is created.
+ virtual void OnNewMetricsLog() = 0;
Ilya Sherman 2014/05/07 01:03:16 nit: "OnDidCreateMetricsLog()" or something else i
bolian 2014/05/07 02:20:26 Done.
+
+ protected:
+ MetricsLogObserver() {}
+ virtual ~MetricsLogObserver() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MetricsLogObserver);
+};
+
class MetricsService
: public chrome_browser_metrics::TrackingSynchronizerObserver,
public content::BrowserChildProcessObserver,
@@ -361,6 +376,11 @@ class MetricsService
// Set up client ID, session ID, etc.
void InitializeMetricsState();
+ // Registers/Unregsiters |observer| to receive MetricsLog notifications.
Ilya Sherman 2014/05/07 01:03:16 nit: "Un" -> "un"
bolian 2014/05/07 02:20:26 Done.
+ void AddMetricsLogObserver(MetricsLogObserver* observer);
+ void RemoveMetricsLogObserver(MetricsLogObserver* observer);
+ void NotifyOnNewMetricsLog();
+
// 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,21 +602,28 @@ class MetricsService
// Field trial groups that map to Chrome configuration states.
SyntheticTrialGroups synthetic_trial_groups_;
+ // Observers of MetricsLog.
+ ObserverList<MetricsLogObserver> metrics_log_observers_;
+
+ friend class MetricsServiceHelper;
+
FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess);
FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest,
PermutedEntropyCacheClearedWhenLowEntropyReset);
FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial);
+ FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsLogObserver);
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 ChromeRenderMessageFilter;
+ friend class ::ChromeBrowserMetricsLogObserver;
Ilya Sherman 2014/05/07 01:03:16 nit: Alphabetically, this should come before line
bolian 2014/05/07 02:20:26 Done.
friend class ::CrashesDOMHandler;
friend class extensions::ExtensionDownloader;
friend class extensions::ManifestFetchData;
@@ -617,6 +644,11 @@ class MetricsServiceHelper {
// IsMetricsReportingEnabled for desktop Chrome.
static bool IsCrashReportingEnabled();
+ // Registers/Unregsiters |observer| to receive MetricsLog notifications
+ // from metric service.
+ static void AddMetricsLogObserver(MetricsLogObserver* observer);
+ static void RemoveMetricsLogObserver(MetricsLogObserver* observer);
+
DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper);
};

Powered by Google App Engine
This is Rietveld 408576698