| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 * @type {Object.<string, string>} | 50 * @type {Object.<string, string>} |
| 51 * @private | 51 * @private |
| 52 */ | 52 */ |
| 53 this.currentDirByRoot_ = {}; | 53 this.currentDirByRoot_ = {}; |
| 54 | 54 |
| 55 this.volumeManager_ = volumeManager; | 55 this.volumeManager_ = volumeManager; |
| 56 } | 56 } |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * Fake entry to be used in currentDirEntry_ when current directory is | 59 * Fake entry to be used in currentDirEntry_ when current directory is |
| 60 * unmounted DRIVE. | 60 * unmounted DRIVE. TODO(haruki): Support "drive/root" and "drive/other". |
| 61 * @private | 61 * @private |
| 62 */ | 62 */ |
| 63 DirectoryModel.fakeDriveEntry_ = { | 63 DirectoryModel.fakeDriveEntry_ = { |
| 64 fullPath: RootDirectory.DRIVE, | 64 fullPath: RootDirectory.DRIVE, |
| 65 isDirectory: true | 65 isDirectory: true |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Fake entry representing a psuedo directory, which contains Drive files | 69 * Fake entry representing a psuedo directory, which contains Drive files |
| 70 * available offline. This entry works as a trigger to start a search using | 70 * available offline. This entry works as a trigger to start a search using |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 | 1088 |
| 1089 readSingle(RootDirectory.DOWNLOADS.substring(1), 'downloads'); | 1089 readSingle(RootDirectory.DOWNLOADS.substring(1), 'downloads'); |
| 1090 util.readDirectory(root, RootDirectory.ARCHIVE.substring(1), | 1090 util.readDirectory(root, RootDirectory.ARCHIVE.substring(1), |
| 1091 append.bind(this, 'archives')); | 1091 append.bind(this, 'archives')); |
| 1092 util.readDirectory(root, RootDirectory.REMOVABLE.substring(1), | 1092 util.readDirectory(root, RootDirectory.REMOVABLE.substring(1), |
| 1093 append.bind(this, 'removables')); | 1093 append.bind(this, 'removables')); |
| 1094 | 1094 |
| 1095 if (this.driveEnabled_) { | 1095 if (this.driveEnabled_) { |
| 1096 var fake = [DirectoryModel.fakeDriveEntry_]; | 1096 var fake = [DirectoryModel.fakeDriveEntry_]; |
| 1097 if (this.isDriveMounted()) { | 1097 if (this.isDriveMounted()) { |
| 1098 readSingle(RootDirectory.DRIVE.substring(1), 'drive', fake); | 1098 readSingle(DirectoryModel.fakeDriveEntry_.fullPath, 'drive', fake); |
| 1099 } else { | 1099 } else { |
| 1100 groups.drive = fake; | 1100 groups.drive = fake; |
| 1101 } | 1101 } |
| 1102 // TODO(haruki): Add DirectoryModel.fakeDriveOfflineEntry_ to show the tab. | 1102 // TODO(haruki): Add DirectoryModel.fakeDriveOfflineEntry_ to show the tab. |
| 1103 } else { | 1103 } else { |
| 1104 groups.drive = []; | 1104 groups.drive = []; |
| 1105 } | 1105 } |
| 1106 }; | 1106 }; |
| 1107 | 1107 |
| 1108 /** | 1108 /** |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 var onGotDirectory = function(entry) { | 1177 var onGotDirectory = function(entry) { |
| 1178 this.updateRootEntry_(entry); | 1178 this.updateRootEntry_(entry); |
| 1179 var currentDirEntry = this.getCurrentDirEntry(); | 1179 var currentDirEntry = this.getCurrentDirEntry(); |
| 1180 if (currentDirEntry == DirectoryModel.fakeDriveEntry_) { | 1180 if (currentDirEntry == DirectoryModel.fakeDriveEntry_) { |
| 1181 this.changeDirectoryEntrySilent_(entry); | 1181 this.changeDirectoryEntrySilent_(entry); |
| 1182 } else if (currentDirEntry == DirectoryModel.fakeDriveOfflineEntry_) { | 1182 } else if (currentDirEntry == DirectoryModel.fakeDriveOfflineEntry_) { |
| 1183 // Need to update the results for offline available files. | 1183 // Need to update the results for offline available files. |
| 1184 this.getDriveOfflineFiles(''); | 1184 this.getDriveOfflineFiles(''); |
| 1185 } | 1185 } |
| 1186 } | 1186 } |
| 1187 this.root_.getDirectory(RootDirectory.DRIVE, {}, | 1187 this.root_.getDirectory( |
| 1188 onGotDirectory.bind(this)); | 1188 DirectoryModel.fakeDriveEntry_.fullPath, {}, |
| 1189 onGotDirectory.bind(this)); |
| 1190 // TODO(haruki): support "other" root. |
| 1189 } else { | 1191 } else { |
| 1190 var rootType = this.getCurrentRootType(); | 1192 var rootType = this.getCurrentRootType(); |
| 1191 if (rootType != RootType.DRIVE && rootType != RootType.DRIVE_OFFLINE) | 1193 if (rootType != RootType.DRIVE && rootType != RootType.DRIVE_OFFLINE) |
| 1192 return; | 1194 return; |
| 1193 | 1195 |
| 1194 // Current entry unmounted. Replace with fake drive one. | 1196 // Current entry unmounted. Replace with fake drive one. |
| 1195 this.updateRootEntry_(DirectoryModel.fakeDriveEntry_); | 1197 this.updateRootEntry_(DirectoryModel.fakeDriveEntry_); |
| 1196 if (this.getCurrentDirPath() == DirectoryModel.fakeDriveEntry_.fullPath) { | 1198 if (this.getCurrentDirPath() == DirectoryModel.fakeDriveEntry_.fullPath) { |
| 1197 // Replace silently and rescan. | 1199 // Replace silently and rescan. |
| 1198 this.changeDirectoryEntrySilent_(DirectoryModel.fakeDriveEntry_); | 1200 this.changeDirectoryEntrySilent_(DirectoryModel.fakeDriveEntry_); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 }.bind(this)); | 1506 }.bind(this)); |
| 1505 } | 1507 } |
| 1506 }; | 1508 }; |
| 1507 | 1509 |
| 1508 /** | 1510 /** |
| 1509 * @return {DirectoryEntry} Current watched directory entry. | 1511 * @return {DirectoryEntry} Current watched directory entry. |
| 1510 */ | 1512 */ |
| 1511 FileWatcher.prototype.getWatchedDirectoryEntry = function() { | 1513 FileWatcher.prototype.getWatchedDirectoryEntry = function() { |
| 1512 return this.watchedDirectoryEntry_; | 1514 return this.watchedDirectoryEntry_; |
| 1513 }; | 1515 }; |
| OLD | NEW |