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

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

Issue 293053006: Files.app: Introduce AsyncUtil.ConcurrentQueue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comment Created 6 years, 7 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
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 37125baca64c38ffd42017111f17722897a799bb..350ecc22b81cf60bf12b1ad9111b2a03d0bf2228 100644
--- a/ui/file_manager/file_manager/foreground/js/directory_contents.js
+++ b/ui/file_manager/file_manager/foreground/js/directory_contents.js
@@ -566,7 +566,10 @@ DirectoryContents.prototype.cancelScan = function() {
this.onScanFinished_();
+ // Cancels the current prefetchMetadata queue and replaces it with new one.
this.prefetchMetadataQueue_.cancel();
+ this.prefetchMetadataQueue_ = new AsyncUtil.Queue();
hirono 2014/05/26 09:19:42 Does it really need to reassign a new queue? It lo
yoshiki 2014/05/26 09:36:33 That's right. Removed.
+
cr.dispatchSimpleEvent(this, 'scan-cancelled');
};
@@ -579,7 +582,10 @@ DirectoryContents.prototype.cancelScan = function() {
DirectoryContents.prototype.onScanFinished_ = function() {
this.scanner_ = null;
- this.prefetchMetadataQueue_.run(function(callback) {
+ this.prefetchMetadataQueue_.run(function(callback, cancelled) {
+ if (cancelled)
+ return callback();
+
// TODO(yoshiki): Here we should fire the update event of changed
// items. Currently we have a method this.fileList_.updateIndex() to
// fire an event, but this method takes only 1 argument and invokes sort
@@ -603,11 +609,12 @@ DirectoryContents.prototype.onScanCompleted_ = function() {
if (this.scanCancelled_)
return;
- this.prefetchMetadataQueue_.run(function(callback) {
+ this.prefetchMetadataQueue_.run(function(callback, cancelled) {
hirono 2014/05/26 09:19:42 What is difference between this.scanCancelled_ and
yoshiki 2014/05/26 09:36:33 In this case, they are same. But in general, the c
hirono 2014/05/26 09:41:04 How about removing this.scanCancelled_ and using t
// Call callback first, so isScanning() returns false in the event handlers.
callback();
- cr.dispatchSimpleEvent(this, 'scan-completed');
+ if (!cancelled)
+ cr.dispatchSimpleEvent(this, 'scan-completed');
}.bind(this));
};
@@ -619,10 +626,12 @@ DirectoryContents.prototype.onScanError_ = function() {
if (this.scanCancelled_)
return;
- this.prefetchMetadataQueue_.run(function(callback) {
+ this.prefetchMetadataQueue_.run(function(callback, cancelled) {
// Call callback first, so isScanning() returns false in the event handlers.
callback();
- cr.dispatchSimpleEvent(this, 'scan-failed');
+
+ if (!cancelled)
+ cr.dispatchSimpleEvent(this, 'scan-failed');
}.bind(this));
};
@@ -655,7 +664,10 @@ DirectoryContents.prototype.onNewEntries_ = function(entries) {
var MAX_CHUNK_SIZE = 50;
for (var i = 0; i < entriesFiltered.length; i += MAX_CHUNK_SIZE) {
var chunk = entriesFiltered.slice(i, i + MAX_CHUNK_SIZE);
- this.prefetchMetadataQueue_.run(function(chunk, callback) {
+ this.prefetchMetadataQueue_.run(function(chunk, callback, cancelled) {
+ if (cancelled)
+ return callback();
hirono 2014/05/26 09:19:42 Maybe "callback(); return;" is more free from misr
yoshiki 2014/05/26 09:36:33 Done.
+
this.prefetchMetadata(chunk, function() {
if (this.scanCancelled_) {
// Do nothing if the scanning is cancelled.

Powered by Google App Engine
This is Rietveld 408576698