| 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 opt_callback) { | 483 opt_callback) { |
| 484 if (this.currentDirContents_.isScanning()) | 484 if (this.currentDirContents_.isScanning()) |
| 485 this.currentDirContents_.cancelScan(); | 485 this.currentDirContents_.cancelScan(); |
| 486 this.currentDirContents_ = newDirContents; | 486 this.currentDirContents_ = newDirContents; |
| 487 this.clearRescanTimeout_(); | 487 this.clearRescanTimeout_(); |
| 488 | 488 |
| 489 if (this.pendingScan_) | 489 if (this.pendingScan_) |
| 490 this.pendingScan_ = false; | 490 this.pendingScan_ = false; |
| 491 | 491 |
| 492 if (this.runningScan_) { | 492 if (this.runningScan_) { |
| 493 this.runningScan_.cancelScan(); | 493 if (this.runningScan_.isScanning()) |
| 494 this.runningScan_.cancelScan(); |
| 494 this.runningScan_ = null; | 495 this.runningScan_ = null; |
| 495 } | 496 } |
| 496 | 497 |
| 497 var onDone = function() { | 498 var onDone = function() { |
| 498 cr.dispatchSimpleEvent(this, 'scan-completed'); | 499 cr.dispatchSimpleEvent(this, 'scan-completed'); |
| 499 if (opt_callback) | 500 if (opt_callback) |
| 500 opt_callback(); | 501 opt_callback(); |
| 501 }.bind(this); | 502 }.bind(this); |
| 502 | 503 |
| 503 var onFailed = function() { | 504 var onFailed = function() { |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 // rescan if necessary. | 1193 // rescan if necessary. |
| 1193 driveRoot = null; | 1194 driveRoot = null; |
| 1194 } | 1195 } |
| 1195 | 1196 |
| 1196 var specialSearchType = PathUtil.getRootType(path); | 1197 var specialSearchType = PathUtil.getRootType(path); |
| 1197 var searchOption; | 1198 var searchOption; |
| 1198 var dirEntry; | 1199 var dirEntry; |
| 1199 if (specialSearchType == RootType.DRIVE_OFFLINE) { | 1200 if (specialSearchType == RootType.DRIVE_OFFLINE) { |
| 1200 dirEntry = DirectoryModel.fakeDriveOfflineEntry_; | 1201 dirEntry = DirectoryModel.fakeDriveOfflineEntry_; |
| 1201 searchOption = | 1202 searchOption = |
| 1202 DirectoryContentsDriveSearchMetadata.SearchType.SEARCH_OFFLINE; | 1203 DriveMetadataSearchContentScanner.SearchType.SEARCH_OFFLINE; |
| 1203 } else if (specialSearchType == RootType.DRIVE_SHARED_WITH_ME) { | 1204 } else if (specialSearchType == RootType.DRIVE_SHARED_WITH_ME) { |
| 1204 dirEntry = DirectoryModel.fakeDriveSharedWithMeEntry_; | 1205 dirEntry = DirectoryModel.fakeDriveSharedWithMeEntry_; |
| 1205 searchOption = | 1206 searchOption = |
| 1206 DirectoryContentsDriveSearchMetadata.SearchType.SEARCH_SHARED_WITH_ME; | 1207 DriveMetadataSearchContentScanner.SearchType.SEARCH_SHARED_WITH_ME; |
| 1207 } else if (specialSearchType == RootType.DRIVE_RECENT) { | 1208 } else if (specialSearchType == RootType.DRIVE_RECENT) { |
| 1208 dirEntry = DirectoryModel.fakeDriveRecentEntry_; | 1209 dirEntry = DirectoryModel.fakeDriveRecentEntry_; |
| 1209 searchOption = | 1210 searchOption = |
| 1210 DirectoryContentsDriveSearchMetadata.SearchType.SEARCH_RECENT_FILES; | 1211 DriveMetadataSearchContentScanner.SearchType.SEARCH_RECENT_FILES; |
| 1211 | 1212 |
| 1212 } else { | 1213 } else { |
| 1213 // Unknown path. | 1214 // Unknown path. |
| 1214 this.changeDirectory(PathUtil.DEFAULT_DIRECTORY); | 1215 this.changeDirectory(PathUtil.DEFAULT_DIRECTORY); |
| 1215 return; | 1216 return; |
| 1216 } | 1217 } |
| 1217 | 1218 |
| 1218 var newDirContents = new DirectoryContentsDriveSearchMetadata( | 1219 var newDirContents = new DirectoryContentsDriveSearchMetadata( |
| 1219 this.currentFileListContext_, | 1220 this.currentFileListContext_, |
| 1220 driveRoot, | 1221 driveRoot, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1247 if (this.onSearchCompleted_) { | 1248 if (this.onSearchCompleted_) { |
| 1248 this.removeEventListener('scan-completed', this.onSearchCompleted_); | 1249 this.removeEventListener('scan-completed', this.onSearchCompleted_); |
| 1249 this.onSearchCompleted_ = null; | 1250 this.onSearchCompleted_ = null; |
| 1250 } | 1251 } |
| 1251 | 1252 |
| 1252 if (this.onClearSearch_) { | 1253 if (this.onClearSearch_) { |
| 1253 this.onClearSearch_(); | 1254 this.onClearSearch_(); |
| 1254 this.onClearSearch_ = null; | 1255 this.onClearSearch_ = null; |
| 1255 } | 1256 } |
| 1256 }; | 1257 }; |
| OLD | NEW |