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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Utilities for FileOperationManager. | 8 * Utilities for FileOperationManager. |
9 */ | 9 */ |
10 var fileOperationUtil = {}; | 10 var fileOperationUtil = {}; |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 if (this.cancelRequested_) { | 629 if (this.cancelRequested_) { |
630 errorCallback(new FileOperationManager.Error( | 630 errorCallback(new FileOperationManager.Error( |
631 util.FileOperationErrorType.FILESYSTEM_ERROR, | 631 util.FileOperationErrorType.FILESYSTEM_ERROR, |
632 util.createDOMError(util.FileError.ABORT_ERR))); | 632 util.createDOMError(util.FileError.ABORT_ERR))); |
633 return; | 633 return; |
634 } | 634 } |
635 progressCallback(); | 635 progressCallback(); |
636 this.processEntry_( | 636 this.processEntry_( |
637 entry, this.targetDirEntry, | 637 entry, this.targetDirEntry, |
638 function(sourceEntry, destinationEntry) { | 638 function(sourceEntry, destinationEntry) { |
639 // Finalize the entry's progress state. | |
640 var sourceEntryURL = sourceEntry.toURL(); | |
641 var processedEntry = | |
642 this.processingEntries[index][sourceEntryURL]; | |
643 | |
644 // Update current source index. | |
645 this.processingSourceIndex_ = index + 1; | |
646 this.processedBytes = this.calcProcessedBytes_(); | |
647 | |
648 // The destination entry may be null, if the copied file got | 639 // The destination entry may be null, if the copied file got |
649 // deleted just after copying. | 640 // deleted just after copying. |
650 if (destinationEntry) { | 641 if (destinationEntry) { |
651 entryChangedCallback( | 642 entryChangedCallback( |
652 util.EntryChangedKind.CREATED, destinationEntry); | 643 util.EntryChangedKind.CREATED, destinationEntry); |
653 } | 644 } |
654 }.bind(this), | 645 }.bind(this), |
655 function(sourceEntry, size) { | 646 function(sourceEntry, size) { |
656 var sourceEntryURL = sourceEntry.toURL(); | 647 var sourceEntryURL = sourceEntry.toURL(); |
657 var processedEntry = | 648 var processedEntry = |
658 this.processingEntries[index][sourceEntryURL]; | 649 this.processingEntries[index][sourceEntryURL]; |
659 if (processedEntry) { | 650 if (processedEntry) { |
660 this.processedBytes += size - processedEntry.processedBytes; | 651 this.processedBytes += size - processedEntry.processedBytes; |
661 processedEntry.processedBytes = size; | 652 processedEntry.processedBytes = size; |
662 progressCallback(); | 653 progressCallback(); |
663 } | 654 } |
664 }.bind(this), | 655 }.bind(this), |
665 callback, | 656 function() { |
| 657 // Update current source index and processing bytes. |
| 658 this.processingSourceIndex_ = index + 1; |
| 659 this.processedBytes = this.calcProcessedBytes_(); |
| 660 callback(); |
| 661 }.bind(this), |
666 errorCallback); | 662 errorCallback); |
667 }, | 663 }, |
668 function() { | 664 function() { |
669 if (this.deleteAfterCopy) { | 665 if (this.deleteAfterCopy) { |
670 deleteOriginals(); | 666 deleteOriginals(); |
671 } else { | 667 } else { |
672 successCallback(); | 668 successCallback(); |
673 } | 669 } |
674 }.bind(this), | 670 }.bind(this), |
675 this); | 671 this); |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 | 1341 |
1346 /** | 1342 /** |
1347 * Generates new task ID. | 1343 * Generates new task ID. |
1348 * | 1344 * |
1349 * @return {string} New task ID. | 1345 * @return {string} New task ID. |
1350 * @private | 1346 * @private |
1351 */ | 1347 */ |
1352 FileOperationManager.prototype.generateTaskId_ = function() { | 1348 FileOperationManager.prototype.generateTaskId_ = function() { |
1353 return 'file-operation-' + this.taskIdCounter_++; | 1349 return 'file-operation-' + this.taskIdCounter_++; |
1354 }; | 1350 }; |
OLD | NEW |