| 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 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1162 this.clearAndScan_(newDirContents); | 1162 this.clearAndScan_(newDirContents); |
| 1163 this.clearSearch_(); | 1163 this.clearSearch_(); |
| 1164 } | 1164 } |
| 1165 return; | 1165 return; |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 // If we already have event listener for an old search, we have to remove it. | 1168 // If we already have event listener for an old search, we have to remove it. |
| 1169 if (this.onSearchCompleted_) | 1169 if (this.onSearchCompleted_) |
| 1170 this.removeEventListener('scan-completed', this.onSearchCompleted_); | 1170 this.removeEventListener('scan-completed', this.onSearchCompleted_); |
| 1171 | 1171 |
| 1172 // Current search will be cancelled. |
| 1173 if (this.onClearSearch_) |
| 1174 this.onClearSearch_(); |
| 1175 |
| 1172 this.onSearchCompleted_ = onSearchRescan; | 1176 this.onSearchCompleted_ = onSearchRescan; |
| 1173 this.onClearSearch_ = onClearSearch; | 1177 this.onClearSearch_ = onClearSearch; |
| 1174 | 1178 |
| 1175 this.addEventListener('scan-completed', this.onSearchCompleted_); | 1179 this.addEventListener('scan-completed', this.onSearchCompleted_); |
| 1176 | 1180 |
| 1177 // If we are offline, let's fallback to file name search inside dir. | 1181 // If we are offline, let's fallback to file name search inside dir. |
| 1178 if (this.getCurrentRootType() === RootType.GDATA && !this.isOffline()) { | 1182 if (this.getCurrentRootType() === RootType.GDATA && !this.isOffline()) { |
| 1179 newDirContents = new DirectoryContentsGDataSearch( | 1183 newDirContents = new DirectoryContentsGDataSearch( |
| 1180 this.currentFileListContext_, this.getCurrentDirEntry(), query); | 1184 this.currentFileListContext_, this.getCurrentDirEntry(), query); |
| 1181 } else { | 1185 } else { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 }.bind(this)); | 1344 }.bind(this)); |
| 1341 } | 1345 } |
| 1342 }; | 1346 }; |
| 1343 | 1347 |
| 1344 /** | 1348 /** |
| 1345 * @return {DirectoryEntry} Current watched directory entry. | 1349 * @return {DirectoryEntry} Current watched directory entry. |
| 1346 */ | 1350 */ |
| 1347 FileWatcher.prototype.getWatchedDirectoryEntry = function() { | 1351 FileWatcher.prototype.getWatchedDirectoryEntry = function() { |
| 1348 return this.watchedDirectoryEntry_; | 1352 return this.watchedDirectoryEntry_; |
| 1349 }; | 1353 }; |
| OLD | NEW |