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

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

Issue 10828218: Add chrome.runtime.onStartup, which is fired on browser start. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm debug logs Created 8 years, 4 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_process_manager.cc ('k') | chrome/common/extensions/api/runtime.json » ('j') | 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 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);
}
« no previous file with comments | « chrome/browser/extensions/extension_process_manager.cc ('k') | chrome/common/extensions/api/runtime.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698