Commit d7a497ba authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[piexwasm] Remove id member from Piex JS objects

The id was a hangover from a time when PIEX image extraction used NaCl
to do thumbnail image extraction. It serves no purpose: remove it from
@typedefs and object properties. Reformat @typedefs for consistency.

No change in behavior, no new tests.

Bug: 1039141
Change-Id: I8c50b7e5906ce3763ba2396b677b7f74f1ec4a09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2062014Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742466}
parent 22b75da2
...@@ -8,12 +8,12 @@ console.log('[PiexLoader] wasm mode loaded'); ...@@ -8,12 +8,12 @@ console.log('[PiexLoader] wasm mode loaded');
* Declares the piex-wasm Module interface. The Module has many interfaces * Declares the piex-wasm Module interface. The Module has many interfaces
* but only declare the parts required for PIEX work. * but only declare the parts required for PIEX work.
* @typedef {{ * @typedef {{
* calledRun: boolean, * calledRun: boolean,
* onAbort: function((!Error|string)):undefined, * onAbort: function((!Error|string)):undefined,
* HEAP8: !Uint8Array, * HEAP8: !Uint8Array,
* _malloc: function(number):number, * _malloc: function(number):number,
* _free: function(number):undefined, * _free: function(number):undefined,
* image: function(number, number):PiexWasmImageResult * image: function(number, number):PiexWasmImageResult
* }} * }}
*/ */
let PiexWasmModule; let PiexWasmModule;
...@@ -58,29 +58,21 @@ function wasmModuleFailed() { ...@@ -58,29 +58,21 @@ function wasmModuleFailed() {
/** /**
* @typedef {{ * @typedef {{
* id: number, * thumbnail: !ArrayBuffer,
* thumbnail: !ArrayBuffer, * mimeType: (string|undefined),
* mimeType: (string|undefined), * orientation: number,
* orientation: number, * colorSpace: ColorSpace,
* colorSpace: ColorSpace, * ifd: ?string
* ifd: ?string
* }} * }}
*/ */
let ImagePreviewResponseData; let ImagePreviewResponseData;
/** /**
*
* @param {!ImagePreviewResponseData} data The preview image data. * @param {!ImagePreviewResponseData} data The preview image data.
* @constructor * @constructor
* @struct * @struct
*/ */
function PiexLoaderResponse(data) { function PiexLoaderResponse(data) {
/**
* @public {number}
* @const
*/
this.id = data.id;
/** /**
* @public {!ArrayBuffer} * @public {!ArrayBuffer}
* @const * @const
...@@ -107,7 +99,7 @@ function PiexLoaderResponse(data) { ...@@ -107,7 +99,7 @@ function PiexLoaderResponse(data) {
this.colorSpace = data.colorSpace; this.colorSpace = data.colorSpace;
/** /**
* JSON encoded RAW image photographic details (Piex Wasm module only). * JSON encoded RAW image photographic details.
* @public {?string} * @public {?string}
* @const * @const
*/ */
...@@ -120,10 +112,7 @@ function PiexLoaderResponse(data) { ...@@ -120,10 +112,7 @@ function PiexLoaderResponse(data) {
* @struct * @struct
*/ */
function PiexLoader() { function PiexLoader() {
/** // TODO(crbug.com/1039141): make this an ES6 class.
* @private {number}
*/
this.requestIdCount_ = 0;
} }
/** /**
...@@ -220,16 +209,8 @@ let PiexWasmImageResult; ...@@ -220,16 +209,8 @@ let PiexWasmImageResult;
class ImageBuffer { class ImageBuffer {
/** /**
* @param {!ArrayBuffer} buffer - raw image source data. * @param {!ArrayBuffer} buffer - raw image source data.
* @param {number} id - caller-defined id.
*/ */
constructor(buffer, id) { constructor(buffer) {
/**
* @type {number}
* @const
* @private
*/
this.id = id;
/** /**
* @type {!Uint8Array} * @type {!Uint8Array}
* @const * @const
...@@ -301,7 +282,6 @@ class ImageBuffer { ...@@ -301,7 +282,6 @@ class ImageBuffer {
ifd: this.details(result, preview.orientation), ifd: this.details(result, preview.orientation),
orientation: preview.orientation, orientation: preview.orientation,
colorSpace: preview.colorSpace, colorSpace: preview.colorSpace,
id: this.id,
}; };
} }
...@@ -322,7 +302,6 @@ class ImageBuffer { ...@@ -322,7 +302,6 @@ class ImageBuffer {
thumbnail: new ArrayBuffer(0), thumbnail: new ArrayBuffer(0),
colorSpace: ColorSpace.SRGB, colorSpace: ColorSpace.SRGB,
orientation: 1, orientation: 1,
id: this.id,
ifd: null, ifd: null,
}; };
} }
...@@ -344,7 +323,6 @@ class ImageBuffer { ...@@ -344,7 +323,6 @@ class ImageBuffer {
ifd: this.details(result, thumbnail.orientation), ifd: this.details(result, thumbnail.orientation),
orientation: thumbnail.orientation, orientation: thumbnail.orientation,
colorSpace: thumbnail.colorSpace, colorSpace: thumbnail.colorSpace,
id: this.id,
}; };
} }
...@@ -365,7 +343,6 @@ class ImageBuffer { ...@@ -365,7 +343,6 @@ class ImageBuffer {
thumbnail: new ArrayBuffer(0), thumbnail: new ArrayBuffer(0),
colorSpace: ColorSpace.SRGB, colorSpace: ColorSpace.SRGB,
orientation: 1, orientation: 1,
id: this.id,
ifd: null, ifd: null,
}; };
} }
...@@ -440,7 +417,6 @@ class ImageBuffer { ...@@ -440,7 +417,6 @@ class ImageBuffer {
ifd: this.details(result, thumbnail.orientation), ifd: this.details(result, thumbnail.orientation),
orientation: thumbnail.orientation, orientation: thumbnail.orientation,
colorSpace: thumbnail.colorSpace, colorSpace: thumbnail.colorSpace,
id: this.id,
}; };
} }
...@@ -497,15 +473,14 @@ class ImageBuffer { ...@@ -497,15 +473,14 @@ class ImageBuffer {
* @return {!Promise<!PiexLoaderResponse>} * @return {!Promise<!PiexLoaderResponse>}
*/ */
PiexLoader.prototype.load = function(url) { PiexLoader.prototype.load = function(url) {
const requestId = this.requestIdCount_++;
let imageBuffer; let imageBuffer;
return readFromFileSystem(url) return readFromFileSystem(url)
.then((buffer) => { .then((buffer) => {
if (wasmModuleFailed() === true) { if (wasmModuleFailed() === true) {
return Promise.reject('piex wasm module failed'); return Promise.reject('piex wasm module failed');
} }
imageBuffer = new ImageBuffer(buffer, requestId); imageBuffer = new ImageBuffer(buffer);
return imageBuffer.process(); return imageBuffer.process();
}) })
.then((result) => { .then((result) => {
......
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