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

Unified Diff: ui/file_manager/file_manager/background/js/volume_manager.js

Issue 651403002: Fix trivial type-check errors in file_manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and correct a comment. Created 6 years, 2 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/file_manager/background/js/volume_manager.js
diff --git a/ui/file_manager/file_manager/background/js/volume_manager.js b/ui/file_manager/file_manager/background/js/volume_manager.js
index 64300d2f7a3f9b884469102a92b31fb3563ac559..1f0704ac80dfb4375f5a09f07678bb1a8b8cdbdb 100644
--- a/ui/file_manager/file_manager/background/js/volume_manager.js
+++ b/ui/file_manager/file_manager/background/js/volume_manager.js
@@ -11,18 +11,18 @@
* @param {VolumeManagerCommon.VolumeType} volumeType The type of the volume.
* @param {string} volumeId ID of the volume.
* @param {FileSystem} fileSystem The file system object for this volume.
- * @param {string} error The error if an error is found.
- * @param {?string} deviceType The type of device ('usb'|'sd'|'optical'|'mobile'
- * |'unknown') (as defined in chromeos/disks/disk_mount_manager.cc).
- * Can be null.
- * @param {?string} devicePath Identifier of the device that the volume belongs
- * to. Can be null.
+ * @param {(string|undefined)} error The error if an error is found.
+ * @param {(string|undefined)} deviceType The type of device
+ * ('usb'|'sd'|'optical'|'mobile'|'unknown') (as defined in
+ * chromeos/disks/disk_mount_manager.cc). Can be undefined.
+ * @param {(string|undefined)} devicePath Identifier of the device that the
+ * volume belongs to. Can be undefined.
* @param {boolean} isReadOnly True if the volume is read only.
* @param {!{displayName:string, isCurrentProfile:boolean}} profile Profile
* information.
* @param {string} label Label of the volume.
- * @param {string} extensionId Id of the extension providing this volume. Empty
- * for native volumes.
+ * @param {(string|undefined)} extensionId Id of the extension providing this
+ * volume. Empty for native volumes.
* @constructor
*/
function VolumeInfo(
@@ -110,19 +110,19 @@ VolumeInfo.prototype = {
return this.fakeEntries_;
},
/**
- * @return {string} Error identifier.
+ * @return {(string|undefined)} Error identifier.
*/
get error() {
return this.error_;
},
/**
- * @return {string} Device type identifier.
+ * @return {(string|undefined)} Device type identifier.
*/
get deviceType() {
return this.deviceType_;
},
/**
- * @return {string} Device identifier.
+ * @return {(string|undefined)} Device identifier.
*/
get devicePath() {
return this.devicePath_;
@@ -146,7 +146,7 @@ VolumeInfo.prototype = {
return this.label_;
},
/**
- * @return {string} Id of an extennsion providing this volume.
+ * @return {(string|undefined)} Id of an extennsion providing this volume.
*/
get extensionId() {
return this.extensionId_;
@@ -198,8 +198,7 @@ var volumeManagerUtil = {};
* Throws an Error when the given error is not in
* VolumeManagerCommon.VolumeError.
*
- * @param {VolumeManagerCommon.VolumeError} error Status string usually received
- * from APIs.
+ * @param {string} error Status string usually received from APIs.
*/
volumeManagerUtil.validateError = function(error) {
for (var key in VolumeManagerCommon.VolumeError) {
@@ -239,7 +238,8 @@ volumeManagerUtil.createVolumeInfo = function(volumeMetadata, callback) {
if (!fileSystem) {
console.error('File system not found: ' + volumeMetadata.volumeId);
callback(new VolumeInfo(
- volumeMetadata.volumeType,
+ /** @type {VolumeManagerCommon.VolumeType} */
+ (volumeMetadata.volumeType),
volumeMetadata.volumeId,
null, // File system is not found.
volumeMetadata.mountCondition,
@@ -266,7 +266,8 @@ volumeManagerUtil.createVolumeInfo = function(volumeMetadata, callback) {
});
}
callback(new VolumeInfo(
- volumeMetadata.volumeType,
+ /** @type {VolumeManagerCommon.VolumeType} */
+ (volumeMetadata.volumeType),
volumeMetadata.volumeId,
fileSystem,
volumeMetadata.mountCondition,
@@ -301,8 +302,8 @@ volumeManagerUtil.volumeListOrder_ = [
* The volumes at first are compared by volume type in the order of
* volumeListOrder_. Then they are compared by volume ID.
*
- * @param {VolumeInfo} volumeInfo1 Volume info to be compared.
- * @param {VolumeInfo} volumeInfo2 Volume info to be compared.
+ * @param {!VolumeInfo} volumeInfo1 Volume info to be compared.
+ * @param {!VolumeInfo} volumeInfo2 Volume info to be compared.
* @return {number} Returns -1 if volume1 < volume2, returns 1 if volume2 >
* volume1, returns 0 if volume1 === volume2.
* @private
@@ -332,7 +333,9 @@ function VolumeInfoList() {
* @private
*/
this.model_ = new cr.ui.ArrayDataModel([]);
- this.model_.setCompareFunction(field, volumeManagerUtil.compareVolumeInfo_);
+ this.model_.setCompareFunction(field,
+ /** @type {function(*, *): number} */
+ (volumeManagerUtil.compareVolumeInfo_));
this.model_.sort(field, 'asc');
Object.freeze(this);
@@ -420,10 +423,10 @@ VolumeInfoList.prototype.findByEntry = function(entry) {
/**
* @param {number} index The index of the volume in the list.
- * @return {VolumeInfo} The VolumeInfo instance.
+ * @return {!VolumeInfo} The VolumeInfo instance.
*/
VolumeInfoList.prototype.item = function(index) {
- return this.model_.item(index);
+ return /** @type {!VolumeInfo} */ (this.model_.item(index));
};
/**
@@ -456,6 +459,11 @@ function VolumeManager() {
// The status should be merged into VolumeManager.
// TODO(hidehiko): Remove them after the migration.
+ /**
+ * Connection state of the Drive.
+ * @type {VolumeManagerCommon.DriveConnectionState}
+ * @private
+ */
this.driveConnectionState_ = {
type: VolumeManagerCommon.DriveConnectionType.OFFLINE,
reason: VolumeManagerCommon.DriveConnectionReason.NO_SERVICE
@@ -468,7 +476,7 @@ function VolumeManager() {
/**
* Invoked when the drive connection status is changed.
- * @private_
+ * @private
*/
VolumeManager.prototype.onDriveConnectionStatusChanged_ = function() {
chrome.fileManagerPrivate.getDriveConnectionState(function(state) {
@@ -479,7 +487,7 @@ VolumeManager.prototype.onDriveConnectionStatusChanged_ = function() {
/**
* Returns the drive connection state.
- * @return {VolumeManagerCommon.DriveConnectionType} Connection type.
+ * @return {VolumeManagerCommon.DriveConnectionState} Connection state.
*/
VolumeManager.prototype.getDriveConnectionState = function() {
return this.driveConnectionState_;
@@ -520,11 +528,11 @@ VolumeManager.instancePromise_ = null;
/**
* Returns the VolumeManager instance asynchronously. If it is not created or
* under initialization, it will waits for the finish of the initialization.
- * @param {function(VolumeManager)} callback Called with the VolumeManager
+ * @param {function(VolumeManager)=} opt_callback Called with the VolumeManager
* instance. TODO(hirono): Remove the callback and use Promise instead.
* @return {Promise} Promise to be fulfilled with the volume manager.
*/
-VolumeManager.getInstance = function(callback) {
+VolumeManager.getInstance = function(opt_callback) {
if (!VolumeManager.instancePromise_) {
VolumeManager.instance_ = new VolumeManager();
VolumeManager.instancePromise_ = new Promise(function(fulfill) {
@@ -533,8 +541,8 @@ VolumeManager.getInstance = function(callback) {
});
});
}
- if (callback)
- VolumeManager.instancePromise_.then(callback);
+ if (opt_callback)
+ VolumeManager.instancePromise_.then(opt_callback);
return VolumeManager.instancePromise_;
};
« no previous file with comments | « ui/file_manager/file_manager/background/js/progress_center.js ('k') | ui/file_manager/file_manager/common/js/externs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698