summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Klein <jlklein@google.com>2015-05-26 22:33:44 -0700
committerJeremy Klein <jlklein@google.com>2015-05-27 05:35:35 +0000
commit796417e50f2e8b1a389e28ff62768b03cca982a6 (patch)
tree90d8ee6ffe2d21b5d6ab73adbc827f82f8f11e47
parent24d3e9aba9f8c4d8d3c9963d3da678a51981c2fa (diff)
downloadchromium_src-796417e50f2e8b1a389e28ff62768b03cca982a6.zip
chromium_src-796417e50f2e8b1a389e28ff62768b03cca982a6.tar.gz
chromium_src-796417e50f2e8b1a389e28ff62768b03cca982a6.tar.bz2
Fix all compiler errors found by the new compiler version.
Bumping closure compiler: compiler.jar: v20150315-201-g05061ab -> v20150505-49-g22940a8 BUG= R=dbeam@chromium.org, fukino@chromium.org, kelvinp@chromium.org Review URL: https://codereview.chromium.org/1148563004 Cr-Commit-Position: refs/heads/master@{#331536}
-rw-r--r--remoting/webapp/browser_test/bump_scroll_browser_test.js2
-rw-r--r--remoting/webapp/js_proto/chrome_proto.js70
-rw-r--r--third_party/closure_compiler/compiler/compiler.jarbin6207606 -> 6261513 bytes
-rw-r--r--third_party/closure_compiler/externs/chrome_extensions.js439
-rw-r--r--third_party/closure_compiler/runner/runner.jarbin19076 -> 19076 bytes
-rw-r--r--ui/file_manager/file_manager/background/js/device_handler.js2
-rw-r--r--ui/file_manager/file_manager/background/js/duplicate_finder.js8
-rw-r--r--ui/file_manager/file_manager/background/js/volume_manager.js2
-rw-r--r--ui/file_manager/image_loader/cache.js38
-rw-r--r--ui/file_manager/image_loader/cache_unittest.js6
-rw-r--r--ui/file_manager/image_loader/image_loader.js6
-rw-r--r--ui/file_manager/image_loader/request.js37
-rw-r--r--ui/file_manager/image_loader/scheduler.js10
13 files changed, 84 insertions, 536 deletions
diff --git a/remoting/webapp/browser_test/bump_scroll_browser_test.js b/remoting/webapp/browser_test/bump_scroll_browser_test.js
index 38eea46..4e50f9f4 100644
--- a/remoting/webapp/browser_test/bump_scroll_browser_test.js
+++ b/remoting/webapp/browser_test/bump_scroll_browser_test.js
@@ -119,7 +119,7 @@ browserTest.Bump_Scroll.prototype.run = function(data) {
).then(
function(value) {
cleanup();
- return browserTest.pass(value);
+ return browserTest.pass();
},
function(error) {
cleanup();
diff --git a/remoting/webapp/js_proto/chrome_proto.js b/remoting/webapp/js_proto/chrome_proto.js
index 744483f..6156a50 100644
--- a/remoting/webapp/js_proto/chrome_proto.js
+++ b/remoting/webapp/js_proto/chrome_proto.js
@@ -7,9 +7,6 @@
// JSCompiler to verify the type-correctness of our code.
/** @type {Object} */
-chrome.app = {};
-
-/** @type {Object} */
chrome.app.runtime = {
/** @type {chrome.Event} */
onLaunched: null
@@ -40,52 +37,37 @@ chrome.app.window = {
};
-/** @type {Object} */
-chrome.runtime = {
- /** @type {Object} */
- lastError: {
- /** @type {string} */
- message: ''
- },
- /** @type {string} */
- id: '',
- /** @return {{name: string, version: string, app: {background: Object}}} */
- getManifest: function() {},
- /** @param {function(Window):void} callback */
- getBackgroundPage: function(callback) {},
- /** @type {chrome.Event} */
- onSuspend: null,
- /** @type {chrome.Event} */
- onSuspendCanceled: null,
- /** @type {chrome.Event} */
- onConnect: null,
- /** @type {chrome.Event} */
- onConnectExternal: null,
- /** @type {chrome.Event} */
- onMessage: null,
- /** @type {chrome.Event} */
- onMessageExternal: null
-};
+/** @type {string} */
+chrome.runtime.id;
-/**
- * @type {?function(string):chrome.runtime.Port}
- */
-chrome.runtime.connectNative = function(name) {};
+/** @return {{name: string, version: string, app: {background: Object}}} */
+chrome.runtime.getManifest = function() {};
-/**
- * @param {{ name: string}} config
- * @return {chrome.runtime.Port}
- */
-chrome.runtime.connect = function(config) {};
+/** @param {function(Window):void} callback */
+chrome.runtime.getBackgroundPage = function(callback) {};
+
+/** @type {chrome.Event} */
+chrome.runtime.onSuspend;
+
+/** @type {chrome.Event} */
+chrome.runtime.onSuspendCanceled;
+
+/** @type {chrome.Event} */
+chrome.runtime.onConnect;
+
+/** @type {chrome.Event} */
+chrome.runtime.onConnectExternal;
+
+/** @type {chrome.Event} */
+chrome.runtime.onMessage;
+
+/** @type {chrome.Event} */
+chrome.runtime.onMessageExternal;
/**
- * @param {string?} extensionId
- * @param {*} message
- * @param {Object=} opt_options
- * @param {function(*)=} opt_callback
+ * @type {?function(string):chrome.runtime.Port}
*/
-chrome.runtime.sendMessage = function(
- extensionId, message, opt_options, opt_callback) {};
+chrome.runtime.connectNative = function(name) {};
/** @constructor */
chrome.runtime.MessageSender = function(){
diff --git a/third_party/closure_compiler/compiler/compiler.jar b/third_party/closure_compiler/compiler/compiler.jar
index 158ddc0..db5a569 100644
--- a/third_party/closure_compiler/compiler/compiler.jar
+++ b/third_party/closure_compiler/compiler/compiler.jar
Binary files differ
diff --git a/third_party/closure_compiler/externs/chrome_extensions.js b/third_party/closure_compiler/externs/chrome_extensions.js
index 7722210..4dbfd03 100644
--- a/third_party/closure_compiler/externs/chrome_extensions.js
+++ b/third_party/closure_compiler/externs/chrome_extensions.js
@@ -241,13 +241,6 @@ chrome.accessibilityFeatures.animationPolicy;
/**
- * TODO(tbreisacher): Move all chrome.app.* externs into their own file.
- * @const
- */
-chrome.app = {};
-
-
-/**
* @const
* @see http://developer.chrome.com/apps/app.runtime.html
*/
@@ -2069,22 +2062,6 @@ chrome.extension.onRequest;
chrome.extension.onRequestExternal;
-/**
- * @see https://developer.chrome.com/extensions/runtime.html
- * @const
- */
-chrome.runtime = {};
-
-
-/** @type {!Object|undefined} */
-chrome.runtime.lastError = {};
-
-
-/**
- * @type {string|undefined}
- */
-chrome.runtime.lastError.message;
-
/** @type {string} */
chrome.runtime.id;
@@ -2197,17 +2174,6 @@ chrome.runtime.requestUpdateCheck = function(callback) {};
chrome.runtime.restart = function() {};
-/**
- * @param {string|!Object.<string>=} opt_extensionIdOrConnectInfo Either the
- * extensionId to connect to, in which case connectInfo params can be
- * passed in the next optional argument, or the connectInfo params.
- * @param {!Object.<string>=} opt_connectInfo The connectInfo object,
- * if arg1 was the extensionId to connect to.
- * @return {!Port} New port.
- */
-chrome.runtime.connect = function(
- opt_extensionIdOrConnectInfo, opt_connectInfo) {};
-
/**
* @see http://developer.chrome.com/extensions/runtime.html#method-connectNative
@@ -2219,27 +2185,6 @@ chrome.runtime.connectNative = function(application) {};
/**
- * @param {string|*} extensionIdOrMessage Either the extensionId to send the
- * message to, in which case the message is passed as the next arg, or the
- * message itself.
- * @param {(*|Object|function(*): void)=} opt_messageOrOptsOrCallback
- * One of:
- * The message, if arg1 was the extensionId.
- * The options for message sending, if arg1 was the message and this
- * argument is not a function.
- * The callback, if arg1 was the message and this argument is a function.
- * @param {(Object|function(*): void)=} opt_optsOrCallback
- * Either the options for message sending, if arg2 was the message,
- * or the callback.
- * @param {function(*): void=} opt_callback The callback function which
- * takes a JSON response object sent by the handler of the request.
- */
-chrome.runtime.sendMessage = function(
- extensionIdOrMessage, opt_messageOrOptsOrCallback, opt_optsOrCallback,
- opt_callback) {};
-
-
-/**
* @see http://developer.chrome.com/extensions/runtime.html#method-sendNativeMessage
* @param {string} application Name of the registered native messaging host to
* connect to, like 'com.google.your_product'.
@@ -5751,7 +5696,7 @@ chrome.webRequest.onSendHeaders;
-/**onKeyEvent
+/**
* @see https://developer.chrome.com/extensions/management.html
* @constructor
*/
@@ -5859,90 +5804,6 @@ IconInfo.prototype.url;
-/**
- * @see https://developer.chrome.com/extensions/tabs
- * @constructor
- */
-function Tab() {}
-
-
-// TODO: Make this field optional once dependent projects have been updated.
-/**
- * @type {number}
- */
-Tab.prototype.id;
-
-
-/** @type {number} */
-Tab.prototype.index;
-
-
-/** @type {number} */
-Tab.prototype.windowId;
-
-
-// TODO: Make this field optional once dependent projects have been updated.
-/**
- * @type {number}
- */
-Tab.prototype.openerTabId;
-
-
-/** @type {boolean} */
-Tab.prototype.highlighted;
-
-
-/** @type {boolean} */
-Tab.prototype.active;
-
-
-/** @type {boolean} */
-Tab.prototype.pinned;
-
-
-// TODO: Make this field optional once dependent projects have been updated.
-/**
- * @type {string}
- */
-Tab.prototype.url;
-
-
-// TODO: Make this field optional once dependent projects have been updated.
-/**
- * @type {string}
- */
-Tab.prototype.title;
-
-
-// TODO: Make this field optional once dependent projects have been updated.
-/**
- * @type {string}
- */
-Tab.prototype.favIconUrl;
-
-
-// TODO: Make this field optional once dependent projects have been updated.
-/**
- * @type {string}
- */
-Tab.prototype.status;
-
-
-/** @type {boolean} */
-Tab.prototype.incognito;
-
-
-/** @type {number|undefined} */
-Tab.prototype.width;
-
-
-/** @type {number|undefined} */
-Tab.prototype.height;
-
-
-/** @type {number|undefined} */
-Tab.prototype.sessionId;
-
/**
@@ -5998,161 +5859,6 @@ ChromeWindow.prototype.alwaysOnTop;
/**
- * @see https://developer.chrome.com/extensions/events.html
- * @constructor
- */
-function ChromeEvent() {}
-
-
-/** @param {!Function} callback */
-ChromeEvent.prototype.addListener = function(callback) {};
-
-
-/** @param {!Function} callback */
-ChromeEvent.prototype.removeListener = function(callback) {};
-
-
-/**
- * @param {!Function} callback
- * @return {boolean}
- */
-ChromeEvent.prototype.hasListener = function(callback) {};
-
-
-/** @return {boolean} */
-ChromeEvent.prototype.hasListeners = function() {};
-
-
-
-/**
- * Event whose listeners take a string parameter.
- * @constructor
- */
-function ChromeStringEvent() {}
-
-
-/** @param {function(string): void} callback */
-ChromeStringEvent.prototype.addListener = function(callback) {};
-
-
-/** @param {function(string): void} callback */
-ChromeStringEvent.prototype.removeListener = function(callback) {};
-
-
-/**
- * @param {function(string): void} callback
- * @return {boolean}
- */
-ChromeStringEvent.prototype.hasListener = function(callback) {};
-
-
-/** @return {boolean} */
-ChromeStringEvent.prototype.hasListeners = function() {};
-
-
-
-/**
- * Event whose listeners take a boolean parameter.
- * @constructor
- */
-
-function ChromeBooleanEvent() {}
-
-
-/**
- * @param {function(boolean): void} callback
- */
-ChromeBooleanEvent.prototype.addListener = function(callback) {};
-
-
-/**
- * @param {function(boolean): void} callback
- */
-ChromeBooleanEvent.prototype.removeListener = function(callback) {};
-
-
-/**
- * @param {function(boolean): void} callback
- * @return {boolean}
- */
-ChromeBooleanEvent.prototype.hasListener = function(callback) {};
-
-
-/**
- * @return {boolean}
- */
-ChromeBooleanEvent.prototype.hasListeners = function() {};
-
-
-
-/**
- * Event whose listeners take a number parameter.
- * @constructor
- */
-
-function ChromeNumberEvent() {}
-
-
-/**
- * @param {function(number): void} callback
- */
-ChromeNumberEvent.prototype.addListener = function(callback) {};
-
-
-/**
- * @param {function(number): void} callback
- */
-ChromeNumberEvent.prototype.removeListener = function(callback) {};
-
-
-/**
- * @param {function(number): void} callback
- * @return {boolean}
- */
-ChromeNumberEvent.prototype.hasListener = function(callback) {};
-
-
-/**
- * @return {boolean}
- */
-ChromeNumberEvent.prototype.hasListeners = function() {};
-
-
-
-/**
- * Event whose listeners take an Object parameter.
- * @constructor
- */
-function ChromeObjectEvent() {}
-
-
-/**
- * @param {function(!Object): void} callback Callback.
- */
-ChromeObjectEvent.prototype.addListener = function(callback) {};
-
-
-/**
- * @param {function(!Object): void} callback Callback.
- */
-ChromeObjectEvent.prototype.removeListener = function(callback) {};
-
-
-/**
- * @param {function(!Object): void} callback Callback.
- * @return {boolean}
- */
-ChromeObjectEvent.prototype.hasListener = function(callback) {};
-
-
-/**
- * @return {boolean}
- */
-ChromeObjectEvent.prototype.hasListeners = function() {};
-
-
-
-/**
* Event whose listeners take an ExtensionInfo parameter.
* @constructor
*/
@@ -6180,59 +5886,6 @@ ChromeExtensionInfoEvent.prototype.hasListeners = function() {};
/**
- * Event whose listeners take a string array parameter.
- * @constructor
- */
-function ChromeStringArrayEvent() {}
-
-
-/** @param {function(!Array.<string>): void} callback */
-ChromeStringArrayEvent.prototype.addListener = function(callback) {};
-
-
-/** @param {function(!Array.<string>): void} callback */
-ChromeStringArrayEvent.prototype.removeListener = function(callback) {};
-
-
-/**
- * @param {function(!Array.<string>): void} callback
- * @return {boolean}
- */
-ChromeStringArrayEvent.prototype.hasListener = function(callback) {};
-
-
-/** @return {boolean} */
-ChromeStringArrayEvent.prototype.hasListeners = function() {};
-
-
-
-/**
- * Event whose listeners take two strings as parameters.
- * @constructor
- */
-function ChromeStringStringEvent() {}
-
-
-/** @param {function(string, string): void} callback */
-ChromeStringStringEvent.prototype.addListener = function(callback) {};
-
-
-/** @param {function(string, string): void} callback */
-ChromeStringStringEvent.prototype.removeListener = function(callback) {};
-
-
-/**
- * @param {function(string, string): void} callback
- * @return {boolean}
- */
-ChromeStringStringEvent.prototype.hasListener = function(callback) {};
-
-
-/** @return {boolean} */
-ChromeStringStringEvent.prototype.hasListeners = function() {};
-
-
-/**
* @see http://developer.chrome.com/extensions/pushMessaging.html
* @const
*/
@@ -6294,66 +5947,6 @@ chrome.pushMessaging.PushMessageEvent.prototype.hasListeners = function() {};
-/**
- * @see http://developer.chrome.com/apps/runtime.html#type-Port
- * @constructor
- */
-function Port() {}
-
-
-/** @type {string} */
-Port.prototype.name;
-
-
-/** @type {!ChromeEvent} */
-Port.prototype.onDisconnect;
-
-
-/** @type {!ChromeEvent} */
-Port.prototype.onMessage;
-
-
-/** @type {MessageSender} */
-Port.prototype.sender;
-
-
-/**
- * @param {Object.<string>} obj Message object.
- */
-Port.prototype.postMessage = function(obj) {};
-
-
-/**
- * Note: as of 2012-04-12, this function is no longer documented on
- * the public web pages, but there are still existing usages.
- */
-Port.prototype.disconnect = function() {};
-
-
-
-/**
- * @see http://developer.chrome.com/extensions/runtime.html#type-MessageSender
- * @constructor
- */
-function MessageSender() {}
-
-
-/** @type {!Tab|undefined} */
-MessageSender.prototype.tab;
-
-
-/** @type {string|undefined} */
-MessageSender.prototype.id;
-
-
-/** @type {string|undefined} */
-MessageSender.prototype.url;
-
-
-/** @type {string|undefined} */
-MessageSender.prototype.tlsChannelId;
-
-
/**
* @see https://developer.chrome.com/extensions/bookmarks.html#type-BookmarkTreeNode
@@ -8354,36 +7947,6 @@ chrome.serial.onReceive;
chrome.serial.onReceiveError;
-/**
- * @const
- * @see https://developer.chrome.com/apps/webstore
- */
-chrome.webstore = {};
-
-
-/**
- * @param {string|function()|function(string)=}
- * opt_urlOrSuccessCallbackOrFailureCallback Either the URL to install or
- * the succcess callback taking no arg or the failure callback taking an
- * error string arg.
- * @param {function()|function(string)=} opt_successCallbackOrFailureCallback
- * Either the succcess callback taking no arg or the failure callback
- * taking an error string arg.
- * @param {function(string)=} opt_failureCallback The failure callback.
- */
-chrome.webstore.install = function(
- opt_urlOrSuccessCallbackOrFailureCallback,
- opt_successCallbackOrFailureCallback,
- opt_failureCallback) {};
-
-
-/** @type {!ChromeStringEvent} */
-chrome.webstore.onInstallStageChanged;
-
-
-/** @type {!ChromeNumberEvent} */
-chrome.webstore.onDownloadProgress;
-
////////////////////////////////////////////////////////////////////////////////
/////////////////////////// Chrome Private APIs ////////////////////////////////
diff --git a/third_party/closure_compiler/runner/runner.jar b/third_party/closure_compiler/runner/runner.jar
index 03d3dc5..1311550 100644
--- a/third_party/closure_compiler/runner/runner.jar
+++ b/third_party/closure_compiler/runner/runner.jar
Binary files differ
diff --git a/ui/file_manager/file_manager/background/js/device_handler.js b/ui/file_manager/file_manager/background/js/device_handler.js
index ecded52..6b86a35 100644
--- a/ui/file_manager/file_manager/background/js/device_handler.js
+++ b/ui/file_manager/file_manager/background/js/device_handler.js
@@ -423,7 +423,7 @@ DeviceHandler.prototype.onMount_ = function(event) {
.then(
/**
* @param {!VolumeInfo} volumeInfo
- * @return {Promise<DirectoryEntry>} The root directory
+ * @return {!Promise<!DirectoryEntry>} The root directory
* of the volume.
*/
function(volumeInfo) {
diff --git a/ui/file_manager/file_manager/background/js/duplicate_finder.js b/ui/file_manager/file_manager/background/js/duplicate_finder.js
index cd8f12d..2ad13d2 100644
--- a/ui/file_manager/file_manager/background/js/duplicate_finder.js
+++ b/ui/file_manager/file_manager/background/js/duplicate_finder.js
@@ -108,12 +108,12 @@ importer.DriveDuplicateFinder.prototype.computeHash_ = function(entry) {
/**
* Finds files with content hashes matching the given hash.
* @param {string} hash The content hash of the file to find.
- * @return {!Promise<Array<string>>} The URLs of the found files. If there are
+ * @return {!Promise<!Array<string>>} The URLs of the found files. If there are
* no matches, the list will be empty.
* @private
*/
importer.DriveDuplicateFinder.prototype.findByHash_ = function(hash) {
- return /** @type {!Promise<Array<string>>} */ (
+ return /** @type {!Promise<!Array<string>>} */ (
this.getDriveId_()
.then(this.searchFilesByHash_.bind(this, hash)));
};
@@ -142,7 +142,7 @@ importer.DriveDuplicateFinder.prototype.getDriveId_ = function() {
* A promise-based wrapper for chrome.fileManagerPrivate.searchFilesByHashes.
* @param {string} hash The content hash to search for.
* @param {string} volumeId The volume to search.
- * @return {!Promise<Array<string>>} A list of file URLs.
+ * @return {!Promise<!Array<string>>} A list of file URLs.
* @private
*/
importer.DriveDuplicateFinder.prototype.searchFilesByHash_ =
@@ -155,7 +155,7 @@ importer.DriveDuplicateFinder.prototype.searchFilesByHash_ =
volumeId,
[hash],
/**
- * @param {!Object<string, Array<string>>} urls
+ * @param {!Object<string, !Array<string>>} urls
* @this {importer.DriveDuplicateFinder}
*/
function(urls) {
diff --git a/ui/file_manager/file_manager/background/js/volume_manager.js b/ui/file_manager/file_manager/background/js/volume_manager.js
index f83ccf9..7fa24b1 100644
--- a/ui/file_manager/file_manager/background/js/volume_manager.js
+++ b/ui/file_manager/file_manager/background/js/volume_manager.js
@@ -189,7 +189,7 @@ VolumeInfo.prototype = /** @struct */ {
* @param {function(!DirectoryEntry)=} opt_onSuccess Success callback with the
* display root directory as an argument.
* @param {function(*)=} opt_onFailure Failure callback.
- * @return {Promise.<!DirectoryEntry>}
+ * @return {!Promise.<!DirectoryEntry>}
*/
VolumeInfo.prototype.resolveDisplayRoot = function(opt_onSuccess,
opt_onFailure) {
diff --git a/ui/file_manager/image_loader/cache.js b/ui/file_manager/image_loader/cache.js
index b9eb698..7b8a3f2 100644
--- a/ui/file_manager/image_loader/cache.js
+++ b/ui/file_manager/image_loader/cache.js
@@ -6,7 +6,7 @@
* Persistent cache storing images in an indexed database on the hard disk.
* @constructor
*/
-function Cache() {
+function ImageCache() {
/**
* IndexedDB database handle.
* @type {IDBDatabase}
@@ -20,14 +20,14 @@ function Cache() {
* @type {string}
* @const
*/
-Cache.DB_NAME = 'image-loader';
+ImageCache.DB_NAME = 'image-loader';
/**
* Cache database version.
* @type {number}
* @const
*/
-Cache.DB_VERSION = 12;
+ImageCache.DB_VERSION = 12;
/**
* Memory limit for images data in bytes.
@@ -35,7 +35,7 @@ Cache.DB_VERSION = 12;
* @const
* @type {number}
*/
-Cache.MEMORY_LIMIT = 250 * 1024 * 1024; // 250 MB.
+ImageCache.MEMORY_LIMIT = 250 * 1024 * 1024; // 250 MB.
/**
* Minimal amount of memory freed per eviction. Used to limit number of
@@ -44,7 +44,7 @@ Cache.MEMORY_LIMIT = 250 * 1024 * 1024; // 250 MB.
* @const
* @type {number}
*/
-Cache.EVICTION_CHUNK_SIZE = 50 * 1024 * 1024; // 50 MB.
+ImageCache.EVICTION_CHUNK_SIZE = 50 * 1024 * 1024; // 50 MB.
/**
* Creates a cache key.
@@ -53,7 +53,7 @@ Cache.EVICTION_CHUNK_SIZE = 50 * 1024 * 1024; // 50 MB.
* @return {?string} Cache key. It may be null if the cache does not support
* |request|. e.g. Data URI.
*/
-Cache.createKey = function(request) {
+ImageCache.createKey = function(request) {
if (/^data:/i.test(request.url))
return null;
return JSON.stringify({
@@ -69,11 +69,12 @@ Cache.createKey = function(request) {
* Initializes the cache database.
* @param {function()} callback Completion callback.
*/
-Cache.prototype.initialize = function(callback) {
+ImageCache.prototype.initialize = function(callback) {
// Establish a connection to the database or (re)create it if not available
// or not up to date. After changing the database's schema, increment
- // Cache.DB_VERSION to force database recreating.
- var openRequest = window.indexedDB.open(Cache.DB_NAME, Cache.DB_VERSION);
+ // ImageCache.DB_VERSION to force database recreating.
+ var openRequest = window.indexedDB.open(
+ ImageCache.DB_NAME, ImageCache.DB_VERSION);
openRequest.onsuccess = function(e) {
this.db_ = e.target.result;
@@ -105,7 +106,7 @@ Cache.prototype.initialize = function(callback) {
* provided, then a new one is created.
* @private
*/
-Cache.prototype.setCacheSize_ = function(size, opt_transaction) {
+ImageCache.prototype.setCacheSize_ = function(size, opt_transaction) {
var transaction = opt_transaction ||
this.db_.transaction(['settings'], 'readwrite');
var settingsStore = transaction.objectStore('settings');
@@ -122,7 +123,7 @@ Cache.prototype.setCacheSize_ = function(size, opt_transaction) {
* provided, then a new one is created.
* @private
*/
-Cache.prototype.fetchCacheSize_ = function(
+ImageCache.prototype.fetchCacheSize_ = function(
onSuccess, onFailure, opt_transaction) {
var transaction = opt_transaction ||
this.db_.transaction(['settings', 'metadata', 'data'], 'readwrite');
@@ -153,26 +154,26 @@ Cache.prototype.fetchCacheSize_ = function(
* provided, then a new one is created.
* @private
*/
-Cache.prototype.evictCache_ = function(
+ImageCache.prototype.evictCache_ = function(
size, onSuccess, onFailure, opt_transaction) {
var transaction = opt_transaction ||
this.db_.transaction(['settings', 'metadata', 'data'], 'readwrite');
// Check if the requested size is smaller than the cache size.
- if (size > Cache.MEMORY_LIMIT) {
+ if (size > ImageCache.MEMORY_LIMIT) {
onFailure();
return;
}
var onCacheSize = function(cacheSize) {
- if (size < Cache.MEMORY_LIMIT - cacheSize) {
+ if (size < ImageCache.MEMORY_LIMIT - cacheSize) {
// Enough space, no need to evict.
this.setCacheSize_(cacheSize + size, transaction);
onSuccess();
return;
}
- var bytesToEvict = Math.max(size, Cache.EVICTION_CHUNK_SIZE);
+ var bytesToEvict = Math.max(size, ImageCache.EVICTION_CHUNK_SIZE);
// Fetch all metadata.
var metadataEntries = [];
@@ -220,7 +221,7 @@ Cache.prototype.evictCache_ = function(
* @param {number} timestamp Last modification timestamp. Used to detect
* if the cache entry becomes out of date.
*/
-Cache.prototype.saveImage = function(key, data, width, height, timestamp) {
+ImageCache.prototype.saveImage = function(key, data, width, height, timestamp) {
if (!this.db_) {
console.warn('Cache database not available.');
return;
@@ -264,7 +265,8 @@ Cache.prototype.saveImage = function(key, data, width, height, timestamp) {
* the image's data, width, height.
* @param {function()} onFailure Failure callback.
*/
-Cache.prototype.loadImage = function(key, timestamp, onSuccess, onFailure) {
+ImageCache.prototype.loadImage = function(
+ key, timestamp, onSuccess, onFailure) {
if (!this.db_) {
console.warn('Cache database not available.');
onFailure();
@@ -348,7 +350,7 @@ Cache.prototype.loadImage = function(key, timestamp, onSuccess, onFailure) {
* @param {IDBTransaction=} opt_transaction Transaction to be reused. If not
* provided, then a new one is created.
*/
-Cache.prototype.removeImage = function(
+ImageCache.prototype.removeImage = function(
key, opt_onSuccess, opt_onFailure, opt_transaction) {
if (!this.db_) {
console.warn('Cache database not available.');
diff --git a/ui/file_manager/image_loader/cache_unittest.js b/ui/file_manager/image_loader/cache_unittest.js
index 1db4c48..5a54ebc 100644
--- a/ui/file_manager/image_loader/cache_unittest.js
+++ b/ui/file_manager/image_loader/cache_unittest.js
@@ -5,14 +5,14 @@
'use strict';
function testCreateCacheKey() {
- var key = Cache.createKey({url: 'http://example.com/image.jpg'});
+ var key = ImageCache.createKey({url: 'http://example.com/image.jpg'});
assertTrue(!!key);
}
function testNotCreateCacheKey() {
- var key = Cache.createKey({url: 'data:xxx'});
+ var key = ImageCache.createKey({url: 'data:xxx'});
assertFalse(!!key);
- var key = Cache.createKey({url: 'DaTa:xxx'});
+ var key = ImageCache.createKey({url: 'DaTa:xxx'});
assertFalse(!!key);
}
diff --git a/ui/file_manager/image_loader/image_loader.js b/ui/file_manager/image_loader/image_loader.js
index 1728727..092a085 100644
--- a/ui/file_manager/image_loader/image_loader.js
+++ b/ui/file_manager/image_loader/image_loader.js
@@ -9,10 +9,10 @@
function ImageLoader() {
/**
* Persistent cache object.
- * @type {Cache}
+ * @type {ImageCache}
* @private
*/
- this.cache_ = new Cache();
+ this.cache_ = new ImageCache();
/**
* Manages pending requests and runs them in order of priorities.
@@ -105,7 +105,7 @@ ImageLoader.prototype.onMessage_ = function(senderId, request, callback) {
return false; // No callback calls.
} else {
// Create a request task and add it to the scheduler (queue).
- var requestTask = new Request(
+ var requestTask = new ImageRequest(
requestId, this.cache_, this.piexLoader_, request, callback);
this.scheduler_.add(requestTask);
return true; // Request will call the callback.
diff --git a/ui/file_manager/image_loader/request.js b/ui/file_manager/image_loader/request.js
index 57f5360..0b23aec 100644
--- a/ui/file_manager/image_loader/request.js
+++ b/ui/file_manager/image_loader/request.js
@@ -20,13 +20,13 @@ var LoadImageRequest;
* returns the image using the callback.
*
* @param {string} id Request ID.
- * @param {Cache} cache Cache object.
+ * @param {ImageCache} 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, piexLoader, request, callback) {
+function ImageRequest(id, cache, piexLoader, request, callback) {
/**
* @type {string}
* @private
@@ -34,7 +34,7 @@ function Request(id, cache, piexLoader, request, callback) {
this.id_ = id;
/**
- * @type {Cache}
+ * @type {ImageCache}
* @private
*/
this.cache_ = cache;
@@ -105,7 +105,7 @@ function Request(id, cache, piexLoader, request, callback) {
* Returns ID of the request.
* @return {string} Request ID.
*/
-Request.prototype.getId = function() {
+ImageRequest.prototype.getId = function() {
return this.id_;
};
@@ -115,7 +115,7 @@ Request.prototype.getId = function() {
*
* @return {number} Priority.
*/
-Request.prototype.getPriority = function() {
+ImageRequest.prototype.getPriority = function() {
return (this.request_.priority !== undefined) ? this.request_.priority : 2;
};
@@ -125,7 +125,8 @@ Request.prototype.getPriority = function() {
* @param {function()} onSuccess Success callback.
* @param {function()} onFailure Failure callback.
*/
-Request.prototype.loadFromCacheAndProcess = function(onSuccess, onFailure) {
+ImageRequest.prototype.loadFromCacheAndProcess = function(
+ onSuccess, onFailure) {
this.loadFromCache_(
function(data, width, height) { // Found in cache.
this.sendImageData_(data, width, height);
@@ -138,7 +139,7 @@ Request.prototype.loadFromCacheAndProcess = function(onSuccess, onFailure) {
* Tries to download the image, resizes and sends the response.
* @param {function()} callback Completion callback.
*/
-Request.prototype.downloadAndProcess = function(callback) {
+ImageRequest.prototype.downloadAndProcess = function(callback) {
if (this.downloadCallback_)
throw new Error('Downloading already started.');
@@ -154,8 +155,8 @@ Request.prototype.downloadAndProcess = function(callback) {
* @param {function()} onFailure Failure callback.
* @private
*/
-Request.prototype.loadFromCache_ = function(onSuccess, onFailure) {
- var cacheKey = Cache.createKey(this.request_);
+ImageRequest.prototype.loadFromCache_ = function(onSuccess, onFailure) {
+ var cacheKey = ImageCache.createKey(this.request_);
if (!cacheKey) {
// Cache key is not provided for the request.
@@ -191,13 +192,13 @@ Request.prototype.loadFromCache_ = function(onSuccess, onFailure) {
* @param {number} height Image height.
* @private
*/
-Request.prototype.saveToCache_ = function(data, width, height) {
+ImageRequest.prototype.saveToCache_ = function(data, width, height) {
if (!this.request_.cache || !this.request_.timestamp) {
// Persistent cache is available only when a timestamp is provided.
return;
}
- var cacheKey = Cache.createKey(this.request_);
+ var cacheKey = ImageCache.createKey(this.request_);
if (!cacheKey) {
// Cache key is not provided for the request.
return;
@@ -217,7 +218,7 @@ Request.prototype.saveToCache_ = function(data, width, height) {
* @param {function()} onFailure Failure callback.
* @private
*/
-Request.prototype.downloadOriginal_ = function(onSuccess, onFailure) {
+ImageRequest.prototype.downloadOriginal_ = function(onSuccess, onFailure) {
this.image_.onload = function() {
URL.revokeObjectURL(this.image_.src);
onSuccess();
@@ -427,7 +428,7 @@ AuthorizedXHR.load_ = function(token, url, onSuccess, onFailure) {
* @param {boolean} imageChanged Whether the image has been changed.
* @private
*/
-Request.prototype.sendImage_ = function(imageChanged) {
+ImageRequest.prototype.sendImage_ = function(imageChanged) {
var imageData;
var width;
var height;
@@ -468,7 +469,7 @@ Request.prototype.sendImage_ = function(imageChanged) {
* @param {number} height Height.
* @private
*/
-Request.prototype.sendImageData_ = function(data, width, height) {
+ImageRequest.prototype.sendImageData_ = function(data, width, height) {
this.sendResponse_({
status: 'success', data: data, width: width, height: height,
taskId: this.request_.taskId
@@ -480,7 +481,7 @@ Request.prototype.sendImageData_ = function(data, width, height) {
* and finalizes the request process.
* @private
*/
-Request.prototype.onImageLoad_ = function() {
+ImageRequest.prototype.onImageLoad_ = function() {
// Perform processing if the url is not a data url, or if there are some
// operations requested.
if (!this.request_.url.match(/^data/) ||
@@ -503,7 +504,7 @@ Request.prototype.onImageLoad_ = function() {
* finalizes the request process.
* @private
*/
-Request.prototype.onImageError_ = function() {
+ImageRequest.prototype.onImageError_ = function() {
this.sendResponse_(
{status: 'error', taskId: this.request_.taskId});
this.cleanup_();
@@ -513,7 +514,7 @@ Request.prototype.onImageError_ = function() {
/**
* Cancels the request.
*/
-Request.prototype.cancel = function() {
+ImageRequest.prototype.cancel = function() {
this.cleanup_();
// If downloading has started, then call the callback.
@@ -525,7 +526,7 @@ Request.prototype.cancel = function() {
* Cleans up memory used by this request.
* @private
*/
-Request.prototype.cleanup_ = function() {
+ImageRequest.prototype.cleanup_ = function() {
this.image_.onerror = function() {};
this.image_.onload = function() {};
diff --git a/ui/file_manager/image_loader/scheduler.js b/ui/file_manager/image_loader/scheduler.js
index 4b35389..6599ea2 100644
--- a/ui/file_manager/image_loader/scheduler.js
+++ b/ui/file_manager/image_loader/scheduler.js
@@ -14,21 +14,21 @@ function Scheduler() {
* However, if they have to be downloaded, then these requests are moved
* to pendingRequests_.
*
- * @type {Array<Request>}
+ * @type {Array<ImageRequest>}
* @private
*/
this.newRequests_ = [];
/**
* List of pending requests for images to be downloaded.
- * @type {Array<Request>}
+ * @type {Array<ImageRequest>}
* @private
*/
this.pendingRequests_ = [];
/**
* List of requests being processed.
- * @type {Array<Request>}
+ * @type {Array<ImageRequest>}
* @private
*/
this.activeRequests_ = [];
@@ -60,7 +60,7 @@ Scheduler.MAXIMUM_IN_PARALLEL = 5;
* with higher priorities are finished. If the result is cached, then it is
* processed immediately once the scheduler is started.
*
- * @param {Request} request Request object.
+ * @param {ImageRequest} request Request object.
*/
Scheduler.prototype.add = function(request) {
if (!this.started_) {
@@ -149,7 +149,7 @@ Scheduler.prototype.continue_ = function() {
/**
* Handles finished requests.
*
- * @param {Request} request Finished request.
+ * @param {ImageRequest} request Finished request.
* @private
*/
Scheduler.prototype.finish_ = function(request) {