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 b449f88d424bab45baa6d4df5a86684560440453..be77c47ac8de5bbb0b56fefed39725e30c880852 100644 |
--- a/chrome/browser/extensions/lazy_background_task_queue.cc |
+++ b/chrome/browser/extensions/lazy_background_task_queue.cc |
@@ -43,7 +43,7 @@ LazyBackgroundTaskQueue::~LazyBackgroundTaskQueue() { |
bool LazyBackgroundTaskQueue::ShouldEnqueueTask( |
Profile* profile, const Extension* extension) { |
DCHECK(extension); |
- if (extension->has_lazy_background_page()) { |
+ if (extension->has_background_page()) { |
ExtensionProcessManager* pm = |
ExtensionSystem::Get(profile)->process_manager(); |
ExtensionHost* background_host = |
@@ -68,10 +68,15 @@ void LazyBackgroundTaskQueue::AddPendingTask( |
tasks_list = new PendingTasksList(); |
pending_tasks_[key] = linked_ptr<PendingTasksList>(tasks_list); |
- // If this is the first enqueued task, and we're not waiting for the |
- // background page to unload, ensure the background page is loaded. |
- if (pending_page_loads_.count(key) == 0) |
- StartLazyBackgroundPage(profile, extension_id); |
+ const Extension* extension = |
+ ExtensionSystem::Get(profile)->extension_service()-> |
+ extensions()->GetByID(extension_id); |
+ if (extension && extension->has_lazy_background_page()) { |
+ // If this is the first enqueued task, and we're not waiting for the |
+ // background page to unload, ensure the background page is loaded. |
+ if (pending_page_loads_.count(key) == 0) |
+ StartLazyBackgroundPage(profile, extension_id); |
+ } |
} else { |
tasks_list = it->second.get(); |
} |
@@ -85,6 +90,8 @@ void LazyBackgroundTaskQueue::StartLazyBackgroundPage( |
ExtensionSystem::Get(profile)->process_manager(); |
if (pm->IsBackgroundHostClosing(extension_id)) { |
// When the background host finishes closing, we will reload it. |
+ // TODO(mpcomplete): I think pending_page_loads_ is obsolete, and |
+ // should be removed. http://crbug.com/136469 |
pending_page_loads_.insert(PendingTasksKey(profile, extension_id)); |
return; |
} |
@@ -105,14 +112,14 @@ void LazyBackgroundTaskQueue::ProcessPendingTasks( |
ExtensionHost* host, |
Profile* profile, |
const Extension* extension) { |
- if (!profile->IsSameProfile(profile_) || |
- !extension->has_lazy_background_page()) |
+ if (!profile->IsSameProfile(profile_)) |
return; |
PendingTasksKey key(profile, extension->id()); |
PendingTasksMap::iterator map_it = pending_tasks_.find(key); |
if (map_it == pending_tasks_.end()) { |
- CHECK(!host); // lazy page should not load without any pending tasks |
+ if (extension->has_lazy_background_page()) |
+ CHECK(!host); // lazy page should not load without any pending tasks |
return; |
} |
@@ -129,7 +136,7 @@ void LazyBackgroundTaskQueue::ProcessPendingTasks( |
// Balance the keepalive in AddPendingTask. Note we don't do this on a |
// failure to load, because the keepalive count is reset in that case. |
- if (host) { |
+ if (host && extension->has_lazy_background_page()) { |
ExtensionSystem::Get(profile)->process_manager()-> |
DecrementLazyKeepaliveCount(extension); |
} |
@@ -159,7 +166,8 @@ void LazyBackgroundTaskQueue::Observe( |
if (host->extension_host_type() == |
chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { |
PendingTasksKey key(profile, host->extension()->id()); |
- if (pending_page_loads_.count(key) > 0) { |
+ if (pending_page_loads_.count(key) > 0 && |
+ host->extension()->has_lazy_background_page()) { |
// We were waiting for the background page to unload. We can start it |
// up again and dispatch any queued events. |
MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |