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

Side by Side Diff: chrome/browser/resources/file_manager/js/file_copy_manager.js

Issue 15806002: Files.app: Fixed a bug of moving multiple files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'use strict'; 5 'use strict';
6 6
7 if (chrome.extension) { 7 if (chrome.extension) {
8 var getContentWindows = function() { 8 var getContentWindows = function() {
9 return chrome.extension.getViews(); 9 return chrome.extension.getViews();
10 }; 10 };
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 }; 82 };
83 83
84 /** 84 /**
85 * @param {Array.<Entry>} entries Entries. 85 * @param {Array.<Entry>} entries Entries.
86 * @param {function} callback When entries resolved. 86 * @param {function} callback When entries resolved.
87 */ 87 */
88 FileCopyManager.Task.prototype.setEntries = function(entries, callback) { 88 FileCopyManager.Task.prototype.setEntries = function(entries, callback) {
89 var self = this; 89 var self = this;
90 90
91 var onEntriesRecursed = function(result) { 91 var onEntriesRecursed = function(result) {
92 self.pendingDirectories = result.dirEntries; 92 // Deeper directory is moved earier.
93 self.pendingDirectories = result.dirEntries.sort(
94 function(a, b) { return a.fullPath < b.fullPath; });
93 self.pendingFiles = result.fileEntries; 95 self.pendingFiles = result.fileEntries;
94 self.pendingBytes = result.fileBytes; 96 self.pendingBytes = result.fileBytes;
95 callback(); 97 callback();
96 }; 98 };
97 99
98 this.originalEntries = entries; 100 this.originalEntries = entries;
99 // When moving directories, FileEntry.moveTo() is used if both source 101 // When moving directories, FileEntry.moveTo() is used if both source
100 // and target are on Drive. There is no need to recurse into directories. 102 // and target are on Drive. There is no need to recurse into directories.
101 var recurse = !this.move; 103 var recurse = !this.move;
102 util.recurseAndResolveEntries(entries, recurse, onEntriesRecursed); 104 util.recurseAndResolveEntries(entries, recurse, onEntriesRecursed);
103 }; 105 };
104 106
105 /** 107 /**
106 * @return {Entry} Next entry. 108 * @return {Entry} Next entry.
107 */ 109 */
108 FileCopyManager.Task.prototype.getNextEntry = function() { 110 FileCopyManager.Task.prototype.getNextEntry = function() {
109 // We should keep the file in pending list and remove it after complete. 111 // We should keep the file in pending list and remove it after complete.
110 // Otherwise, if we try to get status in the middle of copying. The returned 112 // Otherwise, if we try to get status in the middle of copying. The returned
111 // status is wrong (miss count the pasting item in totalItems). 113 // status is wrong (miss count the pasting item in totalItems).
114 if (this.pendingFiles.length) {
115 this.pendingFiles[0].inProgress = true;
116 return this.pendingFiles[0];
117 }
112 if (this.pendingDirectories.length) { 118 if (this.pendingDirectories.length) {
113 this.pendingDirectories[0].inProgress = true; 119 this.pendingDirectories[0].inProgress = true;
114 return this.pendingDirectories[0]; 120 return this.pendingDirectories[0];
115 } 121 }
116
117 if (this.pendingFiles.length) {
118 this.pendingFiles[0].inProgress = true;
119 return this.pendingFiles[0];
120 }
121
122 return null; 122 return null;
123 }; 123 };
124 124
125 /** 125 /**
126 * @param {Entry} entry Entry. 126 * @param {Entry} entry Entry.
127 * @param {number} size Bytes completed. 127 * @param {number} size Bytes completed.
128 */ 128 */
129 FileCopyManager.Task.prototype.markEntryComplete = function(entry, size) { 129 FileCopyManager.Task.prototype.markEntryComplete = function(entry, size) {
130 // It is probably not safe to directly remove the first entry in pending list. 130 // It is probably not safe to directly remove the first entry in pending list.
131 // We need to check if the removed entry (srcEntry) corresponding to the added 131 // We need to check if the removed entry (srcEntry) corresponding to the added
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 // Assume self.cancelRequested_ == false. 1279 // Assume self.cancelRequested_ == false.
1280 // This moved us from 0 to 1 active tasks, let the servicing begin! 1280 // This moved us from 0 to 1 active tasks, let the servicing begin!
1281 self.serviceAllTasks_(); 1281 self.serviceAllTasks_();
1282 } else { 1282 } else {
1283 // Force to update the progress of butter bar when there are new tasks 1283 // Force to update the progress of butter bar when there are new tasks
1284 // coming while servicing current task. 1284 // coming while servicing current task.
1285 self.sendProgressEvent_('PROGRESS'); 1285 self.sendProgressEvent_('PROGRESS');
1286 } 1286 }
1287 }); 1287 });
1288 }; 1288 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698