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

Unified Diff: chrome/browser/extensions/lazy_background_task_queue.cc

Issue 10008094: Clear pending events for transient pages when it crashes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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
« no previous file with comments | « chrome/browser/extensions/extension_event_router.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/lazy_background_task_queue.cc
diff --git a/chrome/browser/extensions/lazy_background_task_queue.cc b/chrome/browser/extensions/lazy_background_task_queue.cc
index 4691c47fedc2d93c8d60804630d1a7c27126f204..bcf7d1c4f18d88b90ae84b4f818c9abfd3d93a44 100644
--- a/chrome/browser/extensions/lazy_background_task_queue.cc
+++ b/chrome/browser/extensions/lazy_background_task_queue.cc
@@ -29,6 +29,8 @@ LazyBackgroundTaskQueue::LazyBackgroundTaskQueue(Profile* profile)
: profile_(profile) {
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
content::NotificationService::AllBrowserContextsAndSources());
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED,
+ content::NotificationService::AllBrowserContextsAndSources());
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
content::Source<Profile>(profile));
}
@@ -66,7 +68,7 @@ void LazyBackgroundTaskQueue::AddPendingTask(
const Extension* extension = profile->GetExtensionService()->
extensions()->GetByID(extension_id);
DCHECK(extension->has_lazy_background_page());
- ExtensionProcessManager* pm = profile->GetExtensionProcessManager();
+ ExtensionProcessManager* pm = profile->GetExtensionProcessManager();
pm->IncrementLazyKeepaliveCount(extension);
pm->CreateBackgroundHost(extension, extension->GetBackgroundURL());
} else {
@@ -116,6 +118,19 @@ void LazyBackgroundTaskQueue::Observe(
}
break;
}
+ case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
+ // Clear pending tasks when the background host dies. This can happen
+ // if the extension crashes. This is not strictly necessary, since we
+ // also unload the extension in that case (which clears the tasks below),
+ // but is a good extra precaution.
+ Profile* profile = content::Source<Profile>(source).ptr();
+ ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
+ if (host->extension_host_type() ==
+ chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
+ pending_tasks_.erase(PendingTasksKey(profile, host->extension()->id()));
+ }
+ break;
+ }
case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
// Clear pending tasks for this extension.
Profile* profile = content::Source<Profile>(source).ptr();
« no previous file with comments | « chrome/browser/extensions/extension_event_router.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698