OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/performance_monitor/performance_monitor.h" | 5 #include "chrome/browser/performance_monitor/performance_monitor.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 // Start our periodic gathering of metrics. | 223 // Start our periodic gathering of metrics. |
224 if (!disable_timer_autostart_for_testing_) | 224 if (!disable_timer_autostart_for_testing_) |
225 timer_.Reset(); | 225 timer_.Reset(); |
226 } | 226 } |
227 | 227 |
228 void PerformanceMonitor::RegisterForNotifications() { | 228 void PerformanceMonitor::RegisterForNotifications() { |
229 DCHECK(database_logging_enabled_); | 229 DCHECK(database_logging_enabled_); |
230 | 230 |
231 // Extensions | 231 // Extensions |
232 registrar_.Add(this, | 232 registrar_.Add( |
233 chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 233 this, |
234 content::NotificationService::AllSources()); | 234 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
235 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_ENABLED, | |
236 content::NotificationService::AllSources()); | |
237 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | |
238 content::NotificationService::AllSources()); | |
239 registrar_.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE, | |
240 content::NotificationService::AllSources()); | 235 content::NotificationService::AllSources()); |
241 registrar_.Add(this, | 236 registrar_.Add(this, |
242 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, | 237 extensions::NOTIFICATION_EXTENSION_ENABLED, |
| 238 content::NotificationService::AllSources()); |
| 239 registrar_.Add(this, |
| 240 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 241 content::NotificationService::AllSources()); |
| 242 registrar_.Add(this, |
| 243 extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
| 244 content::NotificationService::AllSources()); |
| 245 registrar_.Add(this, |
| 246 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, |
243 content::NotificationService::AllSources()); | 247 content::NotificationService::AllSources()); |
244 | 248 |
245 // Crashes | 249 // Crashes |
246 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_HANG, | 250 registrar_.Add(this, content::NOTIFICATION_RENDER_WIDGET_HOST_HANG, |
247 content::NotificationService::AllSources()); | 251 content::NotificationService::AllSources()); |
248 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 252 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
249 content::NotificationService::AllSources()); | 253 content::NotificationService::AllSources()); |
250 | 254 |
251 // Profiles (for unclean exit) | 255 // Profiles (for unclean exit) |
252 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, | 256 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 if (initialized_ && !request.url().SchemeIsFile()) | 553 if (initialized_ && !request.url().SchemeIsFile()) |
550 performance_data_for_io_thread_.network_bytes_read += bytes_read; | 554 performance_data_for_io_thread_.network_bytes_read += bytes_read; |
551 } | 555 } |
552 | 556 |
553 void PerformanceMonitor::Observe(int type, | 557 void PerformanceMonitor::Observe(int type, |
554 const content::NotificationSource& source, | 558 const content::NotificationSource& source, |
555 const content::NotificationDetails& details) { | 559 const content::NotificationDetails& details) { |
556 DCHECK(database_logging_enabled_); | 560 DCHECK(database_logging_enabled_); |
557 | 561 |
558 switch (type) { | 562 switch (type) { |
559 case chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED: { | 563 case extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED: { |
560 AddExtensionEvent( | 564 AddExtensionEvent( |
561 EVENT_EXTENSION_INSTALL, | 565 EVENT_EXTENSION_INSTALL, |
562 content::Details<const extensions::InstalledExtensionInfo>(details)-> | 566 content::Details<const extensions::InstalledExtensionInfo>(details)-> |
563 extension); | 567 extension); |
564 break; | 568 break; |
565 } | 569 } |
566 case chrome::NOTIFICATION_EXTENSION_ENABLED: { | 570 case extensions::NOTIFICATION_EXTENSION_ENABLED: { |
567 AddExtensionEvent(EVENT_EXTENSION_ENABLE, | 571 AddExtensionEvent(EVENT_EXTENSION_ENABLE, |
568 content::Details<Extension>(details).ptr()); | 572 content::Details<Extension>(details).ptr()); |
569 break; | 573 break; |
570 } | 574 } |
571 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 575 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
572 const UnloadedExtensionInfo* info = | 576 const UnloadedExtensionInfo* info = |
573 content::Details<UnloadedExtensionInfo>(details).ptr(); | 577 content::Details<UnloadedExtensionInfo>(details).ptr(); |
574 | 578 |
575 // Check if the extension was unloaded because it was disabled. | 579 // Check if the extension was unloaded because it was disabled. |
576 if (info->reason == UnloadedExtensionInfo::REASON_DISABLE) { | 580 if (info->reason == UnloadedExtensionInfo::REASON_DISABLE) { |
577 AddExtensionEvent(EVENT_EXTENSION_DISABLE, | 581 AddExtensionEvent(EVENT_EXTENSION_DISABLE, |
578 info->extension); | 582 info->extension); |
579 } | 583 } |
580 break; | 584 break; |
581 } | 585 } |
582 case chrome::NOTIFICATION_CRX_INSTALLER_DONE: { | 586 case extensions::NOTIFICATION_CRX_INSTALLER_DONE: { |
583 const extensions::CrxInstaller* installer = | 587 const extensions::CrxInstaller* installer = |
584 content::Source<extensions::CrxInstaller>(source).ptr(); | 588 content::Source<extensions::CrxInstaller>(source).ptr(); |
585 const extensions::Extension* extension = | 589 const extensions::Extension* extension = |
586 content::Details<Extension>(details).ptr(); | 590 content::Details<Extension>(details).ptr(); |
587 | 591 |
588 // Check if the reason for the install was due to a successful | 592 // Check if the reason for the install was due to a successful |
589 // extension update. |extension| is NULL in case of install failure. | 593 // extension update. |extension| is NULL in case of install failure. |
590 if (extension && | 594 if (extension && |
591 installer->install_cause() == extension_misc::INSTALL_CAUSE_UPDATE) { | 595 installer->install_cause() == extension_misc::INSTALL_CAUSE_UPDATE) { |
592 AddExtensionEvent(EVENT_EXTENSION_UPDATE, extension); | 596 AddExtensionEvent(EVENT_EXTENSION_UPDATE, extension); |
593 } | 597 } |
594 break; | 598 break; |
595 } | 599 } |
596 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: { | 600 case extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: { |
597 AddExtensionEvent(EVENT_EXTENSION_UNINSTALL, | 601 AddExtensionEvent(EVENT_EXTENSION_UNINSTALL, |
598 content::Details<Extension>(details).ptr()); | 602 content::Details<Extension>(details).ptr()); |
599 break; | 603 break; |
600 } | 604 } |
601 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: { | 605 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: { |
602 std::string url; | 606 std::string url; |
603 content::RenderWidgetHost* widget = | 607 content::RenderWidgetHost* widget = |
604 content::Source<content::RenderWidgetHost>(source).ptr(); | 608 content::Source<content::RenderWidgetHost>(source).ptr(); |
605 if (widget->IsRenderView()) { | 609 if (widget->IsRenderView()) { |
606 content::RenderViewHost* view = content::RenderViewHost::From(widget); | 610 content::RenderViewHost* view = content::RenderViewHost::From(widget); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 if (!url_list.empty()) | 709 if (!url_list.empty()) |
706 url_list += ", "; | 710 url_list += ", "; |
707 | 711 |
708 url_list += url; | 712 url_list += url; |
709 } | 713 } |
710 | 714 |
711 AddEvent(util::CreateRendererFailureEvent(base::Time::Now(), type, url_list)); | 715 AddEvent(util::CreateRendererFailureEvent(base::Time::Now(), type, url_list)); |
712 } | 716 } |
713 | 717 |
714 } // namespace performance_monitor | 718 } // namespace performance_monitor |
OLD | NEW |