OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Client used to connect to the remote ImageLoader extension. Client class runs | 8 * Client used to connect to the remote ImageLoader extension. Client class runs |
9 * in the extension, where the client.js is included (eg. Files.app). | 9 * in the extension, where the client.js is included (eg. Files.app). |
10 * It sends remote requests using IPC to the ImageLoader class and forwards | 10 * It sends remote requests using IPC to the ImageLoader class and forwards |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 }; | 116 }; |
117 | 117 |
118 /** | 118 /** |
119 * Loads and resizes and image. Use opt_isValid to easily cancel requests | 119 * Loads and resizes and image. Use opt_isValid to easily cancel requests |
120 * which are not valid anymore, which will reduce cpu consumption. | 120 * which are not valid anymore, which will reduce cpu consumption. |
121 * | 121 * |
122 * @param {string} url Url of the requested image. | 122 * @param {string} url Url of the requested image. |
123 * @param {function} callback Callback used to return response. | 123 * @param {function} callback Callback used to return response. |
124 * @param {Object=} opt_options Loader options, such as: scale, maxHeight, | 124 * @param {Object=} opt_options Loader options, such as: scale, maxHeight, |
125 * width, height and/or cache. | 125 * width, height and/or cache. |
126 * @param {function=} opt_isValid Function returning false in case | 126 * @param {Function=} opt_isValid Function returning false in case |
fukino
2014/09/22 06:05:57
More specifically, could you annotate this param a
Vitaly Pavlenko
2014/09/22 20:10:18
Done.
| |
127 * a request is not valid anymore, eg. parent node has been detached. | 127 * a request is not valid anymore, eg. parent node has been detached. |
128 * @return {?number} Remote task id or null if loaded from cache. | 128 * @return {?number} Remote task id or null if loaded from cache. |
129 */ | 129 */ |
130 ImageLoaderClient.prototype.load = function( | 130 ImageLoaderClient.prototype.load = function( |
131 url, callback, opt_options, opt_isValid) { | 131 url, callback, opt_options, opt_isValid) { |
132 opt_options = opt_options || {}; | 132 opt_options = opt_options || {}; |
133 opt_isValid = opt_isValid || function() { return true; }; | 133 opt_isValid = opt_isValid || function() { return true; }; |
134 | 134 |
135 // Record cache usage. | 135 // Record cache usage. |
136 ImageLoaderClient.recordPercentage('Cache.Usage', this.cache_.getUsage()); | 136 ImageLoaderClient.recordPercentage('Cache.Usage', this.cache_.getUsage()); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 onError(); | 360 onError(); |
361 return; | 361 return; |
362 } | 362 } |
363 image.src = result.data; | 363 image.src = result.data; |
364 onSuccess(); | 364 onSuccess(); |
365 }; | 365 }; |
366 | 366 |
367 return ImageLoaderClient.getInstance().load( | 367 return ImageLoaderClient.getInstance().load( |
368 url, callback, options, opt_isValid); | 368 url, callback, options, opt_isValid); |
369 }; | 369 }; |
OLD | NEW |