OLD | NEW |
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 Loading... |
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 Loading... |
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 }; |
OLD | NEW |