| Index: ui/file_manager/file_manager/common/js/async_util.js
|
| diff --git a/ui/file_manager/file_manager/common/js/async_util.js b/ui/file_manager/file_manager/common/js/async_util.js
|
| index 16a1ca2861dc582580d9a677910edd916506d0a2..6204d85cae227868fe3215575f34c5ad8fd6eb3a 100644
|
| --- a/ui/file_manager/file_manager/common/js/async_util.js
|
| +++ b/ui/file_manager/file_manager/common/js/async_util.js
|
| @@ -149,6 +149,17 @@ AsyncUtil.ConcurrentQueue.prototype.onTaskFinished_ = function(closure) {
|
| };
|
|
|
| /**
|
| + * Returns string representation of current AsyncUtil.ConcurrentQueue instance.
|
| + * @return {string} String representation of the instance.
|
| + */
|
| +AsyncUtil.ConcurrentQueue.prototype.toString = function() {
|
| + return 'AsyncUtil.ConcurrentQueue\n' +
|
| + '- WaitingTasksCount: ' + this.getWaitingTasksCount() + '\n' +
|
| + '- RunningTasksCount: ' + this.getRunningTasksCount() + '\n' +
|
| + '- isCancelled: ' + this.isCancelled();
|
| +};
|
| +
|
| +/**
|
| * Creates a class for executing several asynchronous closures in a fifo queue.
|
| * Added tasks will be executed sequentially in order they were added.
|
| *
|
| @@ -164,6 +175,32 @@ AsyncUtil.Queue.prototype = {
|
| };
|
|
|
| /**
|
| + * A task which is executed by AsyncUtil.Group.
|
| + *
|
| + * @param {!function(function())} closure Closure with a completion callback to
|
| + * be executed.
|
| + * @param {!Array.<string>} dependencies Array of dependencies.
|
| + * @param {!string} name Task identifier. Specify to use in dependencies.
|
| + *
|
| + * @constructor
|
| + */
|
| +AsyncUtil.GroupTask = function(closure, dependencies, name) {
|
| + this.closure = closure;
|
| + this.dependencies = dependencies;
|
| + this.name = name;
|
| +};
|
| +
|
| +/**
|
| + * Returns string representation of AsyncUti.GroupTask instance.
|
| + * @return {string} String representation of the instance.
|
| + */
|
| +AsyncUtil.GroupTask.prototype.toString = function() {
|
| + return 'AsyncUtil.GroupTask\n' +
|
| + '- name: ' + this.name + '\n' +
|
| + '- dependencies: ' + this.dependencies.join();
|
| +};
|
| +
|
| +/**
|
| * Creates a class for executing several asynchronous closures in a group in
|
| * a dependency order.
|
| *
|
| @@ -176,6 +213,15 @@ AsyncUtil.Group = function() {
|
| this.completionCallbacks_ = [];
|
| };
|
|
|
| +AsyncUtil.Group.prototype = {
|
| + /**
|
| + * @return {Object.<string, AsyncUtil.GroupTask>} Pending tasks
|
| + */
|
| + get pendingTasks() {
|
| + return this.pendingTasks_;
|
| + }
|
| +};
|
| +
|
| /**
|
| * Enqueues a closure to be executed after dependencies are completed.
|
| *
|
| @@ -189,11 +235,7 @@ AsyncUtil.Group.prototype.add = function(closure, opt_dependencies, opt_name) {
|
| var length = Object.keys(this.addedTasks_).length;
|
| var name = opt_name || ('(unnamed#' + (length + 1) + ')');
|
|
|
| - var task = {
|
| - closure: closure,
|
| - dependencies: opt_dependencies || [],
|
| - name: name
|
| - };
|
| + var task = new AsyncUtil.GroupTask(closure, opt_dependencies || [], name);
|
|
|
| this.addedTasks_[name] = task;
|
| this.pendingTasks_[name] = task;
|
|
|