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

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

Issue 347973002: Files.app: don't refresh metadata when unnecessary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comments 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 163d48919c41bc2ec0f5fa280a0509a7dad9b7f3..336e62d798cc9d2d24689a24203613c836af595f 100644
--- a/ui/file_manager/file_manager/foreground/js/directory_contents.js
+++ b/ui/file_manager/file_manager/foreground/js/directory_contents.js
@@ -546,8 +546,11 @@ DirectoryContents.prototype.getDirectoryEntry = function() {
/**
* Start directory scan/search operation. Either 'scan-completed' or
* 'scan-failed' event will be fired upon completion.
+ *
+ * @param {boolean} refresh True to refrech metadata, or false to use cached
+ * one.
*/
-DirectoryContents.prototype.scan = function() {
+DirectoryContents.prototype.scan = function(refresh) {
/**
* Invoked when the scanning is completed successfully.
* @this {DirectoryContents}
@@ -569,7 +572,7 @@ DirectoryContents.prototype.scan = function() {
// TODO(hidehiko,mtomasz): this scan method must be called at most once.
// Remove such a limitation.
this.scanner_ = this.scannerFactory_();
- this.scanner_.scan(this.onNewEntries_.bind(this),
+ this.scanner_.scan(this.onNewEntries_.bind(this, refresh),
completionCallback.bind(this),
errorCallback.bind(this));
};
@@ -648,10 +651,13 @@ DirectoryContents.prototype.onScanError_ = function() {
/**
* Called when some chunk of entries are read by scanner.
+ *
+ * @param {boolean} refresh True to refresh metadata, or false to use cached
+ * one.
* @param {Array.<Entry>} entries The list of the scanned entries.
* @private
*/
-DirectoryContents.prototype.onNewEntries_ = function(entries) {
+DirectoryContents.prototype.onNewEntries_ = function(refresh, entries) {
if (this.scanCancelled_)
return;
@@ -689,7 +695,7 @@ DirectoryContents.prototype.onNewEntries_ = function(entries) {
var chunk = entriesFiltered.slice(i, i + MAX_CHUNK_SIZE);
prefetchMetadataQueue.run(function(chunk, callbackInner) {
- this.prefetchMetadata(chunk, function() {
+ this.prefetchMetadata(chunk, refresh, function() {
if (!prefetchMetadataQueue.isCancelled()) {
if (this.scanCancelled_)
prefetchMetadataQueue.cancel();
@@ -712,10 +718,17 @@ DirectoryContents.prototype.onNewEntries_ = function(entries) {
/**
* @param {Array.<Entry>} entries Files.
+ * @param {boolean} refresh True to refresh metadata, or false to use cached
+ * one.
* @param {function(Object)} callback Callback on done.
*/
-DirectoryContents.prototype.prefetchMetadata = function(entries, callback) {
- this.context_.metadataCache.getLatest(entries, 'filesystem|drive', callback);
+DirectoryContents.prototype.prefetchMetadata =
+ function(entries, refresh, callback) {
+ var TYPES = 'filesystem|drive';
+ if (refresh)
+ this.context_.metadataCache.getLatest(entries, TYPES, callback);
+ else
+ this.context_.metadataCache.get(entries, TYPES, callback);
};
/**
« 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