From 7c6877dea4bdbc7bd434ea9c96795529e466903c Mon Sep 17 00:00:00 2001 From: "phajdan.jr@chromium.org" Date: Fri, 19 Jun 2009 13:56:25 +0000 Subject: Display an infobar alert when extension process crashes. Also correctly handle crashes in task manager. The infobar allows user to restart the extension process. TEST=Install buildbot extension, see its content in the shelf. Open task manager, kill extension process. Click "restart" in the infobar that should appear. The extension content in the shelf should re-appear after the crash. http://crbug.com/14111 Review URL: http://codereview.chromium.org/126289 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18809 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/task_manager_resource_providers.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'chrome/browser/task_manager_resource_providers.cc') diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc index 7279aab..f76d8ad 100644 --- a/chrome/browser/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager_resource_providers.cc @@ -540,22 +540,30 @@ void TaskManagerExtensionProcessResourceProvider::StartUpdating() { AddToTaskManager(*jt); } - // Register for notifications to get new extension processes. + // Register for notifications about extension process changes. registrar_.Add(this, NotificationType::EXTENSION_HOST_CREATED, NotificationService::AllSources()); registrar_.Add(this, NotificationType::EXTENSION_HOST_DESTROYED, NotificationService::AllSources()); + registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED, + NotificationService::AllSources()); + registrar_.Add(this, NotificationType::EXTENSION_PROCESS_RESTORED, + NotificationService::AllSources()); } void TaskManagerExtensionProcessResourceProvider::StopUpdating() { DCHECK(updating_); updating_ = false; - // Unregister for notifications to get new extension processes. + // Unregister for notifications about extension process changes. registrar_.Remove(this, NotificationType::EXTENSION_HOST_CREATED, NotificationService::AllSources()); registrar_.Remove(this, NotificationType::EXTENSION_HOST_DESTROYED, NotificationService::AllSources()); + registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_CRASHED, + NotificationService::AllSources()); + registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_RESTORED, + NotificationService::AllSources()); // Delete all the resources. STLDeleteContainerPairSecondPointers(resources_.begin(), resources_.end()); @@ -570,9 +578,11 @@ void TaskManagerExtensionProcessResourceProvider::Observe( const NotificationDetails& details) { switch (type.value) { case NotificationType::EXTENSION_HOST_CREATED: + case NotificationType::EXTENSION_PROCESS_RESTORED: AddToTaskManager(Details(details).ptr()); break; case NotificationType::EXTENSION_HOST_DESTROYED: + case NotificationType::EXTENSION_PROCESS_CRASHED: RemoveFromTaskManager(Details(details).ptr()); break; default: @@ -583,6 +593,10 @@ void TaskManagerExtensionProcessResourceProvider::Observe( void TaskManagerExtensionProcessResourceProvider::AddToTaskManager( ExtensionHost* extension_host) { + // Don't add dead extension processes. + if (!extension_host->IsRenderViewLive()) + return; + TaskManagerExtensionProcessResource* resource = new TaskManagerExtensionProcessResource(extension_host); DCHECK(resources_.find(extension_host) == resources_.end()); -- cgit v1.1