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

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

Issue 893913003: Files.app: Fix closure compiler error. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 5 years, 11 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
« no previous file with comments | « no previous file | ui/file_manager/file_manager/background/js/volume_manager_unittest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 660ec4dab53c75834ad6b56e89ffb1f6a5d03680..9c3850abe21ecaabe68371ec90f55c06d977dc1d 100644
--- a/ui/file_manager/file_manager/background/js/volume_manager.js
+++ b/ui/file_manager/file_manager/background/js/volume_manager.js
@@ -355,9 +355,6 @@ function VolumeInfoList() {
(volumeManagerUtil.compareVolumeInfo_));
this.model_.sort(field, 'asc');
- /** @private {!Object.<string, !importer.Resolver.<!VolumeInfo>>} */
- this.volumeInfoResolvers_ = {};
-
Object.freeze(this);
}
@@ -394,14 +391,6 @@ VolumeInfoList.prototype.add = function(volumeInfo) {
this.model_.splice(index, 1, volumeInfo);
else
this.model_.push(volumeInfo);
-
- // Some folks might be expecting this volume to be initialized soon.
- // In that case there'll be a resolver function (associated with a promise)
- // waiting for us here.
- var resolver = this.volumeInfoResolvers_[volumeInfo.volumeId];
- if (resolver) {
- resolver.resolve(volumeInfo);
- }
};
/**
@@ -412,9 +401,6 @@ VolumeInfoList.prototype.remove = function(volumeId) {
var index = this.findIndex(volumeId);
if (index !== -1)
this.model_.splice(index, 1);
-
- // Remove any associated resolvers.
- delete this.volumeInfoResolvers_[volumeId];
};
/**
@@ -491,18 +477,17 @@ VolumeInfoList.prototype.findByVolumeId_ = function(volumeId) {
* if the volume is never mounted.
*/
VolumeInfoList.prototype.whenVolumeInfoReady = function(volumeId) {
- var info = this.findByVolumeId_(volumeId);
- if (!!info) {
- return Promise.resolve(info);
- }
-
- var resolver = this.volumeInfoResolvers_[volumeId];
- if (!resolver) {
- resolver = new importer.Resolver();
- this.volumeInfoResolvers_[volumeId] = resolver;
- }
-
- return resolver.promise;
+ return new Promise(function(fulfill) {
+ var handler = function() {
+ var info = this.findByVolumeId_(volumeId);
+ if (info) {
+ fulfill(info);
+ this.model_.removeEventListener('splice', handler);
+ }
+ }.bind(this);
+ this.model_.addEventListener('splice', handler);
+ handler();
+ }.bind(this));
};
/**
« no previous file with comments | « no previous file | ui/file_manager/file_manager/background/js/volume_manager_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698