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

[piexwasm] Make PiexLoader a namespace

PiexLoader has no |this| properties at all: it's a namespace with one
API called load() effectively, so no need to instance it with new. Do
the simpler thing: make it a namespace [1]. No change in behavior.

[1] See CL:2437316 review comments for the namespace discussion.

Bug: 1132695
Change-Id: I10319ede41bbaeb0caa0c8bab6ff4b7701ff3081
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437319Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812489}
parent bcd9dbe1
......@@ -332,8 +332,7 @@ ImageRequestTask.prototype.downloadOriginal_ = function(onSuccess, onFailure) {
// Load RAW image source thumbnail.
if (fileType.type === 'raw') {
const piexLoader = ImageRequestTask.getPiexLoaderInstance();
piexLoader.load(this.request_.url, chrome.runtime.reload)
PiexLoader.load(this.request_.url, chrome.runtime.reload)
.then(
function(data) {
this.request_.orientation =
......@@ -630,14 +629,3 @@ ImageRequestTask.prototype.cleanup_ = function() {
this.canvas_.width = 0;
this.canvas_.height = 0;
};
/**
* Returns the singleton instance of the PiexLoader RAW image loader.
* @return {!PiexLoader} PiexLoader object.
*/
ImageRequestTask.getPiexLoaderInstance = function() {
if (!ImageRequestTask.piexLoaderInstance_) {
ImageRequestTask.piexLoaderInstance_ = new PiexLoader();
}
return ImageRequestTask.piexLoaderInstance_;
};
......@@ -492,10 +492,9 @@ class ImageBuffer {
}
/**
* Creates a PiexLoader.
* @constructor
* PiexLoader: is a namespace.
*/
function PiexLoader() {}
const PiexLoader = {};
/**
* Loads a RAW image. Returns the image metadata and the image thumbnail in a
......@@ -510,7 +509,7 @@ function PiexLoader() {}
* @param {function()} onPiexModuleFailed
* @return {!Promise<!PiexLoaderResponse>}
*/
PiexLoader.prototype.load = function(source, onPiexModuleFailed) {
PiexLoader.load = function(source, onPiexModuleFailed) {
/** @type {?ImageBuffer} */
let imageBuffer;
......
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