| 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 1d0b01c02b21b556b200c6239d6bed719c2c49c1..27a132f11cdf5d121e5b934eda9d83988dafde6a 100644
|
| --- a/chrome/browser/extensions/lazy_background_task_queue.cc
|
| +++ b/chrome/browser/extensions/lazy_background_task_queue.cc
|
| @@ -42,7 +42,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 = profile->GetExtensionProcessManager();
|
| ExtensionHost* background_host =
|
| pm->GetBackgroundHostForExtension(extension->id());
|
| @@ -66,16 +66,17 @@ void LazyBackgroundTaskQueue::AddPendingTask(
|
| tasks_list = new PendingTasksList();
|
| pending_tasks_[key] = linked_ptr<PendingTasksList>(tasks_list);
|
|
|
| - // If this is the first enqueued task, ensure the background page
|
| - // is loaded.
|
| const Extension* extension =
|
| ExtensionSystem::Get(profile)->extension_service()->
|
| extensions()->GetByID(extension_id);
|
| - DCHECK(extension->has_lazy_background_page());
|
| - ExtensionProcessManager* pm =
|
| - ExtensionSystem::Get(profile)->process_manager();
|
| - pm->IncrementLazyKeepaliveCount(extension);
|
| - pm->CreateBackgroundHost(extension, extension->GetBackgroundURL());
|
| + 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.
|
| + ExtensionProcessManager* pm =
|
| + ExtensionSystem::Get(profile)->process_manager();
|
| + pm->IncrementLazyKeepaliveCount(extension);
|
| + pm->CreateBackgroundHost(extension, extension->GetBackgroundURL());
|
| + }
|
| } else {
|
| tasks_list = it->second.get();
|
| }
|
| @@ -87,14 +88,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;
|
| }
|
|
|
| @@ -111,7 +112,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);
|
| }
|
|
|