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

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: fix unnecessary start 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
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..051cab7f0cdd0a8c6179e107a2cdff730dcf87eb 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());
@@ -59,6 +59,7 @@ void LazyBackgroundTaskQueue::AddPendingTask(
Profile* profile,
const std::string& extension_id,
const PendingTask& task) {
+ LOG(ERROR) << "AddPendingTask: " << extension_id;
PendingTasksList* tasks_list = NULL;
PendingTasksKey key(profile, extension_id);
PendingTasksMap::iterator it = pending_tasks_.find(key);
@@ -66,16 +67,18 @@ 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.
+ LOG(ERROR) << "AddPendingTask NEWHOST: " << extension_id;
+ ExtensionProcessManager* pm =
+ ExtensionSystem::Get(profile)->process_manager();
+ pm->IncrementLazyKeepaliveCount(extension);
+ pm->CreateBackgroundHost(extension, extension->GetBackgroundURL());
+ }
} else {
tasks_list = it->second.get();
}
@@ -87,17 +90,18 @@ 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;
}
+ LOG(ERROR) << "ProcessPendingTasks: " << extension->id() << " " << host;
// Swap the pending tasks to a temporary, to avoid problems if the task
// list is modified during processing.
PendingTasksList tasks;
@@ -111,7 +115,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);
}
@@ -127,6 +131,7 @@ void LazyBackgroundTaskQueue::Observe(
// events for it.
ExtensionHost* host =
content::Details<ExtensionHost>(details).ptr();
+ LOG(ERROR) << "Host done loading: " << host->extension()->id();
if (host->extension_host_type() ==
chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
CHECK(host->did_stop_loading());
@@ -142,6 +147,7 @@ void LazyBackgroundTaskQueue::Observe(
Profile* profile = content::Source<Profile>(source).ptr();
ExtensionHost* host =
content::Details<ExtensionHost>(details).ptr();
+ LOG(ERROR) << "Host destroyed: " << host->extension()->id();
if (host->extension_host_type() ==
chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
ProcessPendingTasks(NULL, profile, host->extension());

Powered by Google App Engine
This is Rietveld 408576698