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

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

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.h
diff --git a/chrome/browser/extensions/lazy_background_task_queue.h b/chrome/browser/extensions/lazy_background_task_queue.h
index 70d1ac0a9c9e1790c949ed1e67cd500b3ce2c421..166bfa5605c4e65547a4e4de48ccd90d599ddcbf 100644
--- a/chrome/browser/extensions/lazy_background_task_queue.h
+++ b/chrome/browser/extensions/lazy_background_task_queue.h
@@ -38,15 +38,15 @@ class LazyBackgroundTaskQueue
explicit LazyBackgroundTaskQueue(Profile* profile);
virtual ~LazyBackgroundTaskQueue();
- // Returns true if the task should be added to the queue (that is, if the
- // extension has a lazy background page that isn't ready yet).
- bool ShouldEnqueueTask(Profile* profile, const Extension* extension);
-
// Adds a task to the queue for a given extension. If this is the first
// task added for the extension, its lazy background page will be loaded.
// The task will be called either when the page is loaded, or when the
// page fails to load for some reason (e.g. a crash). In the latter case,
- // the ExtensionHost parameter is NULL.
+ // the ExtensionHost parameter is NULL. If there is currently a background
+ // page available to handle the task, any suspend the page was in the middle
+ // of will be canceled and the task will be executed with the background page
+ // as an argument. If the extension id isn't lazy, |task| will be executed
+ // straight away.
void AddPendingTask(
Profile* profile,
const std::string& extension_id,
@@ -62,9 +62,20 @@ class LazyBackgroundTaskQueue
linked_ptr<PendingTasksList> > PendingTasksMap;
typedef std::set<PendingTasksKey> PendingPageLoadList;
+ // Returns true if the task should be added to the queue (that is, if the
+ // extension has a lazy background page that isn't ready yet).
+ bool ShouldEnqueueTask(Profile* profile, const Extension* extension);
+
void StartLazyBackgroundPage(Profile* profile,
const std::string& extension_id);
+ // Executes |task| on an existing ExtensionHost if it exists. If the host is
+ // in the middle of a suspend, that suspend is canceled. Returns true if
+ // |task| was executed.
+ bool ExecuteTaskNowIfPossible(Profile* profile,
+ const std::string& extension_id,
+ const PendingTask& task);
+
// content::NotificationObserver interface.
virtual void Observe(int type,
const content::NotificationSource& source,

Powered by Google App Engine
This is Rietveld 408576698