| 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 // If directory files changes too often, don't rescan directory more than once | 5 // If directory files changes too often, don't rescan directory more than once |
| 6 // per specified interval | 6 // per specified interval |
| 7 var SIMULTANEOUS_RESCAN_INTERVAL = 1000; | 7 var SIMULTANEOUS_RESCAN_INTERVAL = 1000; |
| 8 // Used for operations that require almost instant rescan. | 8 // Used for operations that require almost instant rescan. |
| 9 var SHORT_RESCAN_INTERVAL = 100; | 9 var SHORT_RESCAN_INTERVAL = 100; |
| 10 | 10 |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 tracker.hasChanged = true; | 844 tracker.hasChanged = true; |
| 845 } | 845 } |
| 846 }; | 846 }; |
| 847 return tracker; | 847 return tracker; |
| 848 }; | 848 }; |
| 849 | 849 |
| 850 /** | 850 /** |
| 851 * Change the state of the model to reflect the specified path (either a | 851 * Change the state of the model to reflect the specified path (either a |
| 852 * file or directory). | 852 * file or directory). |
| 853 * | 853 * |
| 854 * @param {string} path The root path to use | 854 * @param {string} path The root path to use. |
| 855 * @param {function=} opt_pathResolveCallback Invoked as soon as the path has | 855 * @param {function=} opt_pathResolveCallback Invoked as soon as the path has |
| 856 * been resolved, and called with the base and leaf portions of the path | 856 * been resolved, and called with the base and leaf portions of the path |
| 857 * name, and a flag indicating if the entry exists. Will be called even | 857 * name, and a flag indicating if the entry exists. Will be called even |
| 858 * if another directory change happened while setupPath was in progress, | 858 * if another directory change happened while setupPath was in progress, |
| 859 * but will pass |false| as |exist| parameter. | 859 * but will pass |false| as |exist| parameter. |
| 860 */ | 860 */ |
| 861 DirectoryModel.prototype.setupPath = function(path, opt_pathResolveCallback) { | 861 DirectoryModel.prototype.setupPath = function(path, opt_pathResolveCallback) { |
| 862 var tracker = this.createDirectoryChangeTracker(); | 862 var tracker = this.createDirectoryChangeTracker(); |
| 863 tracker.start(); | 863 tracker.start(); |
| 864 | 864 |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 for (var i = 0; i != this.rootsList_.length; i++) { | 1161 for (var i = 0; i != this.rootsList_.length; i++) { |
| 1162 if (this.rootsList_.item(i).fullPath == entry.fullPath) { | 1162 if (this.rootsList_.item(i).fullPath == entry.fullPath) { |
| 1163 this.rootsList_.splice(i, 1, entry); | 1163 this.rootsList_.splice(i, 1, entry); |
| 1164 return; | 1164 return; |
| 1165 } | 1165 } |
| 1166 } | 1166 } |
| 1167 console.error('Cannot find root: ' + entry.fullPath); | 1167 console.error('Cannot find root: ' + entry.fullPath); |
| 1168 }; | 1168 }; |
| 1169 | 1169 |
| 1170 /** | 1170 /** |
| 1171 * @param {string} path Path | 1171 * @param {string} path Path. |
| 1172 * @return {boolean} If current directory is system. | 1172 * @return {boolean} If current directory is system. |
| 1173 */ | 1173 */ |
| 1174 DirectoryModel.isSystemDirectory = function(path) { | 1174 DirectoryModel.isSystemDirectory = function(path) { |
| 1175 path = path.replace(/\/+$/, ''); | 1175 path = path.replace(/\/+$/, ''); |
| 1176 return path === RootDirectory.REMOVABLE || path === RootDirectory.ARCHIVE; | 1176 return path === RootDirectory.REMOVABLE || path === RootDirectory.ARCHIVE; |
| 1177 }; | 1177 }; |
| 1178 | 1178 |
| 1179 /** | 1179 /** |
| 1180 * Check if the root of the given path is mountable or not. | 1180 * Check if the root of the given path is mountable or not. |
| 1181 * | 1181 * |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1198 }; | 1198 }; |
| 1199 | 1199 |
| 1200 /** | 1200 /** |
| 1201 * Performs search and displays results. The search type is dependent on the | 1201 * Performs search and displays results. The search type is dependent on the |
| 1202 * current directory. If we are currently on drive, server side content search | 1202 * current directory. If we are currently on drive, server side content search |
| 1203 * over drive mount point. If the current directory is not on the drive, file | 1203 * over drive mount point. If the current directory is not on the drive, file |
| 1204 * name search over current directory wil be performed. | 1204 * name search over current directory wil be performed. |
| 1205 * | 1205 * |
| 1206 * @param {string} query Query that will be searched for. | 1206 * @param {string} query Query that will be searched for. |
| 1207 * @param {function} onSearchRescan Function that will be called when the search | 1207 * @param {function} onSearchRescan Function that will be called when the search |
| 1208 * directory is rescanned (i.e. search results are displayed) | 1208 * directory is rescanned (i.e. search results are displayed). |
| 1209 * @param {function} onClearSearch Function to be called when search state gets | 1209 * @param {function} onClearSearch Function to be called when search state gets |
| 1210 * cleared. | 1210 * cleared. |
| 1211 * TODO(olege): Change callbacks to events. | 1211 * TODO(olege): Change callbacks to events. |
| 1212 */ | 1212 */ |
| 1213 DirectoryModel.prototype.search = function(query, | 1213 DirectoryModel.prototype.search = function(query, |
| 1214 onSearchRescan, | 1214 onSearchRescan, |
| 1215 onClearSearch) { | 1215 onClearSearch) { |
| 1216 query = query.trimLeft(); | 1216 query = query.trimLeft(); |
| 1217 | 1217 |
| 1218 this.clearSearch_(); | 1218 this.clearSearch_(); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1404 }.bind(this)); | 1404 }.bind(this)); |
| 1405 } | 1405 } |
| 1406 }; | 1406 }; |
| 1407 | 1407 |
| 1408 /** | 1408 /** |
| 1409 * @return {DirectoryEntry} Current watched directory entry. | 1409 * @return {DirectoryEntry} Current watched directory entry. |
| 1410 */ | 1410 */ |
| 1411 FileWatcher.prototype.getWatchedDirectoryEntry = function() { | 1411 FileWatcher.prototype.getWatchedDirectoryEntry = function() { |
| 1412 return this.watchedDirectoryEntry_; | 1412 return this.watchedDirectoryEntry_; |
| 1413 }; | 1413 }; |
| OLD | NEW |