| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * @constructor | 6 * @constructor |
| 7 * @param {DirectoryEntry} root Root directory entry. | 7 * @param {DirectoryEntry} root Root directory entry. |
| 8 */ | 8 */ |
| 9 function FileCopyManager(root) { | 9 function FileCopyManager(root) { |
| 10 this.copyTasks_ = []; | 10 this.copyTasks_ = []; |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 function(dirEntry, fileName) { | 773 function(dirEntry, fileName) { |
| 774 sourceEntry.moveTo(dirEntry, fileName, | 774 sourceEntry.moveTo(dirEntry, fileName, |
| 775 onFilesystemMoveComplete.bind(self, sourceEntry), | 775 onFilesystemMoveComplete.bind(self, sourceEntry), |
| 776 onFilesystemError); | 776 onFilesystemError); |
| 777 }, | 777 }, |
| 778 onFilesystemError); | 778 onFilesystemError); |
| 779 return; | 779 return; |
| 780 } | 780 } |
| 781 | 781 |
| 782 if (task.sourceOnGData && task.targetOnGData) { | 782 if (task.sourceOnGData && task.targetOnGData) { |
| 783 // TODO(benchan): GDataFileSystem has not implemented directory copy, | 783 // TODO(benchan): DriveFileSystem has not implemented directory copy, |
| 784 // and thus we only call FileEntry.copyTo() for files. Revisit this | 784 // and thus we only call FileEntry.copyTo() for files. Revisit this |
| 785 // code when GDataFileSystem supports directory copy. | 785 // code when DriveFileSystem supports directory copy. |
| 786 if (!sourceEntry.isDirectory) { | 786 if (!sourceEntry.isDirectory) { |
| 787 resolveDirAndBaseName( | 787 resolveDirAndBaseName( |
| 788 targetDirEntry, targetRelativePath, | 788 targetDirEntry, targetRelativePath, |
| 789 function(dirEntry, fileName) { | 789 function(dirEntry, fileName) { |
| 790 sourceEntry.copyTo(dirEntry, fileName, | 790 sourceEntry.copyTo(dirEntry, fileName, |
| 791 onFilesystemCopyComplete.bind(self, sourceEntry), | 791 onFilesystemCopyComplete.bind(self, sourceEntry), |
| 792 onFilesystemError); | 792 onFilesystemError); |
| 793 }, | 793 }, |
| 794 onFilesystemError); | 794 onFilesystemError); |
| 795 return; | 795 return; |
| 796 } | 796 } |
| 797 } | 797 } |
| 798 | 798 |
| 799 // TODO(benchan): Until GDataFileSystem supports FileWriter, we use the | 799 // TODO(benchan): Until DriveFileSystem supports FileWriter, we use the |
| 800 // transferFile API to copy files into or out from a gdata file system. | 800 // transferFile API to copy files into or out from a gdata file system. |
| 801 if (sourceEntry.isFile && (task.sourceOnGData || task.targetOnGData)) { | 801 if (sourceEntry.isFile && (task.sourceOnGData || task.targetOnGData)) { |
| 802 var sourceFileUrl = sourceEntry.toURL(); | 802 var sourceFileUrl = sourceEntry.toURL(); |
| 803 var targetFileUrl = targetDirEntry.toURL() + '/' + | 803 var targetFileUrl = targetDirEntry.toURL() + '/' + |
| 804 encodeURIComponent(targetRelativePath); | 804 encodeURIComponent(targetRelativePath); |
| 805 var transferedBytes = 0; | 805 var transferedBytes = 0; |
| 806 function onFileTransfersUpdated(statusList) { | 806 function onFileTransfersUpdated(statusList) { |
| 807 for (var i = 0; i < statusList.length; i++) { | 807 for (var i = 0; i < statusList.length; i++) { |
| 808 var s = statusList[i]; | 808 var s = statusList[i]; |
| 809 if ((s.fileUrl == sourceFileUrl || s.fileUrl == targetFileUrl) && | 809 if ((s.fileUrl == sourceFileUrl || s.fileUrl == targetFileUrl) && |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 }; | 935 }; |
| 936 | 936 |
| 937 writer.write(file); | 937 writer.write(file); |
| 938 } | 938 } |
| 939 | 939 |
| 940 targetEntry.createWriter(onWriterCreated, errorCallback); | 940 targetEntry.createWriter(onWriterCreated, errorCallback); |
| 941 } | 941 } |
| 942 | 942 |
| 943 sourceEntry.file(onSourceFileFound, errorCallback); | 943 sourceEntry.file(onSourceFileFound, errorCallback); |
| 944 }; | 944 }; |
| 945 | |
| OLD | NEW |