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 @@ ...@@ -4,41 +4,39 @@
/** /**
* Progress center at the background page. * Progress center at the background page.
*
* @interface * @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. * Requests to cancel the progress item.
* If the item has a new ID, the item is added to the item list. * @param {string} id Progress ID to be requested to cancel.
* */
* @param {ProgressCenterItem} item Updated item. requestCancel(id) {}
*/
ProgressCenter.prototype.updateItem = function(item) {};
/** /**
* Requests to cancel the progress item. * Adds a panel UI to the notification center.
* @param {string} id Progress ID to be requested to cancel. * @param {ProgressCenterPanel} panel Panel UI.
*/ */
ProgressCenter.prototype.requestCancel = function(id) {}; addPanel(panel) {}
/** /**
* Adds a panel UI to the notification center. * Removes a panel UI from the notification center.
* @param {ProgressCenterPanel} panel Panel UI. * @param {ProgressCenterPanel} panel Panel UI.
*/ */
ProgressCenter.prototype.addPanel = function(panel) {}; removePanel(panel) {}
/** /**
* Removes a panel UI from the notification center. * Obtains item by ID.
* @param {ProgressCenterPanel} panel Panel UI. * @param {string} id ID of progress item.
*/ * @return {?ProgressCenterItem} Progress center item having the specified
ProgressCenter.prototype.removePanel = function(panel) {}; * ID. Null if the item is not found.
*/
/** getItemById(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.
*/
ProgressCenter.prototype.getItemById = function(id) {};
...@@ -5,47 +5,45 @@ ...@@ -5,47 +5,45 @@
/** /**
* Mock implementation of {ProgressCenter} for tests. * Mock implementation of {ProgressCenter} for tests.
*
* @constructor
* @struct
* @implements {ProgressCenter} * @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. * Stores an item to the progress center.
* @type {Object<ProgressCenterItem>} * @param {ProgressCenterItem} item Progress center item to be stored.
*/ */
this.items = {}; updateItem(item) {
} this.items[item.id] = item;
}
/**
* 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];
};
MockProgressCenter.prototype.requestCancel = () => {}; /**
* Obtains an item stored in the progress center.
MockProgressCenter.prototype.addPanel = () => {}; * @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|. * Returns the number of unique keys in |this.items|.
* @return {number} * @return {number}
*/ */
MockProgressCenter.prototype.getItemCount = function() { getItemCount() {
const array = Object.keys( const array = Object.keys(
/** @type {!Object} */ (this.items)); /** @type {!Object} */ (this.items));
return array.length; return array.length;
}; }
}
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
/** /**
* Event of the ProgressCenter class. * Event of the ProgressCenter class.
* @enum {string} * @const @enum {string}
* @const
*/ */
const ProgressCenterEvent = { const ProgressCenterEvent = {
/** /**
...@@ -22,8 +21,7 @@ Object.freeze(ProgressCenterEvent); ...@@ -22,8 +21,7 @@ Object.freeze(ProgressCenterEvent);
/** /**
* State of progress items. * State of progress items.
* @enum {string} * @const @enum {string}
* @const
*/ */
const ProgressItemState = { const ProgressItemState = {
PROGRESSING: 'progressing', PROGRESSING: 'progressing',
...@@ -35,8 +33,7 @@ Object.freeze(ProgressItemState); ...@@ -35,8 +33,7 @@ Object.freeze(ProgressItemState);
/** /**
* Type of progress items. * Type of progress items.
* @enum {string} * @const @enum {string}
* @const
*/ */
const ProgressItemType = { const ProgressItemType = {
// The item is file copy operation. // The item is file copy operation.
...@@ -62,8 +59,7 @@ class ProgressCenterItem { ...@@ -62,8 +59,7 @@ class ProgressCenterItem {
constructor() { constructor() {
/** /**
* Item ID. * Item ID.
* @type {string} * @private {string}
* @private
*/ */
this.id_ = ''; 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