Chromium Code Reviews| Index: ui/file_manager/image_loader/request.js |
| diff --git a/ui/file_manager/image_loader/request.js b/ui/file_manager/image_loader/request.js |
| index 10453513ab9cc2723b4a6c88bf3c7feb3d5893f0..1b1f0dfc8b8f995c510868d104257012da2f8f17 100644 |
| --- a/ui/file_manager/image_loader/request.js |
| +++ b/ui/file_manager/image_loader/request.js |
| @@ -5,12 +5,23 @@ |
| 'use strict'; |
| /** |
| + * @typedef {{ |
| + * cache: (boolean|undefined), |
| + * priority: (number|undefined), |
| + * taskId: number, |
| + * timestamp: (number|undefined), |
| + * url: string |
| + * }} |
| + */ |
| +var LoadImageRequest; |
|
fukino
2014/10/07 09:52:45
This type defines how the request object given thr
|
| + |
| +/** |
| * Creates and starts downloading and then resizing of the image. Finally, |
| * returns the image using the callback. |
| * |
| * @param {string} id Request ID. |
| * @param {Cache} cache Cache object. |
| - * @param {Object} request Request message as a hash array. |
| + * @param {LoadImageRequest} request Request message as a hash array. |
| * @param {function(Object)} callback Callback used to send the response. |
| * @constructor |
| */ |
| @@ -28,7 +39,7 @@ function Request(id, cache, request, callback) { |
| this.cache_ = cache; |
| /** |
| - * @type {Object} |
| + * @type {LoadImageRequest} |
| * @private |
| */ |
| this.request_ = request; |
| @@ -243,15 +254,17 @@ AuthorizedXHR.prototype.load = function(url, onSuccess, onFailure) { |
| this.aborted_ = false; |
| // Do not call any callbacks when aborting. |
| - var onMaybeSuccess = function(contentType, response) { |
| - if (!this.aborted_) |
| - onSuccess(contentType, response); |
| - }.bind(this); |
| - |
| - var onMaybeFailure = function(opt_code) { |
| - if (!this.aborted_) |
| - onFailure(); |
| - }.bind(this); |
| + var onMaybeSuccess = /** @type {function(string, Blob)} */ ( |
| + function(contentType, response) { |
| + if (!this.aborted_) |
| + onSuccess(contentType, response); |
| + }.bind(this)); |
| + |
| + var onMaybeFailure = /** @type {function(number=)} */ ( |
|
mtomasz
2014/10/07 09:56:15
Sometimes we use number|underfined, but sometimes
fukino
2014/10/07 10:49:44
number= can be used only for optional parameter. (
mtomasz
2014/10/07 10:54:29
Got it. Thanks for the explanation!
|
| + function(opt_code) { |
| + if (!this.aborted_) |
| + onFailure(); |
| + }.bind(this)); |
| // Fetches the access token and makes an authorized call. If refresh is true, |
| // then forces refreshing the access token. |
| @@ -284,7 +297,7 @@ AuthorizedXHR.prototype.load = function(url, onSuccess, onFailure) { |
| null, |
| noCacheUrl, |
| onMaybeSuccess, |
| - onMaybeSuccess); |
| + onMaybeFailure); |
|
fukino
2014/10/07 09:52:45
This was changed onMaybeSuccess unintentionally, s
|
| return; |
| } |