summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics/metrics_service.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-01 18:16:56 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-01 18:16:56 +0000
commitbfd04a62ce610d7bb61dbb78811dccbed23589b7 (patch)
tree70bb228c0f00ba1c12c584efd569daccf96b4026 /chrome/browser/metrics/metrics_service.cc
parenta814d863440f0a154a7299f2d8b440f405c7700e (diff)
downloadchromium_src-bfd04a62ce610d7bb61dbb78811dccbed23589b7.zip
chromium_src-bfd04a62ce610d7bb61dbb78811dccbed23589b7.tar.gz
chromium_src-bfd04a62ce610d7bb61dbb78811dccbed23589b7.tar.bz2
Remove most header file dependencies on the notification type list. It is
really painful to add more types, since lots of headers include the notification service to derive from the notification observer. This splits that out, so much less of the project should end up including notification_types.h ---Paths modified but not in any changelist: Review URL: http://codereview.chromium.org/19744 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics/metrics_service.cc')
-rw-r--r--chrome/browser/metrics/metrics_service.cc94
1 files changed, 51 insertions, 43 deletions
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index f2b3323..f3822e8 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -178,6 +178,7 @@
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/libxml_utils.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/installer/util/google_update_settings.h"
@@ -426,58 +427,58 @@ void MetricsService::Observe(NotificationType type,
if (!CanLogNotification(type, source, details))
return;
- switch (type) {
- case NOTIFY_USER_ACTION:
+ switch (type.value) {
+ case NotificationType::USER_ACTION:
current_log_->RecordUserAction(*Details<const wchar_t*>(details).ptr());
break;
- case NOTIFY_BROWSER_OPENED:
- case NOTIFY_BROWSER_CLOSED:
+ case NotificationType::BROWSER_OPENED:
+ case NotificationType::BROWSER_CLOSED:
LogWindowChange(type, source, details);
break;
- case NOTIFY_TAB_PARENTED:
- case NOTIFY_TAB_CLOSING:
+ case NotificationType::TAB_PARENTED:
+ case NotificationType::TAB_CLOSING:
LogWindowChange(type, source, details);
break;
- case NOTIFY_LOAD_STOP:
+ case NotificationType::LOAD_STOP:
LogLoadComplete(type, source, details);
break;
- case NOTIFY_LOAD_START:
+ case NotificationType::LOAD_START:
LogLoadStarted();
break;
- case NOTIFY_RENDERER_PROCESS_TERMINATED:
+ case NotificationType::RENDERER_PROCESS_TERMINATED:
if (!*Details<bool>(details).ptr())
LogRendererCrash();
break;
- case NOTIFY_RENDERER_PROCESS_HANG:
+ case NotificationType::RENDERER_PROCESS_HANG:
LogRendererHang();
break;
- case NOTIFY_RENDERER_PROCESS_IN_SBOX:
+ case NotificationType::RENDERER_PROCESS_IN_SBOX:
LogRendererInSandbox(*Details<bool>(details).ptr());
break;
- case NOTIFY_PLUGIN_PROCESS_HOST_CONNECTED:
- case NOTIFY_PLUGIN_PROCESS_CRASHED:
- case NOTIFY_PLUGIN_INSTANCE_CREATED:
+ case NotificationType::PLUGIN_PROCESS_HOST_CONNECTED:
+ case NotificationType::PLUGIN_PROCESS_CRASHED:
+ case NotificationType::PLUGIN_INSTANCE_CREATED:
LogPluginChange(type, source, details);
break;
- case TEMPLATE_URL_MODEL_LOADED:
+ case NotificationType::TEMPLATE_URL_MODEL_LOADED:
LogKeywords(Source<TemplateURLModel>(source).ptr());
break;
- case NOTIFY_OMNIBOX_OPENED_URL:
+ case NotificationType::OMNIBOX_OPENED_URL:
current_log_->RecordOmniboxOpenedURL(
*Details<AutocompleteLog>(details).ptr());
break;
- case NOTIFY_BOOKMARK_MODEL_LOADED:
+ case NotificationType::BOOKMARK_MODEL_LOADED:
LogBookmarks(Source<Profile>(source)->GetBookmarkModel());
break;
@@ -706,24 +707,31 @@ void MetricsService::StopRecording(MetricsLog** log) {
}
void MetricsService::ListenerRegistration(bool start_listening) {
- AddOrRemoveObserver(this, NOTIFY_BROWSER_OPENED, start_listening);
- AddOrRemoveObserver(this, NOTIFY_BROWSER_CLOSED, start_listening);
- AddOrRemoveObserver(this, NOTIFY_USER_ACTION, start_listening);
- AddOrRemoveObserver(this, NOTIFY_TAB_PARENTED, start_listening);
- AddOrRemoveObserver(this, NOTIFY_TAB_CLOSING, start_listening);
- AddOrRemoveObserver(this, NOTIFY_LOAD_START, start_listening);
- AddOrRemoveObserver(this, NOTIFY_LOAD_STOP, start_listening);
- AddOrRemoveObserver(this, NOTIFY_RENDERER_PROCESS_IN_SBOX, start_listening);
- AddOrRemoveObserver(this, NOTIFY_RENDERER_PROCESS_TERMINATED,
+ AddOrRemoveObserver(this, NotificationType::BROWSER_OPENED, start_listening);
+ AddOrRemoveObserver(this, NotificationType::BROWSER_CLOSED, start_listening);
+ AddOrRemoveObserver(this, NotificationType::USER_ACTION, start_listening);
+ AddOrRemoveObserver(this, NotificationType::TAB_PARENTED, start_listening);
+ AddOrRemoveObserver(this, NotificationType::TAB_CLOSING, start_listening);
+ AddOrRemoveObserver(this, NotificationType::LOAD_START, start_listening);
+ AddOrRemoveObserver(this, NotificationType::LOAD_STOP, start_listening);
+ AddOrRemoveObserver(this, NotificationType::RENDERER_PROCESS_IN_SBOX,
start_listening);
- AddOrRemoveObserver(this, NOTIFY_RENDERER_PROCESS_HANG, start_listening);
- AddOrRemoveObserver(this, NOTIFY_PLUGIN_PROCESS_HOST_CONNECTED,
+ AddOrRemoveObserver(this, NotificationType::RENDERER_PROCESS_TERMINATED,
+ start_listening);
+ AddOrRemoveObserver(this, NotificationType::RENDERER_PROCESS_HANG,
+ start_listening);
+ AddOrRemoveObserver(this, NotificationType::PLUGIN_PROCESS_HOST_CONNECTED,
+ start_listening);
+ AddOrRemoveObserver(this, NotificationType::PLUGIN_INSTANCE_CREATED,
+ start_listening);
+ AddOrRemoveObserver(this, NotificationType::PLUGIN_PROCESS_CRASHED,
+ start_listening);
+ AddOrRemoveObserver(this, NotificationType::TEMPLATE_URL_MODEL_LOADED,
+ start_listening);
+ AddOrRemoveObserver(this, NotificationType::OMNIBOX_OPENED_URL,
+ start_listening);
+ AddOrRemoveObserver(this, NotificationType::BOOKMARK_MODEL_LOADED,
start_listening);
- AddOrRemoveObserver(this, NOTIFY_PLUGIN_INSTANCE_CREATED, start_listening);
- AddOrRemoveObserver(this, NOTIFY_PLUGIN_PROCESS_CRASHED, start_listening);
- AddOrRemoveObserver(this, TEMPLATE_URL_MODEL_LOADED, start_listening);
- AddOrRemoveObserver(this, NOTIFY_OMNIBOX_OPENED_URL, start_listening);
- AddOrRemoveObserver(this, NOTIFY_BOOKMARK_MODEL_LOADED, start_listening);
}
// static
@@ -1451,14 +1459,14 @@ void MetricsService::LogWindowChange(NotificationType type,
}
DCHECK(controller_id != -1);
- switch (type) {
- case NOTIFY_TAB_PARENTED:
- case NOTIFY_BROWSER_OPENED:
+ switch (type.value) {
+ case NotificationType::TAB_PARENTED:
+ case NotificationType::BROWSER_OPENED:
window_type = MetricsLog::WINDOW_CREATE;
break;
- case NOTIFY_TAB_CLOSING:
- case NOTIFY_BROWSER_CLOSED:
+ case NotificationType::TAB_CLOSING:
+ case NotificationType::BROWSER_CLOSED:
window_map_.erase(window_map_.find(window_or_tab));
window_type = MetricsLog::WINDOW_DESTROY;
break;
@@ -1532,21 +1540,21 @@ void MetricsService::LogPluginChange(NotificationType type,
}
PluginStats& stats = plugin_stats_buffer_[plugin];
- switch (type) {
- case NOTIFY_PLUGIN_PROCESS_HOST_CONNECTED:
+ switch (type.value) {
+ case NotificationType::PLUGIN_PROCESS_HOST_CONNECTED:
stats.process_launches++;
break;
- case NOTIFY_PLUGIN_INSTANCE_CREATED:
+ case NotificationType::PLUGIN_INSTANCE_CREATED:
stats.instances++;
break;
- case NOTIFY_PLUGIN_PROCESS_CRASHED:
+ case NotificationType::PLUGIN_PROCESS_CRASHED:
stats.process_crashes++;
break;
default:
- NOTREACHED() << "Unexpected notification type " << type;
+ NOTREACHED() << "Unexpected notification type " << type.value;
return;
}
}