diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-14 20:51:16 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-14 20:51:16 +0000 |
commit | a4ed6281fe6d6aad1366a8f6b03e35f6e1eadaa6 (patch) | |
tree | d99e2aaa6ee7d542278756feb4006ec0e38d1a45 | |
parent | 87130f869a23f9a842f3a25212dd37bf29814c9d (diff) | |
download | chromium_src-a4ed6281fe6d6aad1366a8f6b03e35f6e1eadaa6.zip chromium_src-a4ed6281fe6d6aad1366a8f6b03e35f6e1eadaa6.tar.gz chromium_src-a4ed6281fe6d6aad1366a8f6b03e35f6e1eadaa6.tar.bz2 |
Fix extension shutdown notification, take 2.
The first patch was broken because a lot of stuff relied on the EXTENSION_PROCESS_CRASHED notification being sent when the extension hadn't actually "crashed". New fix: rename the notification to EXTENSION_PROCESS_TERMINATED, and don't send unload notifications during browser shutdown.
BUG=30057
Review URL: http://codereview.chromium.org/489009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34489 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser.cc | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 11 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 5 | ||||
-rw-r--r-- | chrome/browser/task_manager_resource_providers.cc | 6 | ||||
-rw-r--r-- | chrome/common/notification_type.h | 7 |
5 files changed, 21 insertions, 12 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 40690ba..0c892a9 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -155,7 +155,7 @@ Browser::Browser(Type type, Profile* profile) NotificationService::AllSources()); registrar_.Add(this, NotificationType::EXTENSION_UNLOADED_DISABLED, NotificationService::AllSources()); - registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED, + registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, NotificationService::AllSources()); registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, NotificationService::AllSources()); @@ -2375,7 +2375,7 @@ void Browser::Observe(NotificationType type, break; } - case NotificationType::EXTENSION_PROCESS_CRASHED: { + case NotificationType::EXTENSION_PROCESS_TERMINATED: { window()->GetLocationBar()->InvalidatePageActions(); TabContents* tab_contents = GetSelectedTabContents(); diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 767da27..525b267 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -14,6 +14,7 @@ #include "base/string_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" +#include "chrome/browser/browser_shutdown.h" #include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/browsing_instance.h" #include "chrome/browser/debugger/devtools_manager.h" @@ -242,10 +243,16 @@ void ExtensionHost::UpdatePreferredSize(const gfx::Size& new_size) { } void ExtensionHost::RenderViewGone(RenderViewHost* render_view_host) { - LOG(INFO) << "Sending EXTENSION_PROCESS_CRASHED for " + extension_->name(); + // During browser shutdown, we may use sudden termination on an extension + // process, so it is expected to lose our connection to the render view. + // Do nothing. + if (browser_shutdown::GetShutdownType() != browser_shutdown::NOT_VALID) + return; + + LOG(INFO) << "Sending EXTENSION_PROCESS_TERMINATED for " + extension_->name(); DCHECK_EQ(render_view_host_, render_view_host); NotificationService::current()->Notify( - NotificationType::EXTENSION_PROCESS_CRASHED, + NotificationType::EXTENSION_PROCESS_TERMINATED, Source<Profile>(profile_), Details<ExtensionHost>(this)); } diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index f8916d7..578b8ef 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -122,7 +122,7 @@ ExtensionsService::ExtensionsService(Profile* profile, registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, NotificationService::AllSources()); - registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED, + registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, Source<Profile>(profile_)); // Set up the ExtensionUpdater @@ -840,8 +840,9 @@ void ExtensionsService::Observe(NotificationType type, break; } - case NotificationType::EXTENSION_PROCESS_CRASHED: { + case NotificationType::EXTENSION_PROCESS_TERMINATED: { DCHECK_EQ(profile_, Source<Profile>(source).ptr()); + ExtensionHost* host = Details<ExtensionHost>(details).ptr(); // Unload the entire extension. We want it to be in a consistent state: diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc index 4a3a624..715dd08 100644 --- a/chrome/browser/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager_resource_providers.cc @@ -596,7 +596,7 @@ void TaskManagerExtensionProcessResourceProvider::StartUpdating() { // Register for notifications about extension process changes. registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CREATED, NotificationService::AllSources()); - registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED, + registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, NotificationService::AllSources()); registrar_.Add(this, NotificationType::EXTENSION_HOST_DESTROYED, NotificationService::AllSources()); @@ -609,7 +609,7 @@ void TaskManagerExtensionProcessResourceProvider::StopUpdating() { // Unregister for notifications about extension process changes. registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_CREATED, NotificationService::AllSources()); - registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_CRASHED, + registrar_.Remove(this, NotificationType::EXTENSION_PROCESS_TERMINATED, NotificationService::AllSources()); registrar_.Remove(this, NotificationType::EXTENSION_HOST_DESTROYED, NotificationService::AllSources()); @@ -629,7 +629,7 @@ void TaskManagerExtensionProcessResourceProvider::Observe( case NotificationType::EXTENSION_PROCESS_CREATED: AddToTaskManager(Details<ExtensionHost>(details).ptr()); break; - case NotificationType::EXTENSION_PROCESS_CRASHED: + case NotificationType::EXTENSION_PROCESS_TERMINATED: case NotificationType::EXTENSION_HOST_DESTROYED: RemoveFromTaskManager(Details<ExtensionHost>(details).ptr()); break; diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h index ed930c2..92b6a7e 100644 --- a/chrome/common/notification_type.h +++ b/chrome/common/notification_type.h @@ -708,9 +708,10 @@ class NotificationType { // The details are an ExtensionHost*. EXTENSION_PROCESS_CREATED, - // Sent when extension render process crashes. The details are - // an ExtensionHost* and the source is a Profile*. - EXTENSION_PROCESS_CRASHED, + // Sent when extension render process ends (whether it crashes or closes). + // The details are an ExtensionHost* and the source is a Profile*. Not sent + // during browser shutdown. + EXTENSION_PROCESS_TERMINATED, // Sent when the contents or order of toolstrips in the shelf model change. EXTENSION_SHELF_MODEL_CHANGED, |