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

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

Issue 1027283005: Files.app: Start to use PiexLoader in image loader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace dummy .js extension with .txt extension for avoiding licence check. Created 5 years, 9 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 | « ui/file_manager/image_loader/piex_loader.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 49fdd37e0f278cb7dbc470e56de837836f207b1b..29b701892838e95aeb63e940553438018ac4a53f 100644
--- a/ui/file_manager/image_loader/request.js
+++ b/ui/file_manager/image_loader/request.js
@@ -8,7 +8,8 @@
* priority: (number|undefined),
* taskId: number,
* timestamp: (number|undefined),
- * url: string
+ * url: string,
+ * orientation: ImageOrientation
* }}
*/
var LoadImageRequest;
@@ -19,11 +20,12 @@ var LoadImageRequest;
*
* @param {string} id Request ID.
* @param {Cache} cache Cache object.
+ * @param {!PiexLoader} piexLoader Piex loader for RAW file.
* @param {LoadImageRequest} request Request message as a hash array.
* @param {function(Object)} callback Callback used to send the response.
* @constructor
*/
-function Request(id, cache, request, callback) {
+function Request(id, cache, piexLoader, request, callback) {
/**
* @type {string}
* @private
@@ -37,6 +39,12 @@ function Request(id, cache, request, callback) {
this.cache_ = cache;
/**
+ * @type {!PiexLoader}
+ * @private
+ */
+ this.piexLoader_ = piexLoader;
+
+ /**
* @type {LoadImageRequest}
* @private
*/
@@ -226,11 +234,24 @@ Request.prototype.downloadOriginal_ = function(onSuccess, onFailure) {
return;
}
+ // Load RAW images by using Piex loader instead of XHR.
+ if (FileType.getTypeForName(this.request_.url).type === 'raw') {
+ this.piexLoader_.load(this.request_.url).then(function(data) {
+ var blob = new Blob([data.thumbnail], {type: 'image/jpeg'});
+ var url = URL.createObjectURL(blob);
+ this.image_.src = url;
+ this.request_.orientation = data.orientation;
+ }.bind(this), function(error) {
+ console.error('PiexLoaderError: ', error);
+ onFailure();
+ });
+ return;
+ }
+
// Fetch the image via authorized XHR and parse it.
var parseImage = function(contentType, blob) {
if (contentType)
this.contentType_ = contentType;
-
this.image_.src = URL.createObjectURL(blob);
}.bind(this);
« no previous file with comments | « ui/file_manager/image_loader/piex_loader.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698