Commit 04a1bb6d authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Chromium LUCI CQ

Files app: Generate JS module for //u/f/f/b/j/task_queue.m.js

Generate JS modules for:
//ui/file_manager/externs/background/task_queue.js
//ui/file_manager/file_manager/background/js/task_queue.js

Because Closure doesn't deal well importing the same namespace from
different files, I started splitting the "importer" namespace so each
file will have its own namespace.  Files in the "externs" directory will
have the suffix "Interface" on their namespace.  I'll use this logic for
all files related to "importer" namespace.

The "importer" namespace will remain for the file "importer_common.js"

Move the `UpdateType` our of the TaskQueue namespace to remove the
reference of importer.TaskQueue from importer_common.js because it was
causing a circular dependency between externs/b/task_queue.js and
importer_common.js.

Bug: 1133186
Change-Id: I53af2ceb7f75e463702fdfbb3f2c4758f1fbc540
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592578
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Reviewed-by: default avatarJeremie Boulic <jboulic@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837920}
parent c97414e9
......@@ -72,6 +72,14 @@ js_library("progress_center.m") {
extra_deps = [ ":modulize" ]
}
js_library("task_queue.m") {
sources =
[ "$root_gen_dir/ui/file_manager/externs/background/task_queue.m.js" ]
deps = [ "//ui/file_manager/file_manager/common/js:importer_common.m" ]
extra_deps = [ ":modulize" ]
}
js_modulizer("modulize") {
input_files = [
"background_base.js",
......@@ -79,5 +87,6 @@ js_modulizer("modulize") {
"drive_sync_handler.js",
"file_operation_manager.js",
"progress_center.js",
"task_queue.js",
]
}
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
// Namespace
// eslint-disable-next-line no-var
var importer = importer || {};
/*
......@@ -34,7 +35,7 @@ importer.MediaImportHandler = class extends importer.ImportRunner {
* the FileOperationManager (and thus *spawns* an associated
* FileOperationManager.CopyTask) but this is a temporary state of affairs.
*
* @extends {importer.TaskQueue.BaseTask}
* @extends {taskQueueInterfaces.BaseTask}
* @interface
*/
importer.MediaImportHandler.ImportTask = class {
......
......@@ -2,22 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Namespace
var importer = importer || {};
/**
* import.TaskQueue.
* @interface
* @fileoverview
* @suppress {uselessCode, externsValidation} Temporary suppress because of the
* line exporting.
*/
importer.TaskQueue = class {
// clang-format off
// #import {importer} from '../../file_manager/common/js/importer_common.m.js';
// clang-format on
const taskQueueInterfaces = {};
/** @interface */
taskQueueInterfaces.TaskQueue = class {
/**
* @param {!importer.TaskQueue.Task} task
* @param {!taskQueueInterfaces.Task} task
*/
queueTask(task) {}
/**
* Sets a callback to be triggered when a task updates.
* @param {function(string, !importer.TaskQueue.Task)} callback
* @param {function(string, !taskQueueInterfaces.Task)} callback
*/
addUpdateCallback(callback) {}
......@@ -41,14 +47,14 @@ importer.TaskQueue = class {
* Interface for any Task that is to run on the TaskQueue.
* @interface
*/
importer.TaskQueue.Task = class {
taskQueueInterfaces.Task = class {
constructor() {}
/**
* 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.
* @param {!taskQueueInterfaces.Task.Observer} observer A callback
* that will be triggered each time the task has a status update.
*/
addObserver(observer) {}
......@@ -62,23 +68,25 @@ importer.TaskQueue.Task = class {
* Base class for importer tasks.
* @interface
*/
importer.TaskQueue.BaseTask = class extends importer.TaskQueue.Task {
taskQueueInterfaces.BaseTask = class extends taskQueueInterfaces.Task {
/**
* @param {string} taskId
*/
constructor(taskId) {}
constructor(taskId) {
super();
}
/** @return {string} The task ID. */
get taskId() {}
/**
* @return {!Promise<!importer.TaskQueue.UpdateType>} Resolves when task
* @return {!Promise<!importer.UpdateType>} Resolves when task
* is complete, or cancelled, rejects on error.
*/
get whenFinished() {}
/**
* @param {importer.TaskQueue.UpdateType} updateType
* @param {importer.UpdateType} updateType
* @param {Object=} opt_data
* @protected
*/
......@@ -89,9 +97,12 @@ importer.TaskQueue.BaseTask = class extends importer.TaskQueue.Task {
* 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
* importer.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=)}
* @typedef {function(!importer.UpdateType, Object=)}
*/
importer.TaskQueue.Task.Observer;
taskQueueInterfaces.Task.Observer;
// eslint-disable-next-line semi,no-extra-semi
/* #export */ {taskQueueInterfaces};
......@@ -84,6 +84,7 @@ js_type_check("closure_compile_jsmodules") {
":mock_file_operation_manager.m",
":mock_progress_center.m",
":mount_metrics.m",
":task_queue.m",
":test_util_base.m",
":volume_info_impl.m",
":volume_info_list_impl.m",
......@@ -91,6 +92,12 @@ js_type_check("closure_compile_jsmodules") {
":volume_manager_impl.m",
":volume_manager_util.m",
]
closure_flags = strict_error_checking_closure_args + [
"js_module_root=./gen/ui",
"js_module_root=../../ui",
"hide_warnings_for=third_party/",
]
}
js_type_check("test_support_modules_type_check") {
......@@ -725,6 +732,18 @@ js_unittest("task_queue_unittest") {
externs_list = [ "//ui/file_manager/externs/background/task_queue.js" ]
}
js_library("task_queue.m") {
sources = [
"$root_gen_dir/ui/file_manager/file_manager/background/js/task_queue.m.js",
]
deps = [
"//ui/file_manager/externs/background:task_queue.m",
"//ui/file_manager/file_manager/common/js:importer_common.m",
]
extra_deps = [ ":modulize" ]
}
js_library("test_util_base") {
}
......@@ -930,6 +949,7 @@ js_modulizer("modulize") {
"mock_file_operation_manager.js",
"mock_progress_center.js",
"mount_metrics.js",
"task_queue.js",
]
namespace_rewrites = cr_namespace_rewrites
......
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
// Namespace
var importer = importer || {};
window.importer = window.importer || {};
/**
* @enum {string}
......
......@@ -30,8 +30,8 @@ importer.MediaImportHandlerImpl = class {
/** @private {!importer.HistoryLoader} */
this.historyLoader_ = historyLoader;
/** @private {!importer.TaskQueue} */
this.queue_ = new importer.TaskQueueImpl();
/** @private {!taskQueueInterfaces.TaskQueue} */
this.queue_ = new taskQueue.TaskQueueImpl();
// Prevent the system from sleeping while imports are active.
this.queue_.setActiveCallback(() => {
......@@ -104,8 +104,6 @@ importer.MediaImportHandlerImpl = class {
* @private
*/
onTaskProgress_(task, updateType) {
const UpdateType = importer.TaskQueue.UpdateType;
let item = this.progressCenter_.getItemById(task.taskId);
if (!item) {
item = new ProgressCenterItem();
......@@ -120,7 +118,7 @@ importer.MediaImportHandlerImpl = class {
}
switch (updateType) {
case UpdateType.PROGRESS:
case importer.UpdateType.PROGRESS:
item.message =
strf('CLOUD_IMPORT_ITEMS_REMAINING', task.remainingFilesCount);
item.progressValue = task.processedBytes;
......@@ -131,7 +129,7 @@ importer.MediaImportHandlerImpl = class {
item.remainingTime = this.speedometer_.getRemainingTime();
break;
case UpdateType.COMPLETE:
case importer.UpdateType.COMPLETE:
// Remove the event handler that gets attached for retries.
this.driveSyncHandler_.removeEventListener(
this.driveSyncHandler_.getCompletedEventName(),
......@@ -166,7 +164,7 @@ importer.MediaImportHandlerImpl = class {
break;
case UpdateType.CANCELED:
case importer.UpdateType.CANCELED:
item.message = '';
item.state = ProgressItemState.CANCELED;
break;
......@@ -203,7 +201,7 @@ importer.MediaImportHandlerImpl = class {
* @implements {importer.MediaImportHandler.ImportTask}
*/
importer.MediaImportHandler.ImportTaskImpl =
class extends importer.TaskQueue.BaseTaskImpl {
class extends taskQueue.BaseTaskImpl {
/**
* @param {string} taskId
* @param {!importer.HistoryLoader} historyLoader
......@@ -331,7 +329,7 @@ importer.MediaImportHandler.ImportTaskImpl =
requestCancel() {
this.canceled_ = true;
setTimeout(() => {
this.notify(importer.TaskQueue.UpdateType.CANCELED);
this.notify(importer.UpdateType.CANCELED);
this.sendImportStats_();
});
if (this.cancelCallback_) {
......@@ -459,7 +457,7 @@ importer.MediaImportHandler.ImportTaskImpl =
this.processedBytes_ -= currentBytes;
this.processedBytes_ += processedBytes;
currentBytes = processedBytes;
this.notify(importer.TaskQueue.UpdateType.PROGRESS);
this.notify(importer.UpdateType.PROGRESS);
};
/**
......@@ -473,12 +471,12 @@ importer.MediaImportHandler.ImportTaskImpl =
this.processedBytes_ += entry.size;
destinationEntry.size = entry.size;
this.notify(
/** @type {importer.TaskQueue.UpdateType} */
/** @type {importer.UpdateType} */
(importer.MediaImportHandler.ImportTask.UpdateType.ENTRY_CHANGED), {
sourceUrl: sourceUrl,
destination: destinationEntry,
});
this.notify(importer.TaskQueue.UpdateType.PROGRESS);
this.notify(importer.UpdateType.PROGRESS);
};
/**
......@@ -488,7 +486,7 @@ importer.MediaImportHandler.ImportTaskImpl =
const onComplete = destinationEntry => {
this.cancelCallback_ = null;
this.markAsCopied_(entry, /** @type {!FileEntry} */ (destinationEntry));
this.notify(importer.TaskQueue.UpdateType.PROGRESS);
this.notify(importer.UpdateType.PROGRESS);
resolver.resolve(destinationEntry);
};
......@@ -498,11 +496,11 @@ importer.MediaImportHandler.ImportTaskImpl =
if (error.name === util.FileError.ABORT_ERR) {
// Task cancellations result in the error callback being triggered with
// an ABORT_ERR, but we want to ignore these errors.
this.notify(importer.TaskQueue.UpdateType.PROGRESS);
this.notify(importer.UpdateType.PROGRESS);
resolver.resolve(null);
} else {
this.errorCount_++;
this.notify(importer.TaskQueue.UpdateType.ERROR);
this.notify(importer.UpdateType.ERROR);
resolver.reject(error);
}
};
......@@ -555,7 +553,7 @@ importer.MediaImportHandler.ImportTaskImpl =
/** @private */
onSuccess_() {
this.notify(importer.TaskQueue.UpdateType.COMPLETE);
this.notify(importer.UpdateType.COMPLETE);
}
/**
......
......@@ -122,16 +122,16 @@ function testImportMedia(callback) {
const whenImportDone = new Promise((resolve, reject) => {
importTask.addObserver(
/**
* @param {!importer.TaskQueue.UpdateType} updateType
* @param {!importer.UpdateType} updateType
* @param {Object=} opt_task
*/
(updateType, opt_task) => {
switch (updateType) {
case importer.TaskQueue.UpdateType.COMPLETE:
case importer.UpdateType.COMPLETE:
resolve();
break;
case importer.TaskQueue.UpdateType.ERROR:
reject(new Error(importer.TaskQueue.UpdateType.ERROR));
case importer.UpdateType.ERROR:
reject(new Error(importer.UpdateType.ERROR));
break;
}
});
......@@ -182,16 +182,16 @@ function testImportMedia_skipAndMarkDuplicatedFiles(callback) {
const whenImportDone = new Promise((resolve, reject) => {
importTask.addObserver(
/**
* @param {!importer.TaskQueue.UpdateType} updateType
* @param {!importer.UpdateType} updateType
* @param {Object=} opt_task
*/
(updateType, opt_task) => {
switch (updateType) {
case importer.TaskQueue.UpdateType.COMPLETE:
case importer.UpdateType.COMPLETE:
resolve();
break;
case importer.TaskQueue.UpdateType.ERROR:
reject(new Error(importer.TaskQueue.UpdateType.ERROR));
case importer.UpdateType.ERROR:
reject(new Error(importer.UpdateType.ERROR));
break;
}
});
......@@ -236,16 +236,16 @@ function testImportMedia_EmploysEncodedUrls(callback) {
new Promise((resolve, reject) => {
importTask.addObserver(
/**
* @param {!importer.TaskQueue.UpdateType} updateType
* @param {!importer.UpdateType} updateType
* @param {Object=} opt_task
*/
(updateType, opt_task) => {
switch (updateType) {
case importer.TaskQueue.UpdateType.COMPLETE:
case importer.UpdateType.COMPLETE:
resolve(/** @type {!MockDirectoryEntry} */
(destinationFileSystem.root).getAllChildren());
break;
case importer.TaskQueue.UpdateType.ERROR:
case importer.UpdateType.ERROR:
reject('Task failed :(');
break;
}
......@@ -284,16 +284,16 @@ function testImportMediaWithDuplicateFilenames(callback) {
const whenImportDone = new Promise((resolve, reject) => {
importTask.addObserver(
/**
* @param {!importer.TaskQueue.UpdateType} updateType
* @param {!importer.UpdateType} updateType
* @param {Object=} opt_task
*/
(updateType, opt_task) => {
switch (updateType) {
case importer.TaskQueue.UpdateType.COMPLETE:
case importer.UpdateType.COMPLETE:
resolve();
break;
case importer.TaskQueue.UpdateType.ERROR:
reject(new Error(importer.TaskQueue.UpdateType.ERROR));
case importer.UpdateType.ERROR:
reject(new Error(importer.UpdateType.ERROR));
break;
}
});
......@@ -332,18 +332,18 @@ function testKeepAwakeDuringImport(callback) {
const whenImportDone = new Promise((resolve, reject) => {
importTask.addObserver(
/**
* @param {!importer.TaskQueue.UpdateType} updateType
* @param {!importer.UpdateType} updateType
* @param {Object=} opt_task
*/
(updateType, opt_task) => {
// Assert that keepAwake is set while the task is active.
assertTrue(mockChrome.power.requestKeepAwakeStatus);
switch (updateType) {
case importer.TaskQueue.UpdateType.COMPLETE:
case importer.UpdateType.COMPLETE:
resolve();
break;
case importer.TaskQueue.UpdateType.ERROR:
reject(new Error(importer.TaskQueue.UpdateType.ERROR));
case importer.UpdateType.ERROR:
reject(new Error(importer.UpdateType.ERROR));
break;
}
});
......@@ -385,16 +385,16 @@ function testUpdatesHistoryAfterImport(callback) {
const whenImportDone = new Promise((resolve, reject) => {
importTask.addObserver(
/**
* @param {!importer.TaskQueue.UpdateType} updateType
* @param {!importer.UpdateType} updateType
* @param {Object=} opt_task
*/
(updateType, opt_task) => {
switch (updateType) {
case importer.TaskQueue.UpdateType.COMPLETE:
case importer.UpdateType.COMPLETE:
resolve();
break;
case importer.TaskQueue.UpdateType.ERROR:
reject(new Error(importer.TaskQueue.UpdateType.ERROR));
case importer.UpdateType.ERROR:
reject(new Error(importer.UpdateType.ERROR));
break;
}
});
......@@ -442,11 +442,11 @@ function testImportCancellation(callback) {
const whenImportCancelled = new Promise((resolve, reject) => {
importTask.addObserver(
/**
* @param {!importer.TaskQueue.UpdateType} updateType
* @param {!importer.UpdateType} updateType
* @param {Object=} opt_task
*/
(updateType, opt_task) => {
if (updateType === importer.TaskQueue.UpdateType.CANCELED) {
if (updateType === importer.UpdateType.CANCELED) {
resolve();
}
});
......@@ -503,11 +503,11 @@ function testImportWithErrors(callback) {
const whenImportDone = new Promise((resolve, reject) => {
importTask.addObserver(
/**
* @param {!importer.TaskQueue.UpdateType} updateType
* @param {!importer.UpdateType} updateType
* @param {Object=} opt_task
*/
(updateType, opt_task) => {
if (updateType === importer.TaskQueue.UpdateType.COMPLETE) {
if (updateType === importer.UpdateType.COMPLETE) {
resolve();
}
});
......@@ -546,7 +546,7 @@ function testImportWithErrors(callback) {
* @return {!Array<!Entry>}
*/
function setupFileSystem(fileNames) {
let fileSystem = new MockFileSystem('fake-media-volume');
const fileSystem = new MockFileSystem('fake-media-volume');
fileSystem.populate(fileNames);
return fileNames.map((name) => fileSystem.entries[name]);
}
......
......@@ -2,13 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Namespace
var importer = importer || {};
/**
* @fileoverview
* @suppress {uselessCode} Temporary suppress because of the line exporting.
*/
// clang-format off
// #import {importer} from '../../common/js/importer_common.m.js';
// #import {taskQueueInterfaces} from '../../../externs/background/task_queue.m.js';
// clang-format on
importer.TaskQueue = importer.TaskQueue || {};
// Namespace
const taskQueue = {};
/**
* A queue of tasks. Tasks (subclasses of TaskQueue.Task) can be pushed onto
* A queue of tasks. Tasks (subclasses of 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
......@@ -17,14 +25,16 @@ importer.TaskQueue = importer.TaskQueue || {};
* be triggered whenever the queue transitions between the active and idle
* states.
*
* @implements {importer.TaskQueue}
* @implements {taskQueueInterfaces.TaskQueue}
*/
importer.TaskQueueImpl = class {
taskQueue.TaskQueueImpl = class {
constructor() {
/** @private {!Array<!importer.TaskQueue.Task>} */
/** @private {!Array<!taskQueueInterfaces.Task>} */
this.tasks_ = [];
/** @private {!Array<!function(string, !importer.TaskQueue.Task)>} */
/**
* @private {!Array<!function(string, !taskQueueInterfaces.Task)>}
*/
this.updateCallbacks_ = [];
/** @private {?function()} */
......@@ -38,7 +48,7 @@ importer.TaskQueueImpl = class {
}
/**
* @param {!importer.TaskQueue.Task} task
* @param {!taskQueueInterfaces.Task} task
*/
queueTask(task) {
// The Tasks that are pushed onto the queue aren't required to be inherently
......@@ -55,7 +65,7 @@ importer.TaskQueueImpl = class {
/**
* Sets a callback to be triggered when a task updates.
* @param {function(string, !importer.TaskQueue.Task)} callback
* @param {function(string, !taskQueueInterfaces.Task)} callback
*/
addUpdateCallback(callback) {
this.updateCallbacks_.push(callback);
......@@ -83,8 +93,8 @@ importer.TaskQueueImpl = class {
/**
* Sends out notifications when a task updates. This is meant to be called by
* the running tasks owned by this queue.
* @param {!importer.TaskQueue.Task} task
* @param {!importer.TaskQueue.UpdateType} updateType
* @param {!taskQueueInterfaces.Task} task
* @param {!importer.UpdateType} updateType
* @private
*/
onTaskUpdate_(task, updateType) {
......@@ -94,9 +104,8 @@ importer.TaskQueueImpl = class {
});
// If the task update is a terminal one, move on to the next task.
const UpdateType = importer.TaskQueue.UpdateType;
if (updateType === UpdateType.COMPLETE ||
updateType === UpdateType.CANCELED) {
if (updateType === importer.UpdateType.COMPLETE ||
updateType === importer.UpdateType.CANCELED) {
// Assumption: the currently running task is at the head of the queue.
console.assert(
this.tasks_[0] === task,
......@@ -139,9 +148,9 @@ importer.TaskQueueImpl = class {
/**
* Base class for importer tasks.
* @implements {importer.TaskQueue.Task}
* @implements {taskQueueInterfaces.Task}
*/
importer.TaskQueue.BaseTaskImpl = class {
taskQueue.BaseTaskImpl = class {
/**
* @param {string} taskId
*/
......@@ -149,10 +158,10 @@ importer.TaskQueue.BaseTaskImpl = class {
/** @protected {string} */
this.taskId_ = taskId;
/** @private {!Array<!importer.TaskQueue.Task.Observer>} */
/** @private {!Array<!taskQueueInterfaces.Task.Observer>} */
this.observers_ = [];
/** @private {!importer.Resolver<!importer.TaskQueue.UpdateType>} */
/** @private {!importer.Resolver<!importer.UpdateType>} */
this.finishedResolver_ = new importer.Resolver();
}
/** @return {string} The task ID. */
......@@ -161,7 +170,7 @@ importer.TaskQueue.BaseTaskImpl = class {
}
/**
* @return {!Promise<!importer.TaskQueue.UpdateType>} Resolves when task
* @return {!Promise<!importer.UpdateType>} Resolves when task
* is complete, or cancelled, rejects on error.
*/
get whenFinished() {
......@@ -177,14 +186,14 @@ importer.TaskQueue.BaseTaskImpl = class {
run() {}
/**
* @param {importer.TaskQueue.UpdateType} updateType
* @param {importer.UpdateType} updateType
* @param {Object=} opt_data
* @protected
*/
notify(updateType, opt_data) {
switch (updateType) {
case importer.TaskQueue.UpdateType.CANCELED:
case importer.TaskQueue.UpdateType.COMPLETE:
case importer.UpdateType.CANCELED:
case importer.UpdateType.COMPLETE:
this.finishedResolver_.resolve(updateType);
}
......@@ -193,3 +202,6 @@ importer.TaskQueue.BaseTaskImpl = class {
});
}
};
// eslint-disable-next-line semi,no-extra-semi
/* #export */ {taskQueue};
......@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/** @type {!importer.TaskQueue} */
/** @type {!taskQueueInterfaces.TaskQueue} */
let queue;
/** @type {!Object<importer.TaskQueue.UpdateType, number>} */
/** @type {!Object<importer.UpdateType, number>} */
const updates = {};
function setUp() {
queue = new importer.TaskQueueImpl();
queue = new taskQueue.TaskQueueImpl();
// Set up a callback to log updates from running tasks.
for (const updateType in importer.TaskQueue.UpdateType) {
for (const updateType in importer.UpdateType) {
// Reset counts for all update types.
updates[importer.TaskQueue.UpdateType[updateType]] = 0;
updates[importer.UpdateType[updateType]] = 0;
}
// Counts the number of updates of each type that have been received.
......@@ -27,7 +27,7 @@ function setUp() {
/**
* A Task subclass for testing.
*/
class TestTask extends importer.TaskQueue.BaseTaskImpl {
class TestTask extends taskQueue.BaseTaskImpl {
/**
* @param {string} taskId
*/
......@@ -55,22 +55,22 @@ class TestTask extends importer.TaskQueue.BaseTaskImpl {
/** Sends a quick error notification. */
notifyError() {
this.notify(importer.TaskQueue.UpdateType.ERROR);
this.notify(importer.UpdateType.ERROR);
}
/** Sends a quick completion notification. */
notifyComplete() {
this.notify(importer.TaskQueue.UpdateType.COMPLETE);
this.notify(importer.UpdateType.COMPLETE);
}
/** Sends a quick cancelled notification. */
notifyCanceled() {
this.notify(importer.TaskQueue.UpdateType.CANCELED);
this.notify(importer.UpdateType.CANCELED);
}
/** Sends a quick progress notification. */
notifyProgress() {
this.notify(importer.TaskQueue.UpdateType.PROGRESS);
this.notify(importer.UpdateType.PROGRESS);
}
/** @return {!Promise} A promise that settles once #run is called. */
......@@ -165,7 +165,7 @@ function testProgressUpdate(callback) {
const whenDone = new Promise(resolve => {
queue.setIdleCallback(() => {
// Verify that progress was recorded.
assertEquals(1, updates[importer.TaskQueue.UpdateType.PROGRESS]);
assertEquals(1, updates[importer.UpdateType.PROGRESS]);
resolve();
});
});
......@@ -189,7 +189,7 @@ function testSuccessUpdate(callback) {
const whenDone = new Promise(resolve => {
queue.setIdleCallback(() => {
// Verify that the done callback was called.
assertEquals(1, updates[importer.TaskQueue.UpdateType.COMPLETE]);
assertEquals(1, updates[importer.UpdateType.COMPLETE]);
resolve();
});
});
......@@ -214,7 +214,7 @@ function testErrorUpdate(callback) {
const whenDone = new Promise(resolve => {
queue.setIdleCallback(() => {
// Verify that the done callback was called.
assertEquals(1, updates[importer.TaskQueue.UpdateType.ERROR]);
assertEquals(1, updates[importer.UpdateType.ERROR]);
resolve();
});
});
......
......@@ -56,6 +56,12 @@ js_type_check("closure_compile_jsmodules") {
":trash.m",
":util.m",
]
closure_flags = strict_error_checking_closure_args + [
"js_module_root=./gen/ui",
"js_module_root=../../ui",
"hide_warnings_for=third_party/",
]
}
js_type_check("test_support_type_check") {
......@@ -214,6 +220,7 @@ js_library("test_importer_common.m") {
js_unittest("importer_common_unittest.m") {
deps = [
":importer_common.m",
":mock_entry.m",
":test_importer_common.m",
"//chrome/test/data/webui:chai_assert",
......
......@@ -19,12 +19,10 @@
// eslint-disable-next-line no-var
var importer = importer || {};
importer.TaskQueue = importer.TaskQueue || {};
/**
* @enum {string}
*/
importer.TaskQueue.UpdateType = {
importer.UpdateType = {
PROGRESS: 'PROGRESS',
COMPLETE: 'COMPLETE',
ERROR: 'ERROR',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment