Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Utilities for file operations. | 6 * Utilities for file operations. |
| 7 */ | 7 */ |
| 8 var fileOperationUtil = {}; | 8 var fileOperationUtil = {}; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 * @param {function()} successCallback Callback run on success. | 605 * @param {function()} successCallback Callback run on success. |
| 606 * @param {function(fileOperationUtil.Error)} errorCallback Callback run on | 606 * @param {function(fileOperationUtil.Error)} errorCallback Callback run on |
| 607 * error. | 607 * error. |
| 608 */ | 608 */ |
| 609 fileOperationUtil.Task.prototype.run = function( | 609 fileOperationUtil.Task.prototype.run = function( |
| 610 entryChangedCallback, progressCallback, successCallback, errorCallback) { | 610 entryChangedCallback, progressCallback, successCallback, errorCallback) { |
| 611 }; | 611 }; |
| 612 | 612 |
| 613 /** | 613 /** |
| 614 * Get states of the task. | 614 * Get states of the task. |
| 615 * TOOD(hirono): Removes this method and sets a task to progress events. | 615 * TODO(hirono): Removes this method and sets a task to progress events. |
| 616 * @return {Object} Status object. | 616 * @return {Object} Status object. |
| 617 */ | 617 */ |
| 618 fileOperationUtil.Task.prototype.getStatus = function() { | 618 fileOperationUtil.Task.prototype.getStatus = function() { |
| 619 var processingEntry = this.sourceEntries[this.processingSourceIndex_]; | 619 var processingEntry = this.sourceEntries[this.processingSourceIndex_]; |
| 620 var numRemainingItems = 0; | |
| 621 | |
| 622 var resolvedEntryMap; | |
| 623 if (this.processingEntries && this.processingEntries.length > 0) | |
| 624 resolvedEntryMap = this.processingEntries[this.processingSourceIndex_]; | |
| 625 | |
| 626 if (resolvedEntryMap) { | |
| 627 for (var key in resolvedEntryMap) { | |
|
fukino
2017/06/26 05:15:15
not lgtm, since this changes asymptotic time compl
tetsui
2017/06/26 06:51:20
Done.
| |
| 628 if (resolvedEntryMap.hasOwnProperty(key) && | |
| 629 resolvedEntryMap[key].processedBytes === 0) { | |
| 630 numRemainingItems++; | |
| 631 } | |
| 632 } | |
| 633 for (var i = this.processingSourceIndex_ + 1; | |
| 634 i < this.processingEntries.length; i++) { | |
| 635 numRemainingItems += Object.keys(this.processingEntries[i] || {}).length; | |
| 636 } | |
| 637 } else { | |
| 638 numRemainingItems = this.sourceEntries.length - this.processingSourceIndex_; | |
| 639 } | |
| 620 return { | 640 return { |
| 621 operationType: this.operationType, | 641 operationType: this.operationType, |
| 622 numRemainingItems: this.sourceEntries.length - this.processingSourceIndex_, | 642 numRemainingItems: numRemainingItems, |
| 623 totalBytes: this.totalBytes, | 643 totalBytes: this.totalBytes, |
| 624 processedBytes: this.processedBytes, | 644 processedBytes: this.processedBytes, |
| 625 processingEntryName: processingEntry ? processingEntry.name : '' | 645 processingEntryName: processingEntry ? processingEntry.name : '' |
| 626 }; | 646 }; |
| 627 }; | 647 }; |
| 628 | 648 |
| 629 /** | 649 /** |
| 630 * Obtains the number of total processed bytes. | 650 * Obtains the number of total processed bytes. |
| 631 * @return {number} Number of total processed bytes. | 651 * @return {number} Number of total processed bytes. |
| 632 * @private | 652 * @private |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1292 fileOperationUtil.EventRouter.prototype.sendDeleteEvent = function( | 1312 fileOperationUtil.EventRouter.prototype.sendDeleteEvent = function( |
| 1293 reason, task) { | 1313 reason, task) { |
| 1294 var event = /** @type {FileOperationProgressEvent} */ (new Event('delete')); | 1314 var event = /** @type {FileOperationProgressEvent} */ (new Event('delete')); |
| 1295 event.reason = reason; | 1315 event.reason = reason; |
| 1296 event.taskId = task.taskId; | 1316 event.taskId = task.taskId; |
| 1297 event.entries = task.entries; | 1317 event.entries = task.entries; |
| 1298 event.totalBytes = task.totalBytes; | 1318 event.totalBytes = task.totalBytes; |
| 1299 event.processedBytes = task.processedBytes; | 1319 event.processedBytes = task.processedBytes; |
| 1300 this.dispatchEvent(event); | 1320 this.dispatchEvent(event); |
| 1301 }; | 1321 }; |
| OLD | NEW |