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

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

Issue 22150006: Re-implement cancellation of copyFileEntry_(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/file_manager/js/file_copy_manager.js ('k') | 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 /** 7 /**
8 * Namespace for utility functions. 8 * Namespace for utility functions.
9 */ 9 */
10 var util = {}; 10 var util = {};
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // Found a path that doesn't exist. 498 // Found a path that doesn't exist.
499 onSuccess(trialPath); 499 onSuccess(trialPath);
500 } 500 }
501 501
502 var numRetry = MAX_RETRY; 502 var numRetry = MAX_RETRY;
503 var onResolved = function(entry) { 503 var onResolved = function(entry) {
504 if (--numRetry == 0) { 504 if (--numRetry == 0) {
505 // Hit the limit of the number of retrial. 505 // Hit the limit of the number of retrial.
506 // Note that we cannot create FileError object directly, so here we use 506 // Note that we cannot create FileError object directly, so here we use
507 // Object.create instead. 507 // Object.create instead.
508 onError(Object.create(FileError.prototype, { 508 onError(util.createFileError(FileError.PATH_EXISTS_ERR));
509 code: {
510 get: function() { return FileError.PATH_EXISTS_ERR; }
511 }
512 }));
513 return; 509 return;
514 } 510 }
515 511
516 ++copyNumber; 512 ++copyNumber;
517 trialPath = prefix + ' (' + copyNumber + ')' + ext; 513 trialPath = prefix + ' (' + copyNumber + ')' + ext;
518 util.resolvePath(dirEntry, trialPath, onResolved, onNotResolved); 514 util.resolvePath(dirEntry, trialPath, onResolved, onNotResolved);
519 }; 515 };
520 516
521 // Check to see if the target exists. 517 // Check to see if the target exists.
522 util.resolvePath(dirEntry, trialPath, onResolved, onNotResolved); 518 util.resolvePath(dirEntry, trialPath, onResolved, onNotResolved);
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 }; 1156 };
1161 1157
1162 /** 1158 /**
1163 * @param {DirectoryEntry|Object} entry DirectoryEntry to be checked. 1159 * @param {DirectoryEntry|Object} entry DirectoryEntry to be checked.
1164 * @return {boolean} True if the given entry is fake. 1160 * @return {boolean} True if the given entry is fake.
1165 */ 1161 */
1166 util.isFakeDirectoryEntry = function(entry) { 1162 util.isFakeDirectoryEntry = function(entry) {
1167 // Currently, fake entry doesn't support createReader. 1163 // Currently, fake entry doesn't support createReader.
1168 return !('createReader' in entry); 1164 return !('createReader' in entry);
1169 }; 1165 };
1166
1167 /**
1168 * Creates a FileError instance with given code.
1169 * Note that we cannot create FileError instance by "new FileError(code)",
1170 * unfortunately, so here we use Object.create.
1171 * @param {number} code Error code for the FileError.
1172 * @return {FileError} FileError instance
1173 */
1174 util.createFileError = function(code) {
1175 return Object.create(FileError.prototype, {
1176 code: { get: function() { return code; } }
1177 });
1178 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/js/file_copy_manager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698