| Index: trunk/src/chrome/browser/resources/file_manager/foreground/js/metadata/metadata_cache.js
|
| ===================================================================
|
| --- trunk/src/chrome/browser/resources/file_manager/foreground/js/metadata/metadata_cache.js (revision 244077)
|
| +++ trunk/src/chrome/browser/resources/file_manager/foreground/js/metadata/metadata_cache.js (working copy)
|
| @@ -76,8 +76,6 @@
|
| this.batchCount_ = 0;
|
| this.totalCount_ = 0;
|
|
|
| - this.currentCacheSize_ = 0;
|
| -
|
| /**
|
| * Time of first get query of the current batch. Items updated later than this
|
| * will not be evicted.
|
| @@ -105,9 +103,9 @@
|
| MetadataCache.DESCENDANTS = 2;
|
|
|
| /**
|
| - * Margin of the cache size. This amount of caches may be kept in addition.
|
| + * Minimum number of items in cache to start eviction.
|
| */
|
| -MetadataCache.EVICTION_THRESHOLD_MARGIN = 500;
|
| +MetadataCache.EVICTION_NUMBER = 1000;
|
|
|
| /**
|
| * @param {VolumeManagerWrapper} volumeManager Volume manager instance.
|
| @@ -161,28 +159,6 @@
|
| };
|
|
|
| /**
|
| - * Sets the size of cache. The actual cache size may be larger than the given
|
| - * value.
|
| - * @param {number} size The cache size to be set.
|
| - */
|
| -MetadataCache.prototype.setCacheSize = function(size) {
|
| - this.currentCacheSize_ = size;
|
| -
|
| - if (this.totalCount_ > this.currentEvictionThreshold_())
|
| - this.evict_();
|
| -};
|
| -
|
| -/**
|
| - * Returns the current threshold to evict caches. When the number of caches
|
| - * exceeds this, the cache should be evicted.
|
| - * @return {number} Threshold to evict caches.
|
| - * @private
|
| - */
|
| -MetadataCache.prototype.currentEvictionThreshold_ = function() {
|
| - return this.currentCacheSize_ * 2 + MetadataCache.EVICTION_THRESHOLD_MARGIN;
|
| -};
|
| -
|
| -/**
|
| * Fetches the metadata, puts it in the cache, and passes to callback.
|
| * If required metadata is already in the cache, does not fetch it again.
|
| * @param {Entry|Array.<Entry>} entries The list of entries. May be just a
|
| @@ -482,7 +458,7 @@
|
| MetadataCache.prototype.endBatchUpdates = function() {
|
| this.batchCount_--;
|
| if (this.batchCount_ !== 0) return;
|
| - if (this.totalCount_ > this.currentEvictionThreshold_())
|
| + if (this.totalCount_ > MetadataCache.EVICTION_NUMBER)
|
| this.evict_();
|
| for (var index = 0; index < this.observers_.length; index++) {
|
| var observer = this.observers_[index];
|
| @@ -537,7 +513,7 @@
|
| var toRemove = [];
|
|
|
| // We leave only a half of items, so we will not call evict_ soon again.
|
| - var desiredCount = this.currentEvictionThreshold();
|
| + var desiredCount = Math.round(MetadataCache.EVICTION_NUMBER / 2);
|
| var removeCount = this.totalCount_ - desiredCount;
|
| for (var url in this.cache_) {
|
| if (this.cache_.hasOwnProperty(url) &&
|
|
|