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

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

Issue 10804020: Introduce runtime.onSuspendCanceled() event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos call Created 8 years, 5 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 b98d44626be848a3a2db04c60ac4cb11ea981243..0288ef94e48d5d1e5af29e7c4a2eb74db1210719 100644
--- a/chrome/browser/extensions/lazy_background_task_queue.cc
+++ b/chrome/browser/extensions/lazy_background_task_queue.cc
@@ -48,18 +48,47 @@ bool LazyBackgroundTaskQueue::ShouldEnqueueTask(
ExtensionSystem::Get(profile)->process_manager();
ExtensionHost* background_host =
pm->GetBackgroundHostForExtension(extension->id());
- if (!background_host || !background_host->did_stop_loading() ||
- pm->IsBackgroundHostClosing(extension->id()))
+ if (!background_host || !background_host->did_stop_loading())
return true;
}
return false;
}
+const Extension* GetExtension(Profile* profile,
+ const std::string& extension_id) {
+ return ExtensionSystem::Get(profile)->extension_service()->
+ extensions()->GetByID(extension_id);
+}
+
+bool LazyBackgroundTaskQueue::ExecuteTaskNowIfPossible(
+ Profile* profile,
+ const std::string& extension_id,
+ const PendingTask& task) {
+ const Extension* extension = GetExtension(profile, extension_id);
+ if (ShouldEnqueueTask(profile, extension))
+ return false;
+
+ ExtensionProcessManager* pm =
+ ExtensionSystem::Get(profile)->process_manager();
+ ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id);
+
+ if (!host)
+ return true;
Matt Perry 2012/07/24 19:25:15 I think you still want to run the task with a NULL
+
+ if (pm->IsBackgroundHostClosing(extension_id))
+ pm->CancelSuspend(extension_id);
+
+ task.Run(host);
+ return true;
+}
+
void LazyBackgroundTaskQueue::AddPendingTask(
Profile* profile,
const std::string& extension_id,
const PendingTask& task) {
+ if (ExecuteTaskNowIfPossible(profile, extension_id, task))
+ return;
PendingTasksList* tasks_list = NULL;
PendingTasksKey key(profile, extension_id);
PendingTasksMap::iterator it = pending_tasks_.find(key);

Powered by Google App Engine
This is Rietveld 408576698