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

Unified Diff: chrome/browser/performance_monitor/performance_monitor.cc

Issue 10837003: CPM Refactor and Cleanup (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_startup_times
Patch Set: Created 8 years, 5 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
Index: chrome/browser/performance_monitor/performance_monitor.cc
diff --git a/chrome/browser/performance_monitor/performance_monitor.cc b/chrome/browser/performance_monitor/performance_monitor.cc
index c23d68cc121b94b99375e57e94fd60c5449961e5..4bbe8d0af62b98a6af0fab8946a31a7088e4fd27 100644
--- a/chrome/browser/performance_monitor/performance_monitor.cc
+++ b/chrome/browser/performance_monitor/performance_monitor.cc
@@ -29,7 +29,6 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
-#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
using content::BrowserThread;
@@ -279,39 +278,24 @@ void PerformanceMonitor::Observe(int type,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_EXTENSION_INSTALLED: {
- const Extension* extension = content::Details<Extension>(details).ptr();
- AddEvent(util::CreateExtensionInstallEvent(base::Time::Now(),
- extension->id(),
- extension->name(),
- extension->url().spec(),
- extension->location(),
- extension->VersionString(),
- extension->description()));
+ HandleExtensionEvent(EVENT_EXTENSION_INSTALL,
+ content::Details<Extension>(details).ptr());
break;
}
case chrome::NOTIFICATION_EXTENSION_ENABLED: {
- const Extension* extension = content::Details<Extension>(details).ptr();
- AddEvent(util::CreateExtensionEnableEvent(base::Time::Now(),
- extension->id(),
- extension->name(),
- extension->url().spec(),
- extension->location(),
- extension->VersionString(),
- extension->description()));
+ HandleExtensionEvent(EVENT_EXTENSION_ENABLE,
+ content::Details<Extension>(details).ptr());
break;
}
case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
const extensions::UnloadedExtensionInfo* info =
content::Details<extensions::UnloadedExtensionInfo>(details).ptr();
- const Extension* extension = info->extension;
- AddEvent(util::CreateExtensionUnloadEvent(base::Time::Now(),
- extension->id(),
- extension->name(),
- extension->url().spec(),
- extension->location(),
- extension->VersionString(),
- extension->description(),
- info->reason));
+
+ // Check if the extension was unloaded because it was disabled.
+ if (info->reason == extension_misc::UNLOAD_REASON_DISABLE) {
+ HandleExtensionEvent(EVENT_EXTENSION_DISABLE,
+ info->extension);
+ }
break;
}
case chrome::NOTIFICATION_CRX_INSTALLER_DONE: {
@@ -319,28 +303,15 @@ void PerformanceMonitor::Observe(int type,
content::Source<extensions::CrxInstaller>(source).ptr();
// Check if the reason for the install was due to an extension update.
- if (installer->install_cause() != extension_misc::INSTALL_CAUSE_UPDATE)
- break;
-
- const Extension* extension = content::Details<Extension>(details).ptr();
- AddEvent(util::CreateExtensionUpdateEvent(base::Time::Now(),
- extension->id(),
- extension->name(),
- extension->url().spec(),
- extension->location(),
- extension->VersionString(),
- extension->description()));
+ if (installer->install_cause() == extension_misc::INSTALL_CAUSE_UPDATE) {
+ HandleExtensionEvent(EVENT_EXTENSION_UPDATE,
+ content::Details<Extension>(details).ptr());
+ }
break;
}
case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
- const Extension* extension = content::Details<Extension>(details).ptr();
- AddEvent(util::CreateExtensionUninstallEvent(base::Time::Now(),
- extension->id(),
- extension->name(),
- extension->url().spec(),
- extension->location(),
- extension->VersionString(),
- extension->description()));
+ HandleExtensionEvent(EVENT_EXTENSION_UNINSTALL,
+ content::Details<Extension>(details).ptr());
break;
}
case content::NOTIFICATION_RENDERER_PROCESS_HANG: {
@@ -351,22 +322,8 @@ void PerformanceMonitor::Observe(int type,
break;
}
case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
- content::RenderProcessHost::RendererClosedDetails closed_details =
- *content::Details<content::RenderProcessHost::RendererClosedDetails>(
- details).ptr();
-
- // We only care if this is an invalid termination.
- if (closed_details.status == base::TERMINATION_STATUS_NORMAL_TERMINATION
- || closed_details.status == base::TERMINATION_STATUS_STILL_RUNNING)
- break;
-
- // Determine the type of crash.
- EventType type =
- closed_details.status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ?
- EVENT_KILLED_BY_OS_CRASH : EVENT_RENDERER_CRASH;
-
- AddEvent(util::CreateCrashEvent(base::Time::Now(),
- type));
+ HandleCrashEvent(*content::Details<
+ content::RenderProcessHost::RendererClosedDetails>(details).ptr());
break;
}
case chrome::NOTIFICATION_PROFILE_ADDED: {
@@ -389,4 +346,36 @@ void PerformanceMonitor::Observe(int type,
}
}
+void PerformanceMonitor::HandleExtensionEvent(EventType type,
+ const Extension* extension) {
+ DCHECK(type == EVENT_EXTENSION_INSTALL ||
+ type == EVENT_EXTENSION_UNINSTALL ||
+ type == EVENT_EXTENSION_UPDATE ||
+ type == EVENT_EXTENSION_ENABLE ||
+ type == EVENT_EXTENSION_DISABLE);
+ AddEvent(util::CreateExtensionEvent(type,
+ base::Time::Now(),
+ extension->id(),
+ extension->name(),
+ extension->url().spec(),
+ extension->location(),
+ extension->VersionString(),
+ extension->description()));
+}
+
+void PerformanceMonitor::HandleCrashEvent(
+ const content::RenderProcessHost::RendererClosedDetails& details) {
+ // We only care if this is an invalid termination.
+ if (details.status == base::TERMINATION_STATUS_NORMAL_TERMINATION ||
+ details.status == base::TERMINATION_STATUS_STILL_RUNNING)
+ return;
+
+ // Determine the type of crash.
+ EventType type =
+ details.status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED ?
+ EVENT_KILLED_BY_OS_CRASH : EVENT_RENDERER_CRASH;
+
+ AddEvent(util::CreateCrashEvent(base::Time::Now(), type));
+}
+
} // namespace performance_monitor

Powered by Google App Engine
This is Rietveld 408576698