Chromium Code Reviews| 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 | |
|
yoshiki
2013/03/15 06:26:58
nit: remove
Haruki Sato
2013/03/15 06:49:47
Done. Thanks.
| |
| 68 /** | 69 /** |
| 69 * Fake entry representing a psuedo directory, which contains Drive files | 70 * Fake entry representing a psuedo directory, which contains Drive files |
| 70 * available offline. This entry works as a trigger to start a search using | 71 * available offline. This entry works as a trigger to start a search using |
| 71 * DirectoryContentsDriveOffline. | 72 * DirectoryContentsDriveOffline. |
| 72 * DirectoryModel is responsible to start the search when the UI tries to open | 73 * DirectoryModel is responsible to start the search when the UI tries to open |
| 73 * this fake entry (e.g. changeDirectory()). | 74 * this fake entry (e.g. changeDirectory()). |
| 74 * @private | 75 * @private |
| 75 */ | 76 */ |
| 76 DirectoryModel.fakeDriveOfflineEntry_ = { | 77 DirectoryModel.fakeDriveOfflineEntry_ = { |
| 77 fullPath: RootDirectory.DRIVE_OFFLINE, | 78 fullPath: RootDirectory.DRIVE_OFFLINE, |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1088 | 1089 |
| 1089 readSingle(RootDirectory.DOWNLOADS.substring(1), 'downloads'); | 1090 readSingle(RootDirectory.DOWNLOADS.substring(1), 'downloads'); |
| 1090 util.readDirectory(root, RootDirectory.ARCHIVE.substring(1), | 1091 util.readDirectory(root, RootDirectory.ARCHIVE.substring(1), |
| 1091 append.bind(this, 'archives')); | 1092 append.bind(this, 'archives')); |
| 1092 util.readDirectory(root, RootDirectory.REMOVABLE.substring(1), | 1093 util.readDirectory(root, RootDirectory.REMOVABLE.substring(1), |
| 1093 append.bind(this, 'removables')); | 1094 append.bind(this, 'removables')); |
| 1094 | 1095 |
| 1095 if (this.driveEnabled_) { | 1096 if (this.driveEnabled_) { |
| 1096 var fake = [DirectoryModel.fakeDriveEntry_]; | 1097 var fake = [DirectoryModel.fakeDriveEntry_]; |
| 1097 if (this.isDriveMounted()) { | 1098 if (this.isDriveMounted()) { |
| 1098 readSingle(RootDirectory.DRIVE.substring(1), 'drive', fake); | 1099 readSingle(DirectoryModel.fakeDriveEntry_.fullPath, 'drive', fake); |
| 1099 } else { | 1100 } else { |
| 1100 groups.drive = fake; | 1101 groups.drive = fake; |
| 1101 } | 1102 } |
| 1102 // TODO(haruki): Add DirectoryModel.fakeDriveOfflineEntry_ to show the tab. | 1103 // TODO(haruki): Add DirectoryModel.fakeDriveOfflineEntry_ to show the tab. |
| 1103 } else { | 1104 } else { |
| 1104 groups.drive = []; | 1105 groups.drive = []; |
| 1105 } | 1106 } |
| 1106 }; | 1107 }; |
| 1107 | 1108 |
| 1108 /** | 1109 /** |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1177 var onGotDirectory = function(entry) { | 1178 var onGotDirectory = function(entry) { |
| 1178 this.updateRootEntry_(entry); | 1179 this.updateRootEntry_(entry); |
| 1179 var currentDirEntry = this.getCurrentDirEntry(); | 1180 var currentDirEntry = this.getCurrentDirEntry(); |
| 1180 if (currentDirEntry == DirectoryModel.fakeDriveEntry_) { | 1181 if (currentDirEntry == DirectoryModel.fakeDriveEntry_) { |
| 1181 this.changeDirectoryEntrySilent_(entry); | 1182 this.changeDirectoryEntrySilent_(entry); |
| 1182 } else if (currentDirEntry == DirectoryModel.fakeDriveOfflineEntry_) { | 1183 } else if (currentDirEntry == DirectoryModel.fakeDriveOfflineEntry_) { |
| 1183 // Need to update the results for offline available files. | 1184 // Need to update the results for offline available files. |
| 1184 this.getDriveOfflineFiles(''); | 1185 this.getDriveOfflineFiles(''); |
| 1185 } | 1186 } |
| 1186 } | 1187 } |
| 1187 this.root_.getDirectory(RootDirectory.DRIVE, {}, | 1188 this.root_.getDirectory( |
| 1188 onGotDirectory.bind(this)); | 1189 DirectoryModel.fakeDriveEntry_.fullPath, {}, |
| 1190 onGotDirectory.bind(this)); | |
| 1191 // TODO(haruki): support "other" root. | |
| 1189 } else { | 1192 } else { |
| 1190 var rootType = this.getCurrentRootType(); | 1193 var rootType = this.getCurrentRootType(); |
| 1191 if (rootType != RootType.DRIVE && rootType != RootType.DRIVE_OFFLINE) | 1194 if (rootType != RootType.DRIVE && rootType != RootType.DRIVE_OFFLINE) |
| 1192 return; | 1195 return; |
| 1193 | 1196 |
| 1194 // Current entry unmounted. Replace with fake drive one. | 1197 // Current entry unmounted. Replace with fake drive one. |
| 1195 this.updateRootEntry_(DirectoryModel.fakeDriveEntry_); | 1198 this.updateRootEntry_(DirectoryModel.fakeDriveEntry_); |
| 1196 if (this.getCurrentDirPath() == DirectoryModel.fakeDriveEntry_.fullPath) { | 1199 if (this.getCurrentDirPath() == DirectoryModel.fakeDriveEntry_.fullPath) { |
| 1197 // Replace silently and rescan. | 1200 // Replace silently and rescan. |
| 1198 this.changeDirectoryEntrySilent_(DirectoryModel.fakeDriveEntry_); | 1201 this.changeDirectoryEntrySilent_(DirectoryModel.fakeDriveEntry_); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1504 }.bind(this)); | 1507 }.bind(this)); |
| 1505 } | 1508 } |
| 1506 }; | 1509 }; |
| 1507 | 1510 |
| 1508 /** | 1511 /** |
| 1509 * @return {DirectoryEntry} Current watched directory entry. | 1512 * @return {DirectoryEntry} Current watched directory entry. |
| 1510 */ | 1513 */ |
| 1511 FileWatcher.prototype.getWatchedDirectoryEntry = function() { | 1514 FileWatcher.prototype.getWatchedDirectoryEntry = function() { |
| 1512 return this.watchedDirectoryEntry_; | 1515 return this.watchedDirectoryEntry_; |
| 1513 }; | 1516 }; |
| OLD | NEW |