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

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

Issue 507293002: Enrich fileBrowserPrivate.onFileTransfersUpdated event to support displaying total number of jobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/background/js/drive_sync_handler.js
diff --git a/ui/file_manager/file_manager/background/js/drive_sync_handler.js b/ui/file_manager/file_manager/background/js/drive_sync_handler.js
index f655957ebecb09184905ab6f91a9134972bd7aca..18cf498405f4598721c0f0c6d5a893377d5cc48a 100644
--- a/ui/file_manager/file_manager/background/js/drive_sync_handler.js
+++ b/ui/file_manager/file_manager/background/js/drive_sync_handler.js
@@ -85,13 +85,18 @@ DriveSyncHandler.prototype.onFileTransfersUpdated_ = function(statusList) {
for (var i = 0; i < statusList.length; i++) {
var status = statusList[i];
switch (status.transferState) {
+ case 'added':
+ this.removeItem_(status,'sync');
hirono 2014/08/27 08:37:20 Please make the 'sync' constant.
hirono 2014/08/27 08:37:21 Can we just update the item?
iseki 2014/08/28 07:13:32 Done.
iseki 2014/08/28 07:13:32 Done.
+ this.updateItem_(status, 'sync');
+ break;
case 'in_progress':
case 'started':
- this.updateItem_(status);
+ this.removeItem_(status, 'sync');
+ this.updateItem_(status, 'sync');
break;
case 'completed':
case 'failed':
- this.removeItem_(status);
+ this.removeItem_(status, 'sync');
if (!this.syncing)
this.dispatchEvent(new Event(DriveSyncHandler.COMPLETED_EVENT));
break;
@@ -105,9 +110,10 @@ DriveSyncHandler.prototype.onFileTransfersUpdated_ = function(statusList) {
/**
* Updates the item involved with the given status.
* @param {FileTransferStatus} status Transfer status.
+ * @patam {String} label which indicate a lamp of process.
hirono 2014/08/27 08:37:20 The style of JSDoc for parameters is: @param {typ
hirono 2014/08/27 08:37:21 @patam -> @param String -> string String is primit
iseki 2014/08/28 07:13:32 Done.
iseki 2014/08/28 07:13:32 Done.
* @private
*/
-DriveSyncHandler.prototype.updateItem_ = function(status) {
+DriveSyncHandler.prototype.updateItem_ = function(status, label) {
hirono 2014/08/27 08:37:20 The label sounds like a text displayed in UI eleme
iseki 2014/08/28 07:13:32 Done.
this.queue_.run(function(callback) {
if (this.items_[status.fileUrl]) {
callback();
@@ -119,9 +125,13 @@ DriveSyncHandler.prototype.updateItem_ = function(status) {
DriveSyncHandler.PROGRESS_ITEM_ID_PREFIX + (this.idCounter_++);
item.type = ProgressItemType.SYNC;
item.quiet = true;
- item.message = strf('SYNC_FILE_NAME', entry.name);
+ if (status.num_total_jobs > 1) {
+ item.message = strf('SYNC_FILE_NAME', status.num_total_jobs + ' items');
hirono 2014/08/27 08:37:21 'items' should be a part of locale string. This ca
+ } else {
+ item.message = strf('SYNC_FILE_NAME', entry.name);
+ }
item.cancelCallback = this.requestCancel_.bind(this, entry);
- this.items_[status.fileUrl] = item;
+ this.items_[label] = item;
callback();
}.bind(this), function(error) {
console.warn('Resolving URL ' + status.fileUrl + ' is failed: ', error);
@@ -129,7 +139,7 @@ DriveSyncHandler.prototype.updateItem_ = function(status) {
});
}.bind(this));
this.queue_.run(function(callback) {
- var item = this.items_[status.fileUrl];
+ var item = this.items_[label];
if (!item) {
callback();
return;
@@ -144,11 +154,12 @@ DriveSyncHandler.prototype.updateItem_ = function(status) {
/**
* Removes the item involved with the given status.
* @param {FileTransferStatus} status Transfer status.
+ * @patam {String} label which indicate a lamp of process.
hirono 2014/08/27 08:37:20 ditto.
iseki 2014/08/28 07:13:32 Done.
* @private
*/
-DriveSyncHandler.prototype.removeItem_ = function(status) {
+DriveSyncHandler.prototype.removeItem_ = function(status, label) {
this.queue_.run(function(callback) {
- var item = this.items_[status.fileUrl];
+ var item = this.items_[label];
if (!item) {
callback();
return;
@@ -156,7 +167,7 @@ DriveSyncHandler.prototype.removeItem_ = function(status) {
item.state = status.transferState === 'completed' ?
ProgressItemState.COMPLETED : ProgressItemState.CANCELED;
this.progressCenter_.updateItem(item);
- delete this.items_[status.fileUrl];
+ delete this.items_[label];
callback();
}.bind(this));
};

Powered by Google App Engine
This is Rietveld 408576698