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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 // If directory files changes too often, don't rescan directory more than once | 7 // If directory files changes too often, don't rescan directory more than once |
8 // per specified interval | 8 // per specified interval |
9 var SIMULTANEOUS_RESCAN_INTERVAL = 1000; | 9 var SIMULTANEOUS_RESCAN_INTERVAL = 1000; |
10 // Used for operations that require almost instant rescan. | 10 // Used for operations that require almost instant rescan. |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 }; | 879 }; |
880 | 880 |
881 this.currentDirContents_.createDirectory(name, onSuccess.bind(this), | 881 this.currentDirContents_.createDirectory(name, onSuccess.bind(this), |
882 errorCallback); | 882 errorCallback); |
883 }; | 883 }; |
884 | 884 |
885 /** | 885 /** |
886 * Changes directory. Causes 'directory-change' event. | 886 * Changes directory. Causes 'directory-change' event. |
887 * | 887 * |
888 * @param {string} path New current directory path. | 888 * @param {string} path New current directory path. |
889 * @param {function()=} opt_errorCallback Executed if the change directory | 889 * @param {function(FileError)=} opt_errorCallback Executed if the change |
890 * failed. | 890 * directory failed. |
891 */ | 891 */ |
892 DirectoryModel.prototype.changeDirectory = function(path, opt_errorCallback) { | 892 DirectoryModel.prototype.changeDirectory = function(path, opt_errorCallback) { |
893 if (PathUtil.isSpecialSearchRoot(path)) { | 893 if (PathUtil.isSpecialSearchRoot(path)) { |
894 this.specialSearch(path, ''); | 894 this.specialSearch(path, ''); |
895 return; | 895 return; |
896 } | 896 } |
897 | 897 |
898 this.resolveDirectory(path, function(directoryEntry) { | 898 this.resolveDirectory(path, function(directoryEntry) { |
899 this.changeDirectoryEntry_(false, directoryEntry); | 899 this.changeDirectoryEntry_(false, directoryEntry); |
900 }.bind(this), function(error) { | 900 }.bind(this), function(error) { |
901 console.error('Error changing directory to ' + path + ': ', error); | 901 console.error('Error changing directory to ' + path + ': ', error); |
902 if (opt_errorCallback) | 902 if (opt_errorCallback) |
903 opt_errorCallback(); | 903 opt_errorCallback(error); |
904 }); | 904 }); |
905 }; | 905 }; |
906 | 906 |
907 /** | 907 /** |
908 * Resolves absolute directory path. Handles Drive stub. If the drive is | 908 * Resolves absolute directory path. Handles Drive stub. If the drive is |
909 * mounting, callbacks will be called after the mount is completed. | 909 * mounting, callbacks will be called after the mount is completed. |
910 * | 910 * |
911 * @param {string} path Path to the directory. | 911 * @param {string} path Path to the directory. |
912 * @param {function(DirectoryEntry)} successCallback Success callback. | 912 * @param {function(DirectoryEntry)} successCallback Success callback. |
913 * @param {function(FileError)} errorCallback Error callback. | 913 * @param {function(FileError)} errorCallback Error callback. |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 if (this.onSearchCompleted_) { | 1419 if (this.onSearchCompleted_) { |
1420 this.removeEventListener('scan-completed', this.onSearchCompleted_); | 1420 this.removeEventListener('scan-completed', this.onSearchCompleted_); |
1421 this.onSearchCompleted_ = null; | 1421 this.onSearchCompleted_ = null; |
1422 } | 1422 } |
1423 | 1423 |
1424 if (this.onClearSearch_) { | 1424 if (this.onClearSearch_) { |
1425 this.onClearSearch_(); | 1425 this.onClearSearch_(); |
1426 this.onClearSearch_ = null; | 1426 this.onClearSearch_ = null; |
1427 } | 1427 } |
1428 }; | 1428 }; |
OLD | NEW |