Commit 44b8aeca authored by François Degros's avatar François Degros Committed by Commit Bot

[Files app] ES6 class for progress_center.js and mock_progress_center.js

Bug: 778674
Change-Id: I3152edd3fcfc7b96a2bf24ed828faf344ca94a0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1614757Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Auto-Submit: François Degros <fdegros@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660268}
parent 86280c24
......@@ -4,41 +4,39 @@
/**
* Progress center at the background page.
*
* @interface
*/
var ProgressCenter = function() {};
class ProgressCenter {
/**
* Updates the item in the progress center.
* If the item has a new ID, the item is added to the item list.
* @param {ProgressCenterItem} item Updated item.
*/
updateItem(item) {}
/**
* Updates the item in the progress center.
* If the item has a new ID, the item is added to the item list.
*
* @param {ProgressCenterItem} item Updated item.
*/
ProgressCenter.prototype.updateItem = function(item) {};
/**
* Requests to cancel the progress item.
* @param {string} id Progress ID to be requested to cancel.
*/
requestCancel(id) {}
/**
* Requests to cancel the progress item.
* @param {string} id Progress ID to be requested to cancel.
*/
ProgressCenter.prototype.requestCancel = function(id) {};
/**
* Adds a panel UI to the notification center.
* @param {ProgressCenterPanel} panel Panel UI.
*/
addPanel(panel) {}
/**
* Adds a panel UI to the notification center.
* @param {ProgressCenterPanel} panel Panel UI.
*/
ProgressCenter.prototype.addPanel = function(panel) {};
/**
* Removes a panel UI from the notification center.
* @param {ProgressCenterPanel} panel Panel UI.
*/
removePanel(panel) {}
/**
* Removes a panel UI from the notification center.
* @param {ProgressCenterPanel} panel Panel UI.
*/
ProgressCenter.prototype.removePanel = function(panel) {};
/**
* Obtains item by ID.
* @param {string} id ID of progress item.
* @return {ProgressCenterItem} Progress center item having the specified
* ID. Null if the item is not found.
*/
ProgressCenter.prototype.getItemById = function(id) {};
/**
* Obtains item by ID.
* @param {string} id ID of progress item.
* @return {?ProgressCenterItem} Progress center item having the specified
* ID. Null if the item is not found.
*/
getItemById(id) {}
}
......@@ -5,47 +5,45 @@
/**
* Mock implementation of {ProgressCenter} for tests.
*
* @constructor
* @struct
* @implements {ProgressCenter}
* @final
*/
function MockProgressCenter() {
class MockProgressCenter {
constructor() {
/**
* Items stored in the progress center.
* @const {!Object<ProgressCenterItem>}
*/
this.items = {};
}
/**
* Items stored in the progress center.
* @type {Object<ProgressCenterItem>}
* Stores an item to the progress center.
* @param {ProgressCenterItem} item Progress center item to be stored.
*/
this.items = {};
}
/**
* Stores an item to the progress center.
* @param {ProgressCenterItem} item Progress center item to be stored.
*/
MockProgressCenter.prototype.updateItem = function(item) {
this.items[item.id] = item;
};
/**
* Obtains an item stored in the progress center.
* @param {string} id ID spcifying the progress item.
*/
MockProgressCenter.prototype.getItemById = function(id) {
return this.items[id];
};
updateItem(item) {
this.items[item.id] = item;
}
MockProgressCenter.prototype.requestCancel = () => {};
MockProgressCenter.prototype.addPanel = () => {};
/**
* Obtains an item stored in the progress center.
* @param {string} id ID spcifying the progress item.
*/
getItemById(id) {
return this.items[id];
}
MockProgressCenter.prototype.removePanel = () => {};
requestCancel() {}
addPanel() {}
removePanel() {}
/**
* Returns the number of unique keys in |this.items|.
* @return {number}
*/
MockProgressCenter.prototype.getItemCount = function() {
const array = Object.keys(
/** @type {!Object} */ (this.items));
return array.length;
};
/**
* Returns the number of unique keys in |this.items|.
* @return {number}
*/
getItemCount() {
const array = Object.keys(
/** @type {!Object} */ (this.items));
return array.length;
}
}
......@@ -4,8 +4,7 @@
/**
* Event of the ProgressCenter class.
* @enum {string}
* @const
* @const @enum {string}
*/
const ProgressCenterEvent = {
/**
......@@ -22,8 +21,7 @@ Object.freeze(ProgressCenterEvent);
/**
* State of progress items.
* @enum {string}
* @const
* @const @enum {string}
*/
const ProgressItemState = {
PROGRESSING: 'progressing',
......@@ -35,8 +33,7 @@ Object.freeze(ProgressItemState);
/**
* Type of progress items.
* @enum {string}
* @const
* @const @enum {string}
*/
const ProgressItemType = {
// The item is file copy operation.
......@@ -62,8 +59,7 @@ class ProgressCenterItem {
constructor() {
/**
* Item ID.
* @type {string}
* @private
* @private {string}
*/
this.id_ = '';
......
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