| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 //------------------------------------------------------------------------------ | 5 //------------------------------------------------------------------------------ |
| 6 // Description of the life cycle of a instance of MetricsService. | 6 // Description of the life cycle of a instance of MetricsService. |
| 7 // | 7 // |
| 8 // OVERVIEW | 8 // OVERVIEW |
| 9 // | 9 // |
| 10 // A MetricsService instance is typically created at application startup. It | 10 // A MetricsService instance is typically created at application startup. It |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 #include "chrome/common/chrome_notification_types.h" | 172 #include "chrome/common/chrome_notification_types.h" |
| 173 #include "chrome/common/chrome_switches.h" | 173 #include "chrome/common/chrome_switches.h" |
| 174 #include "chrome/common/guid.h" | 174 #include "chrome/common/guid.h" |
| 175 #include "chrome/common/metrics_log_manager.h" | 175 #include "chrome/common/metrics_log_manager.h" |
| 176 #include "chrome/common/pref_names.h" | 176 #include "chrome/common/pref_names.h" |
| 177 #include "chrome/common/render_messages.h" | 177 #include "chrome/common/render_messages.h" |
| 178 #include "content/browser/load_notification_details.h" | 178 #include "content/browser/load_notification_details.h" |
| 179 #include "content/browser/plugin_service.h" | 179 #include "content/browser/plugin_service.h" |
| 180 #include "content/browser/renderer_host/render_process_host.h" | 180 #include "content/browser/renderer_host/render_process_host.h" |
| 181 #include "content/common/child_process_info.h" | 181 #include "content/common/child_process_info.h" |
| 182 #include "content/common/notification_service.h" | 182 #include "content/public/browser/notification_service.h" |
| 183 #include "webkit/plugins/npapi/plugin_list.h" | 183 #include "webkit/plugins/npapi/plugin_list.h" |
| 184 #include "webkit/plugins/webplugininfo.h" | 184 #include "webkit/plugins/webplugininfo.h" |
| 185 | 185 |
| 186 // TODO(port): port browser_distribution.h. | 186 // TODO(port): port browser_distribution.h. |
| 187 #if !defined(OS_POSIX) | 187 #if !defined(OS_POSIX) |
| 188 #include "chrome/installer/util/browser_distribution.h" | 188 #include "chrome/installer/util/browser_distribution.h" |
| 189 #endif | 189 #endif |
| 190 | 190 |
| 191 #if defined(OS_CHROMEOS) | 191 #if defined(OS_CHROMEOS) |
| 192 #include "chrome/browser/chromeos/cros/cros_library.h" | 192 #include "chrome/browser/chromeos/cros/cros_library.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 bool MetricsService::reporting_active() const { | 452 bool MetricsService::reporting_active() const { |
| 453 DCHECK(IsSingleThreaded()); | 453 DCHECK(IsSingleThreaded()); |
| 454 return reporting_active_; | 454 return reporting_active_; |
| 455 } | 455 } |
| 456 | 456 |
| 457 // static | 457 // static |
| 458 void MetricsService::SetUpNotifications( | 458 void MetricsService::SetUpNotifications( |
| 459 content::NotificationRegistrar* registrar, | 459 content::NotificationRegistrar* registrar, |
| 460 content::NotificationObserver* observer) { | 460 content::NotificationObserver* observer) { |
| 461 registrar->Add(observer, chrome::NOTIFICATION_BROWSER_OPENED, | 461 registrar->Add(observer, chrome::NOTIFICATION_BROWSER_OPENED, |
| 462 NotificationService::AllBrowserContextsAndSources()); | 462 content::NotificationService::AllBrowserContextsAndSources()); |
| 463 registrar->Add(observer, chrome::NOTIFICATION_BROWSER_CLOSED, | 463 registrar->Add(observer, chrome::NOTIFICATION_BROWSER_CLOSED, |
| 464 NotificationService::AllSources()); | 464 content::NotificationService::AllSources()); |
| 465 registrar->Add(observer, content::NOTIFICATION_USER_ACTION, | 465 registrar->Add(observer, content::NOTIFICATION_USER_ACTION, |
| 466 NotificationService::AllSources()); | 466 content::NotificationService::AllSources()); |
| 467 registrar->Add(observer, content::NOTIFICATION_TAB_PARENTED, | 467 registrar->Add(observer, content::NOTIFICATION_TAB_PARENTED, |
| 468 NotificationService::AllSources()); | 468 content::NotificationService::AllSources()); |
| 469 registrar->Add(observer, content::NOTIFICATION_TAB_CLOSING, | 469 registrar->Add(observer, content::NOTIFICATION_TAB_CLOSING, |
| 470 NotificationService::AllSources()); | 470 content::NotificationService::AllSources()); |
| 471 registrar->Add(observer, content::NOTIFICATION_LOAD_START, | 471 registrar->Add(observer, content::NOTIFICATION_LOAD_START, |
| 472 NotificationService::AllSources()); | 472 content::NotificationService::AllSources()); |
| 473 registrar->Add(observer, content::NOTIFICATION_LOAD_STOP, | 473 registrar->Add(observer, content::NOTIFICATION_LOAD_STOP, |
| 474 NotificationService::AllSources()); | 474 content::NotificationService::AllSources()); |
| 475 registrar->Add(observer, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 475 registrar->Add(observer, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 476 NotificationService::AllSources()); | 476 content::NotificationService::AllSources()); |
| 477 registrar->Add(observer, content::NOTIFICATION_RENDERER_PROCESS_HANG, | 477 registrar->Add(observer, content::NOTIFICATION_RENDERER_PROCESS_HANG, |
| 478 NotificationService::AllSources()); | 478 content::NotificationService::AllSources()); |
| 479 registrar->Add(observer, content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED, | 479 registrar->Add(observer, content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED, |
| 480 NotificationService::AllSources()); | 480 content::NotificationService::AllSources()); |
| 481 registrar->Add(observer, content::NOTIFICATION_CHILD_INSTANCE_CREATED, | 481 registrar->Add(observer, content::NOTIFICATION_CHILD_INSTANCE_CREATED, |
| 482 NotificationService::AllSources()); | 482 content::NotificationService::AllSources()); |
| 483 registrar->Add(observer, content::NOTIFICATION_CHILD_PROCESS_CRASHED, | 483 registrar->Add(observer, content::NOTIFICATION_CHILD_PROCESS_CRASHED, |
| 484 NotificationService::AllSources()); | 484 content::NotificationService::AllSources()); |
| 485 registrar->Add(observer, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 485 registrar->Add(observer, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
| 486 NotificationService::AllSources()); | 486 content::NotificationService::AllSources()); |
| 487 registrar->Add(observer, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 487 registrar->Add(observer, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
| 488 NotificationService::AllSources()); | 488 content::NotificationService::AllSources()); |
| 489 registrar->Add(observer, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, | 489 registrar->Add(observer, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, |
| 490 NotificationService::AllBrowserContextsAndSources()); | 490 content::NotificationService::AllBrowserContextsAndSources()); |
| 491 } | 491 } |
| 492 | 492 |
| 493 void MetricsService::Observe(int type, | 493 void MetricsService::Observe(int type, |
| 494 const content::NotificationSource& source, | 494 const content::NotificationSource& source, |
| 495 const content::NotificationDetails& details) { | 495 const content::NotificationDetails& details) { |
| 496 DCHECK(log_manager_.current_log()); | 496 DCHECK(log_manager_.current_log()); |
| 497 DCHECK(IsSingleThreaded()); | 497 DCHECK(IsSingleThreaded()); |
| 498 | 498 |
| 499 if (!CanLogNotification(type, source, details)) | 499 if (!CanLogNotification(type, source, details)) |
| 500 return; | 500 return; |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 // TODO(brettw) we should have some kind of ID for the parent. | 1196 // TODO(brettw) we should have some kind of ID for the parent. |
| 1197 log_manager_.current_log()->RecordWindowEvent(window_type, controller_id, 0); | 1197 log_manager_.current_log()->RecordWindowEvent(window_type, controller_id, 0); |
| 1198 } | 1198 } |
| 1199 | 1199 |
| 1200 void MetricsService::LogLoadComplete( | 1200 void MetricsService::LogLoadComplete( |
| 1201 int type, | 1201 int type, |
| 1202 const content::NotificationSource& source, | 1202 const content::NotificationSource& source, |
| 1203 const content::NotificationDetails& details) { | 1203 const content::NotificationDetails& details) { |
| 1204 if (details == NotificationService::NoDetails()) | 1204 if (details == content::NotificationService::NoDetails()) |
| 1205 return; | 1205 return; |
| 1206 | 1206 |
| 1207 // TODO(jar): There is a bug causing this to be called too many times, and | 1207 // TODO(jar): There is a bug causing this to be called too many times, and |
| 1208 // the log overflows. For now, we won't record these events. | 1208 // the log overflows. For now, we won't record these events. |
| 1209 UMA_HISTOGRAM_COUNTS("UMA.LogLoadComplete called", 1); | 1209 UMA_HISTOGRAM_COUNTS("UMA.LogLoadComplete called", 1); |
| 1210 return; | 1210 return; |
| 1211 | 1211 |
| 1212 const content::Details<LoadNotificationDetails> load_details(details); | 1212 const content::Details<LoadNotificationDetails> load_details(details); |
| 1213 int controller_id = window_map_[details.map_key()]; | 1213 int controller_id = window_map_[details.map_key()]; |
| 1214 log_manager_.current_log()->RecordLoadEvent(controller_id, | 1214 log_manager_.current_log()->RecordLoadEvent(controller_id, |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 if (local_state) { | 1542 if (local_state) { |
| 1543 const PrefService::Preference* uma_pref = | 1543 const PrefService::Preference* uma_pref = |
| 1544 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1544 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
| 1545 if (uma_pref) { | 1545 if (uma_pref) { |
| 1546 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1546 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
| 1547 DCHECK(success); | 1547 DCHECK(success); |
| 1548 } | 1548 } |
| 1549 } | 1549 } |
| 1550 return result; | 1550 return result; |
| 1551 } | 1551 } |
| OLD | NEW |