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

Unified Diff: chrome/browser/metrics/chrome_metrics_service_client.cc

Issue 287193005: [Metrics] Move non-idle notifications from MetricsService to ChromeMetricsServiceClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: break! 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
« no previous file with comments | « chrome/browser/metrics/chrome_metrics_service_client.h ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/chrome_metrics_service_client.cc
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc
index 7599f4cd0956a206c42d133bb714711104322ad9..ae8a2358f6553d4668ee8034f5fa2de2fa63a885 100644
--- a/chrome/browser/metrics/chrome_metrics_service_client.cc
+++ b/chrome/browser/metrics/chrome_metrics_service_client.cc
@@ -6,10 +6,13 @@
#include "base/logging.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/google/google_util.h"
+#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/ui/browser_otr_state.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/crash_keys.h"
+#include "content/public/browser/notification_service.h"
namespace {
@@ -33,7 +36,8 @@ metrics::SystemProfileProto::Channel AsProtobufChannel(
} // namespace
-ChromeMetricsServiceClient::ChromeMetricsServiceClient() {
+ChromeMetricsServiceClient::ChromeMetricsServiceClient() : service_(NULL) {
+ RegisterForNotifications();
}
ChromeMetricsServiceClient::~ChromeMetricsServiceClient() {
@@ -63,3 +67,50 @@ std::string ChromeMetricsServiceClient::GetVersionString() {
// TODO(asvitkine): Move over from metrics_log.cc
return std::string();
}
+
+void ChromeMetricsServiceClient::RegisterForNotifications() {
+ registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED,
+ content::NotificationService::AllBrowserContextsAndSources());
+ registrar_.Add(this, chrome::NOTIFICATION_BROWSER_CLOSED,
+ content::NotificationService::AllSources());
+ registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED,
+ content::NotificationService::AllSources());
+ registrar_.Add(this, chrome::NOTIFICATION_TAB_CLOSING,
+ content::NotificationService::AllSources());
+ registrar_.Add(this, content::NOTIFICATION_LOAD_START,
+ content::NotificationService::AllSources());
+ registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
+ content::NotificationService::AllSources());
+ registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
+ content::NotificationService::AllSources());
+ registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_HANG,
+ content::NotificationService::AllSources());
+ registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
+ content::NotificationService::AllSources());
+}
+
+void ChromeMetricsServiceClient::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ switch (type) {
+ case chrome::NOTIFICATION_BROWSER_OPENED:
+ case chrome::NOTIFICATION_BROWSER_CLOSED:
+ case chrome::NOTIFICATION_OMNIBOX_OPENED_URL:
+ case chrome::NOTIFICATION_TAB_PARENTED:
+ case chrome::NOTIFICATION_TAB_CLOSING:
+ case content::NOTIFICATION_LOAD_STOP:
+ case content::NOTIFICATION_LOAD_START:
+ case content::NOTIFICATION_RENDERER_PROCESS_CLOSED:
+ case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG:
+ // TODO(isherman): Remove this NULL check: http://crbug.com/375248
+ if (service_)
+ service_->OnApplicationNotIdle();
+ break;
+
+ default:
+ NOTREACHED();
+ }
+}
« no previous file with comments | « chrome/browser/metrics/chrome_metrics_service_client.h ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698