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

Unified Diff: ui/file_manager/file_manager/foreground/js/directory_contents.js

Issue 310633002: Files.app: Let DirectoryContents controls metadata cache size by relative value (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/directory_model.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/directory_contents.js
diff --git a/ui/file_manager/file_manager/foreground/js/directory_contents.js b/ui/file_manager/file_manager/foreground/js/directory_contents.js
index ee35ab31662023005758f964a4a4b9944a2e5042..8c95f0b7e4b8a031cb41e871f288ecf4cfb91f2a 100644
--- a/ui/file_manager/file_manager/foreground/js/directory_contents.js
+++ b/ui/file_manager/file_manager/foreground/js/directory_contents.js
@@ -455,6 +455,8 @@ function DirectoryContents(context,
this.scanner_ = null;
this.processNewEntriesQueue_ = new AsyncUtil.Queue();
this.scanCancelled_ = false;
+
+ this.lastSpaceInMetadataCache_ = 0;
}
/**
@@ -475,6 +477,24 @@ DirectoryContents.prototype.clone = function() {
};
/**
+ * Disposes the reserved metadata cache.
+ */
+DirectoryContents.prototype.dispose = function() {
+ this.context_.metadataCache.resizeBy(-this.lastSpaceInMetadataCache_);
+};
+
+/**
+ * Make a space for current directory size in the metadata cache.
+ *
+ * @param {number} size The cache size to be set.
+ * @private
+ */
+DirectoryContents.prototype.makeSpaceInMetadataCache_ = function(size) {
+ this.context_.metadataCache.resizeBy(size - this.lastSpaceInMetadataCache_);
+ this.lastSpaceInMetadataCache_ = size;
+};
+
+/**
* Use a given fileList instead of the fileList from the context.
* @param {Array|cr.ui.ArrayDataModel} fileList The new file list.
*/
@@ -483,7 +503,7 @@ DirectoryContents.prototype.setFileList = function(fileList) {
this.fileList_ = fileList;
else
this.fileList_ = new cr.ui.ArrayDataModel(fileList);
- this.context_.metadataCache.setCacheSize(this.fileList_.length);
+ this.makeSpaceInMetadataCache_(this.fileList_.length);
};
/**
@@ -497,7 +517,7 @@ DirectoryContents.prototype.replaceContextFileList = function() {
spliceArgs.unshift(0, fileList.length);
fileList.splice.apply(fileList, spliceArgs);
this.fileList_ = fileList;
- this.context_.metadataCache.setCacheSize(this.fileList_.length);
+ this.makeSpaceInMetadataCache_(this.fileList_.length);
}
};
@@ -650,7 +670,7 @@ DirectoryContents.prototype.onNewEntries_ = function(entries) {
this.fileList_.push.apply(this.fileList_, entriesFiltered);
cr.dispatchSimpleEvent(this, 'scan-updated');
- this.context_.metadataCache.setCacheSize(this.fileList_.length);
+ this.makeSpaceInMetadataCache_(this.fileList_.length);
this.processNewEntriesQueue_.run(function(callbackOuter) {
// Because the prefetchMetadata can be slow, throttling by splitting entries
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/directory_model.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698