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

Side by Side Diff: ui/file_manager/file_manager/common/js/util.js

Issue 420743002: Gallery: Store image caches in Gallery items. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * Namespace for utility functions. 8 * Namespace for utility functions.
9 */ 9 */
10 var util = {}; 10 var util = {};
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 * @param {Object} map A map of timestamped key-value pairs. 827 * @param {Object} map A map of timestamped key-value pairs.
828 * @private 828 * @private
829 */ 829 */
830 util.AppCache.cleanup_ = function(map) { 830 util.AppCache.cleanup_ = function(map) {
831 // Sort keys by ascending timestamps. 831 // Sort keys by ascending timestamps.
832 var keys = []; 832 var keys = [];
833 for (var key in map) { 833 for (var key in map) {
834 if (map.hasOwnProperty(key)) 834 if (map.hasOwnProperty(key))
835 keys.push(key); 835 keys.push(key);
836 } 836 }
837 keys.sort(function(a, b) { return map[a].expire > map[b].expire }); 837 keys.sort(function(a, b) { return map[a].expire > map[b].expire; });
838 838
839 var cutoff = Date.now(); 839 var cutoff = Date.now();
840 840
841 var obsolete = 0; 841 var obsolete = 0;
842 while (obsolete < keys.length && 842 while (obsolete < keys.length &&
843 map[keys[obsolete]].expire < cutoff) { 843 map[keys[obsolete]].expire < cutoff) {
844 obsolete++; 844 obsolete++;
845 } 845 }
846 846
847 var overCapacity = Math.max(0, keys.length - util.AppCache.CAPACITY); 847 var overCapacity = Math.max(0, keys.length - util.AppCache.CAPACITY);
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 parentEntry.toURL(), 1420 parentEntry.toURL(),
1421 name, 1421 name,
1422 function(valid) { 1422 function(valid) {
1423 if (valid) 1423 if (valid)
1424 fulfill(); 1424 fulfill();
1425 else 1425 else
1426 reject(str('ERROR_LONG_NAME')); 1426 reject(str('ERROR_LONG_NAME'));
1427 }); 1427 });
1428 }); 1428 });
1429 }; 1429 };
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/gallery/js/gallery.js » ('j') | ui/file_manager/gallery/js/gallery.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698