Commit d0e9b7d3 authored by yawano's avatar yawano Committed by Commit bot

Move util.loadImage and util.cancelLoadImage to thumbnail_loader.js.

util.loadImage and util.cancelLoadImage seem to be called only by thumbnail_loader.js. Since common/js/util.js is included by many applications, unnecessarily putting codes in common/js/util.js brings unnecessary dependencies.

BUG=433728
TEST=GYP_GENERATORS=ninja tools/gyp/gyp --depth . ui/file_manager/gallery/js/compiled_resources.gyp && ninja -C out/Default

Review URL: https://codereview.chromium.org/823593006

Cr-Commit-Position: refs/heads/master@{#309615}
parent da9bd892
......@@ -485,37 +485,6 @@ util.AppCache.cleanup_ = function(map) {
}
};
/**
* Load an image.
*
* @param {HTMLImageElement} image Image element.
* @param {string} url Source url.
* @param {Object=} opt_options Hash array of options, eg. width, height,
* maxWidth, maxHeight, scale, cache.
* @param {function()=} opt_isValid Function returning false iff the task
* is not valid and should be aborted.
* @return {?number} Task identifier or null if fetched immediately from
* cache.
*/
util.loadImage = function(image, url, opt_options, opt_isValid) {
return ImageLoaderClient.loadToImage(url,
image,
opt_options || {},
function() {},
function() {
image.onerror(new Event('load-error'));
},
opt_isValid);
};
/**
* Cancels loading an image.
* @param {number} taskId Task identifier returned by util.loadImage().
*/
util.cancelLoadImage = function(taskId) {
ImageLoaderClient.getInstance().cancel(taskId);
};
/**
* Returns true if the board of the device matches the given prefix.
* @param {string} boardPrefix The board prefix to match against.
......
......@@ -183,14 +183,20 @@ ThumbnailLoader.prototype.load = function(box, fillMode, opt_optimizationMode,
this.metadata_.filesystem &&
this.metadata_.filesystem.modificationTime &&
this.metadata_.filesystem.modificationTime.getTime();
this.taskId_ = util.loadImage(
this.image_,
this.taskId_ = ImageLoaderClient.loadToImage(
this.thumbnailUrl_,
{ maxWidth: ThumbnailLoader.THUMBNAIL_MAX_WIDTH,
this.image_,
{
maxWidth: ThumbnailLoader.THUMBNAIL_MAX_WIDTH,
maxHeight: ThumbnailLoader.THUMBNAIL_MAX_HEIGHT,
cache: true,
priority: this.priority_,
timestamp: modificationTime },
timestamp: modificationTime
},
function() {},
function() {
this.image_.onerror(new Event('load-error'));
}.bind(this),
function() {
if (opt_optimizationMode ==
ThumbnailLoader.OptimizationMode.DISCARD_DETACHED &&
......@@ -209,7 +215,7 @@ ThumbnailLoader.prototype.cancel = function() {
if (this.taskId_) {
this.image_.onload = function() {};
this.image_.onerror = function() {};
util.cancelLoadImage(this.taskId_);
ImageLoaderClient.getInstance().cancel(this.taskId_);
this.taskId_ = null;
}
};
......@@ -266,14 +272,20 @@ ThumbnailLoader.prototype.loadDetachedImage = function(callback) {
this.metadata_.filesystem &&
this.metadata_.filesystem.modificationTime &&
this.metadata_.filesystem.modificationTime.getTime();
this.taskId_ = util.loadImage(
this.image_,
this.taskId_ = ImageLoaderClient.loadToImage(
this.thumbnailUrl_,
{ maxWidth: ThumbnailLoader.THUMBNAIL_MAX_WIDTH,
this.image_,
{
maxWidth: ThumbnailLoader.THUMBNAIL_MAX_WIDTH,
maxHeight: ThumbnailLoader.THUMBNAIL_MAX_HEIGHT,
cache: true,
priority: this.priority_,
timestamp: modificationTime });
timestamp: modificationTime
},
function() {},
function() {
this.image_.onerror(new Event('load-error'));
}.bind(this));
};
/**
......
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