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

Unified Diff: ui/file_manager/externs/background/task_queue.js

Issue 2883263002: Stop foreground depending on background in gyp v2 (Closed)
Patch Set: Remove private Created 3 years, 7 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: ui/file_manager/externs/background/task_queue.js
diff --git a/ui/file_manager/externs/background/task_queue.js b/ui/file_manager/externs/background/task_queue.js
new file mode 100644
index 0000000000000000000000000000000000000000..93c8f47328a3148e76e787b69ab1b0bc6fd18e80
--- /dev/null
+++ b/ui/file_manager/externs/background/task_queue.js
@@ -0,0 +1,114 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Namespace
+var importer;
+
+/**
+ * A queue of tasks. Tasks (subclasses of TaskQueue.Task) can be pushed onto
+ * the queue. The queue becomes active whenever it is not empty, and it will
+ * begin executing tasks one at a time. The tasks are executed in a separate
+ * asynchronous context. As each task runs, it can send update notifications
+ * which are relayed back to clients via callbacks. When the queue runs of of
+ * tasks, it goes back into an idle state. Clients can set callbacks which will
+ * be triggered whenever the queue transitions between the active and idle
+ * states.
+ *
+ * @constructor
+ * @struct
+ */
+importer.TaskQueue = function() {};
fukino 2017/05/17 04:58:56 Do we have to expose full shape of importer.TaskQu
oka 2017/05/17 08:45:42 Removed needless exposure.
+
+/**
+ * @enum {string}
+ */
+importer.TaskQueue.UpdateType = {};
+
+
+/**
+ * @param {!importer.TaskQueue.Task} task
+ */
+importer.TaskQueue.prototype.queueTask = function(task) {};
+
+/**
+ * Sets a callback to be triggered when a task updates.
+ * @param {function(string, !importer.TaskQueue.Task)} callback
+ */
+importer.TaskQueue.prototype.addUpdateCallback = function(callback) {};
+
+/**
+ * Sets a callback that is triggered each time the queue goes from an idle
+ * (i.e. empty with no running tasks) to an active (i.e. having a running task)
+ * state.
+ * @param {function()} callback
+ */
+importer.TaskQueue.prototype.setActiveCallback = function(callback) {};
+
+/**
+ * Sets a callback that is triggered each time the queue goes from an active to
+ * an idle state. Also see #setActiveCallback.
+ * @param {function()} callback
+ */
+importer.TaskQueue.prototype.setIdleCallback = function(callback) {};
+
+/**
+ * Interface for any Task that is to run on the TaskQueue.
+ * @interface
+ */
+importer.TaskQueue.Task = function() {};
+
+/**
+ * A callback that is triggered whenever an update is reported on the observed
+ * task. The first argument is a string specifying the type of the update.
+ * Standard values used by all tasks are enumerated in
+ * importer.TaskQueue.UpdateType, but child classes may add supplementary update
+ * types of their own. The second argument is an Object containing
+ * supplementary information pertaining to the update.
+ * @typedef {function(!importer.TaskQueue.UpdateType, Object=)}
+ */
+importer.TaskQueue.Task.Observer;
+
+/**
+ * Sets the TaskQueue that will own this task. The TaskQueue must call this
+ * prior to enqueuing a Task.
+ * @param {!importer.TaskQueue.Task.Observer} observer A callback that
+ * will be triggered each time the task has a status update.
+ */
+importer.TaskQueue.Task.prototype.addObserver;
+
+/**
+ * Performs the actual work of the Task. Child classes should implement this.
+ */
+importer.TaskQueue.Task.prototype.run;
+
+/**
+ * Base class for importer tasks.
+ * @constructor
+ * @implements {importer.TaskQueue.Task}
+ */
+importer.TaskQueue.BaseTask = function() {};
+
+/** @struct */
+importer.TaskQueue.BaseTask.prototype = {
+ /** @return {string} The task ID. */
+ get taskId() {},
+
+ /** @return {!Promise<!importer.TaskQueue.UpdateType>} Resolves when task
+ is complete, or cancelled, rejects on error. */
+ get whenFinished() {}
+};
+
+/** @override */
+importer.TaskQueue.BaseTask.prototype.addObserver = function(observer) {};
+
+/** @override */
+importer.TaskQueue.BaseTask.prototype.run = function() {};
+
+/**
+ * @param {string} updateType
+ * @param {Object=} opt_data
+ * @protected
+ */
+importer.TaskQueue.BaseTask.prototype.notify = function(updateType, opt_data) {
+};

Powered by Google App Engine
This is Rietveld 408576698