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

[Files app] Removed callback from volumeManagerFactory.getInstance()

Change-Id: Id668076353fc0a3a956fe7c742a3971c1d4f6f78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1619451
Commit-Queue: François Degros <fdegros@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Auto-Submit: François Degros <fdegros@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661278}
parent 5955f245
...@@ -105,11 +105,14 @@ class FilteredVolumeManager extends cr.EventTarget { ...@@ -105,11 +105,14 @@ class FilteredVolumeManager extends cr.EventTarget {
}); });
} }
queue.run(callNextStep => { queue.run(async (callNextStep) => {
this.backgroundPage_.volumeManagerFactory.getInstance(volumeManager => { try {
const volumeManager =
await this.backgroundPage_.volumeManagerFactory.getInstance();
this.onReady_(volumeManager); this.onReady_(volumeManager);
} finally {
callNextStep(); callNextStep();
}); }
}); });
} }
......
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
var volumeManagerFactory = {}; var volumeManagerFactory = {};
/** /**
* @param {function(VolumeManager)=} opt_callback * @return {!Promise<!VolumeManager>}
* @return {Promise}
*/ */
volumeManagerFactory.getInstance = function(opt_callback) {}; volumeManagerFactory.getInstance = function() {};
/** /**
* @return {VolumeManager} * @return {VolumeManager}
......
...@@ -19,21 +19,15 @@ var volumeManagerFactory = (() => { ...@@ -19,21 +19,15 @@ var volumeManagerFactory = (() => {
* Returns the VolumeManager instance asynchronously. If it has not been * Returns the VolumeManager instance asynchronously. If it has not been
* created or is under initialization, it will waits for the finish of the * created or is under initialization, it will waits for the finish of the
* initialization. * initialization.
* @param {function(VolumeManager)=} opt_callback Called with the
* VolumeManager instance. TODO(hirono): Remove the callback and use
* Promise instead.
* @return {!Promise<!VolumeManager>} Promise to be fulfilled with the volume * @return {!Promise<!VolumeManager>} Promise to be fulfilled with the volume
* manager. * manager.
*/ */
function getInstance(opt_callback) { function getInstance() {
if (!instancePromise) { if (!instancePromise) {
instance = new VolumeManagerImpl(); instance = new VolumeManagerImpl();
instancePromise = instancePromise =
new Promise(fulfill => instance.initialize(() => fulfill(instance))); new Promise(fulfill => instance.initialize(() => fulfill(instance)));
} }
if (opt_callback) {
instancePromise.then(opt_callback);
}
return instancePromise; return instancePromise;
} }
......
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