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

Unified Diff: ui/file_manager/file_manager/background/js/media_import_handler.js

Issue 964533003: Files.app: Fix task cancellation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2311
Patch Set: Created 5 years, 10 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/background/js/media_import_handler_unittest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/background/js/media_import_handler.js
diff --git a/ui/file_manager/file_manager/background/js/media_import_handler.js b/ui/file_manager/file_manager/background/js/media_import_handler.js
index 9065e05b120e19d08378e89f0339d2ef3238d912..1ccb473db899e88a8940c59915ffb6942bf2a03b 100644
--- a/ui/file_manager/file_manager/background/js/media_import_handler.js
+++ b/ui/file_manager/file_manager/background/js/media_import_handler.js
@@ -109,8 +109,6 @@ importer.MediaImportHandler.prototype.onTaskProgress_ =
item.id = task.taskId;
// TODO(kenobi): Might need a different progress item type here.
item.type = ProgressItemType.COPY;
- item.message =
- strf('CLOUD_IMPORT_ITEMS_REMAINING', task.remainingFilesCount);
item.progressMax = task.totalBytes;
item.cancelCallback = function() {
task.requestCancel();
@@ -119,18 +117,20 @@ importer.MediaImportHandler.prototype.onTaskProgress_ =
switch (updateType) {
case UpdateType.PROGRESS:
- item.progressValue = task.processedBytes;
item.message =
strf('CLOUD_IMPORT_ITEMS_REMAINING', task.remainingFilesCount);
- break;
- case UpdateType.SUCCESS:
+ item.progressValue = task.processedBytes;
+ item.state = ProgressItemState.PROGRESSING;
+ break;
+ case UpdateType.COMPLETE:
item.message = '';
item.progressValue = item.progressMax;
item.state = ProgressItemState.COMPLETED;
break;
case UpdateType.ERROR:
- item.message = '';
- item.progressValue = item.progressMax;
+ item.message =
+ strf('CLOUD_IMPORT_ITEMS_REMAINING', task.remainingFilesCount);
+ item.progressValue = task.processedBytes;
item.state = ProgressItemState.ERROR;
break;
case UpdateType.CANCELED:
@@ -337,7 +337,8 @@ importer.MediaImportHandler.ImportTask.prototype.importOne_ =
return this.copy_(entry, destinationDirectory);
}
}.bind(this))
- .then(completionCallback);
+ // Regardless of the result of this copy, push on to the next file.
+ .then(completionCallback, completionCallback);
};
/**
@@ -401,7 +402,12 @@ importer.MediaImportHandler.ImportTask.prototype.copy_ =
/** @this {importer.MediaImportHandler.ImportTask} */
var onError = function(error) {
this.cancelCallback_ = null;
- this.onError_(error);
+ this.errorCount_++;
+ // Log the bytes as processed in spite of the error. This ensures
+ // completion of the progress bar.
+ this.processedBytes_ -= currentBytes;
+ this.processedBytes_ += entry.size;
+ this.notify(importer.TaskQueue.UpdateType.ERROR);
resolver.reject(error);
};
@@ -474,21 +480,12 @@ importer.MediaImportHandler.ImportTask.prototype.markAsImported_ =
/** @private */
importer.MediaImportHandler.ImportTask.prototype.onSuccess_ = function() {
- this.notify(importer.TaskQueue.UpdateType.SUCCESS);
+ this.notify(importer.TaskQueue.UpdateType.COMPLETE);
this.tracker_.send(metrics.ImportEvents.ENDED);
this.sendImportStats_();
};
/**
- * @param {DOMError} error
- * @private
- */
-importer.MediaImportHandler.ImportTask.prototype.onError_ = function(error) {
- this.notify(importer.TaskQueue.UpdateType.ERROR);
- this.errorCount_++;
-};
-
-/**
* Sends import statistics to analytics.
*/
importer.MediaImportHandler.ImportTask.prototype.sendImportStats_ = function() {
« no previous file with comments | « no previous file | ui/file_manager/file_manager/background/js/media_import_handler_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698