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

Unified Diff: ui/file_manager/image_loader/piex_loader.js

Issue 2675193005: Remove rejected promise of PiexLoader which is not caught. (Closed)
Patch Set: Created 3 years, 10 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/image_loader/request.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/image_loader/piex_loader.js
diff --git a/ui/file_manager/image_loader/piex_loader.js b/ui/file_manager/image_loader/piex_loader.js
index e506e3a4d03f208f61e9f521ce9cdfe7c45cbf86..a7b81f4ad4f412fdacc3853c6816ea7891efeec8 100644
--- a/ui/file_manager/image_loader/piex_loader.js
+++ b/ui/file_manager/image_loader/piex_loader.js
@@ -65,14 +65,14 @@ function PiexLoader() {
this.naclModule_ = document.createElement('embed');
/**
- * @private {!Promise}
+ * @private {!Promise<boolean>}
* @const
*/
this.naclPromise_ = new Promise(function(fulfill) {
chrome.fileManagerPrivate.isPiexLoaderEnabled(fulfill);
}).then(function(enabled) {
if (!enabled)
- return Promise.reject('PiexLoader is not enabled for chromium build.');
+ return false;
return new Promise(function(fulfill, reject) {
var embed = this.naclModule_;
embed.setAttribute('type', 'application/x-pnacl');
@@ -99,8 +99,12 @@ function PiexLoader() {
}.bind(this), true);
listenerContainer.style.height = '0px';
document.body.appendChild(listenerContainer);
+ return true;
oka 2017/02/07 17:01:33 wondering why it's not fulfill(true).
hirono 2017/02/09 03:52:55 Yes, the line is wrong. Removed this and updated #
}.bind(this));
- }.bind(this));
+ }.bind(this)).catch(function (error) {
+ console.error(error);
+ return false;
+ });
/**
* @private {!Object<number, PiexRequestCallbacks>}
@@ -135,7 +139,9 @@ PiexLoader.prototype.onMessage_ = function(event) {
* @return {!Promise<!PiexLoaderResponse>}
*/
PiexLoader.prototype.load = function(url) {
- return this.naclPromise_.then(function() {
+ return this.naclPromise_.then(function(loaded) {
+ if (!loaded)
+ return Promise.reject('Piex is not loaded');
var message = {
id: this.requestIdCount_++,
name: 'loadThumbnail',
@@ -144,6 +150,9 @@ PiexLoader.prototype.load = function(url) {
this.naclModule_.postMessage(message);
return new Promise(function(fulfill, reject) {
this.requests_[message.id] = {fulfill: fulfill, reject: reject};
- }.bind(this));
+ }.bind(this)).catch(function(error) {
+ console.error('PiexLoaderError: ', error);
+ return Promise.reject(error);
+ });
}.bind(this));
};
« no previous file with comments | « no previous file | ui/file_manager/image_loader/request.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698