Index: chrome/browser/metrics/chrome_metrics_service_client.h |
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.h b/chrome/browser/metrics/chrome_metrics_service_client.h |
index 4e11165e718e8a279895f1288e46769f484860a8..9b0c86881102203fea8c28275f1516a028ea93ed 100644 |
--- a/chrome/browser/metrics/chrome_metrics_service_client.h |
+++ b/chrome/browser/metrics/chrome_metrics_service_client.h |
@@ -8,11 +8,17 @@ |
#include <string> |
#include "base/basictypes.h" |
+#include "base/threading/thread_checker.h" |
#include "components/metrics/metrics_service_client.h" |
+#include "content/public/browser/notification_observer.h" |
+#include "content/public/browser/notification_registrar.h" |
+ |
+class MetricsService; |
// ChromeMetricsServiceClient provides an implementation of MetricsServiceClient |
// that depends on chrome/. |
-class ChromeMetricsServiceClient : public metrics::MetricsServiceClient { |
+class ChromeMetricsServiceClient : public metrics::MetricsServiceClient, |
+ public content::NotificationObserver { |
public: |
ChromeMetricsServiceClient(); |
virtual ~ChromeMetricsServiceClient(); |
@@ -25,7 +31,29 @@ class ChromeMetricsServiceClient : public metrics::MetricsServiceClient { |
virtual metrics::SystemProfileProto::Channel GetChannel() OVERRIDE; |
virtual std::string GetVersionString() OVERRIDE; |
+ // Stores a weak pointer to the given |service|. |
+ // TODO(isherman): Fix the memory ownership model so that this method is not |
+ // needed: http://crbug.com/375248 |
+ void set_service(MetricsService* service) { service_ = service; } |
+ |
private: |
+ // Registers |this| as an observer for notifications which indicate that a |
+ // user is performing work. This is useful to allow some features to sleep, |
+ // until the machine becomes active, such as precluding UMA uploads unless |
+ // there was recent activity. |
+ void RegisterForNotifications(); |
+ |
+ // content::NotificationObserver: |
+ virtual void Observe(int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) OVERRIDE; |
+ |
+ // The MetricsService that |this| is a client of. Weak pointer. |
+ MetricsService* service_; |
+ |
+ content::NotificationRegistrar registrar_; |
+ base::ThreadChecker thread_checker_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); |
}; |