Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: chrome/browser/resources/image_loader/client.js

Issue 14623021: Introduce a priority queue to the image loader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 var ImageLoader = ImageLoader || {}; 5 var ImageLoader = ImageLoader || {};
6 6
7 /** 7 /**
8 * Image loader's extension id. 8 * Image loader's extension id.
9 * @const 9 * @const
10 * @type {string} 10 * @type {string}
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 /** 262 /**
263 * Saves an image in the cache. 263 * Saves an image in the cache.
264 * 264 *
265 * @param {string} key Cache key. 265 * @param {string} key Cache key.
266 * @param {string} data Image data. 266 * @param {string} data Image data.
267 * @param {number=} opt_timestamp Last modification timestamp. Used to detect 267 * @param {number=} opt_timestamp Last modification timestamp. Used to detect
268 * if the cache entry becomes out of date. 268 * if the cache entry becomes out of date.
269 */ 269 */
270 ImageLoader.Client.Cache.prototype.saveImage = function( 270 ImageLoader.Client.Cache.prototype.saveImage = function(
271 key, data, opt_timestamp) { 271 key, data, opt_timestamp) {
272
273 // If the image is currently in cache, then remove it. 272 // If the image is currently in cache, then remove it.
274 if (this.images_[key]) 273 if (this.images_[key])
275 this.removeImage(key); 274 this.removeImage(key);
276 275
277 if (ImageLoader.Client.Cache.MEMORY_LIMIT - this.size_ < data.length) { 276 if (ImageLoader.Client.Cache.MEMORY_LIMIT - this.size_ < data.length) {
278 ImageLoader.Client.recordBinary('Evicted', 1); 277 ImageLoader.Client.recordBinary('Evicted', 1);
279 this.evictCache_(data.length); 278 this.evictCache_(data.length);
280 } else { 279 } else {
281 ImageLoader.Client.recordBinary('Evicted', 0); 280 ImageLoader.Client.recordBinary('Evicted', 0);
282 } 281 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 onError(); 357 onError();
359 return; 358 return;
360 } 359 }
361 image.src = result.data; 360 image.src = result.data;
362 onSuccess(); 361 onSuccess();
363 }; 362 };
364 363
365 return ImageLoader.Client.getInstance().load( 364 return ImageLoader.Client.getInstance().load(
366 url, callback, options, opt_isValid); 365 url, callback, options, opt_isValid);
367 }; 366 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698