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

Unified Diff: chrome/browser/resources/file_manager/js/file_copy_manager.js

Issue 9652024: Only show progress bar after 500ms (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 9 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: chrome/browser/resources/file_manager/js/file_copy_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_copy_manager.js b/chrome/browser/resources/file_manager/js/file_copy_manager.js
index d29bb526a4b58fc60e4f0d31a50c3e7fb81379ba..2262df57b4fdf7e8a343f8b5c1a5706916ca2a72 100644
--- a/chrome/browser/resources/file_manager/js/file_copy_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_copy_manager.js
@@ -57,11 +57,14 @@ FileCopyManager.Task.prototype.setEntries = function(entries, callback) {
}
FileCopyManager.Task.prototype.takeNextEntry = function() {
Rick Byers 2012/03/09 21:45:45 This function name is misleading now (you're not '
bshe 2012/03/12 00:13:34 Done.
+ // We should keep the file in pending list and remove it after complete.
+ // Otherwise, if we try to get status in the middle of copying. The returned
+ // status is wrong (miss count the pasting item in totalItems).
if (this.pendingDirectories.length)
- return this.pendingDirectories.shift();
+ return this.pendingDirectories[0];
if (this.pendingFiles.length)
- return this.pendingFiles.shift();
+ return this.pendingFiles[0];
return null;
};
@@ -69,9 +72,11 @@ FileCopyManager.Task.prototype.takeNextEntry = function() {
FileCopyManager.Task.prototype.markEntryComplete = function(entry, size) {
if (entry.isDirectory) {
this.completedDirectories.push(entry);
+ this.pendingDirectories.shift();
Rick Byers 2012/03/09 21:45:45 You're implicitly assuming that 'entry' is still t
bshe 2012/03/12 00:13:34 It seems entry is targetEntry and shift function r
} else {
this.completedFiles.push(entry);
this.completedBytes += size;
+ this.pendingFiles.shift();
}
};
@@ -351,7 +356,9 @@ FileCopyManager.prototype.serviceNextTask_ = function(
}
function onEntryServiced(targetEntry, size) {
- if (!targetEntry) {
+ // We should not dispatch a PROGRESS event when there is no pending items
+ // in the task.
+ if (task.pendingDirectories.length + task.pendingFiles.length == 0) {
// All done with the entries in this task.
if (task.deleteAfterCopy) {
deleteOriginals()

Powered by Google App Engine
This is Rietveld 408576698