| 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 * MetadataCache is a map from Entry to an object containing properties. | 8 * MetadataCache is a map from Entry to an object containing properties. |
| 9 * Properties are divided by types, and all properties of one type are accessed | 9 * Properties are divided by types, and all properties of one type are accessed |
| 10 * at once. | 10 * at once. |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 530 |
| 531 /** | 531 /** |
| 532 * Removes the oldest items from the cache. | 532 * Removes the oldest items from the cache. |
| 533 * This method never removes the items from last batch. | 533 * This method never removes the items from last batch. |
| 534 * @private | 534 * @private |
| 535 */ | 535 */ |
| 536 MetadataCache.prototype.evict_ = function() { | 536 MetadataCache.prototype.evict_ = function() { |
| 537 var toRemove = []; | 537 var toRemove = []; |
| 538 | 538 |
| 539 // We leave only a half of items, so we will not call evict_ soon again. | 539 // We leave only a half of items, so we will not call evict_ soon again. |
| 540 var desiredCount = this.currentEvictionThreshold(); | 540 var desiredCount = this.currentEvictionThreshold_(); |
| 541 var removeCount = this.totalCount_ - desiredCount; | 541 var removeCount = this.totalCount_ - desiredCount; |
| 542 for (var url in this.cache_) { | 542 for (var url in this.cache_) { |
| 543 if (this.cache_.hasOwnProperty(url) && | 543 if (this.cache_.hasOwnProperty(url) && |
| 544 this.cache_[url].time < this.lastBatchStart_) { | 544 this.cache_[url].time < this.lastBatchStart_) { |
| 545 toRemove.push(url); | 545 toRemove.push(url); |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| 549 toRemove.sort(function(a, b) { | 549 toRemove.sort(function(a, b) { |
| 550 var aTime = this.cache_[a].time; | 550 var aTime = this.cache_[a].time; |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 | 1044 |
| 1045 /** | 1045 /** |
| 1046 * Handles the 'log' message from the worker. | 1046 * Handles the 'log' message from the worker. |
| 1047 * @param {Array.<*>} arglist Log arguments. | 1047 * @param {Array.<*>} arglist Log arguments. |
| 1048 * @private | 1048 * @private |
| 1049 */ | 1049 */ |
| 1050 ContentProvider.prototype.onLog_ = function(arglist) { | 1050 ContentProvider.prototype.onLog_ = function(arglist) { |
| 1051 if (MetadataCache.log) // Avoid log spam by default. | 1051 if (MetadataCache.log) // Avoid log spam by default. |
| 1052 console.log.apply(console, ['metadata:'].concat(arglist)); | 1052 console.log.apply(console, ['metadata:'].concat(arglist)); |
| 1053 }; | 1053 }; |
| OLD | NEW |