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 = 500; | 7 var SIMULTANEOUS_RESCAN_INTERVAL = 500; |
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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 this.directoryChangeQueue_ = new AsyncUtil.Queue(); | 38 this.directoryChangeQueue_ = new AsyncUtil.Queue(); |
39 this.rescanAggregator_ = new AsyncUtil.Aggregator( | 39 this.rescanAggregator_ = new AsyncUtil.Aggregator( |
40 this.rescanSoon.bind(this, true), 500); | 40 this.rescanSoon.bind(this, true), 500); |
41 | 41 |
42 this.fileFilter_ = fileFilter; | 42 this.fileFilter_ = fileFilter; |
43 this.fileFilter_.addEventListener('changed', | 43 this.fileFilter_.addEventListener('changed', |
44 this.onFilterChanged_.bind(this)); | 44 this.onFilterChanged_.bind(this)); |
45 | 45 |
46 this.currentFileListContext_ = new FileListContext( | 46 this.currentFileListContext_ = new FileListContext( |
47 fileFilter, metadataCache); | 47 fileFilter, metadataCache, fileSystemMetadata); |
48 this.currentDirContents_ = | 48 this.currentDirContents_ = |
49 DirectoryContents.createForDirectory(this.currentFileListContext_, null); | 49 DirectoryContents.createForDirectory(this.currentFileListContext_, null); |
50 | 50 |
51 this.metadataCache_ = metadataCache; | 51 this.metadataCache_ = metadataCache; |
52 this.fileSystemMetadata_ = fileSystemMetadata; | 52 this.fileSystemMetadata_ = fileSystemMetadata; |
53 | 53 |
54 this.volumeManager_ = volumeManager; | 54 this.volumeManager_ = volumeManager; |
55 this.volumeManager_.volumeInfoList.addEventListener( | 55 this.volumeManager_.volumeInfoList.addEventListener( |
56 'splice', this.onVolumeInfoListUpdated_.bind(this)); | 56 'splice', this.onVolumeInfoListUpdated_.bind(this)); |
57 | 57 |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 | 827 |
828 var dirContents = this.currentDirContents_; | 828 var dirContents = this.currentDirContents_; |
829 var sequence = this.changeDirectorySequence_; | 829 var sequence = this.changeDirectorySequence_; |
830 | 830 |
831 new Promise(entry.getDirectory.bind( | 831 new Promise(entry.getDirectory.bind( |
832 entry, name, {create: true, exclusive: true})). | 832 entry, name, {create: true, exclusive: true})). |
833 | 833 |
834 then(function(newEntry) { | 834 then(function(newEntry) { |
835 // Refresh the cache. | 835 // Refresh the cache. |
836 this.metadataCache_.clear([newEntry], '*'); | 836 this.metadataCache_.clear([newEntry], '*'); |
837 this.fileSystemMetadata_.notifyEntryCreated([newEntry]); | 837 this.fileSystemMetadata_.notifyEntriesCreated([newEntry]); |
838 return new Promise(function(onFulfilled, onRejected) { | 838 return new Promise(function(onFulfilled, onRejected) { |
839 dirContents.prefetchMetadata( | 839 dirContents.prefetchMetadata( |
840 [newEntry], false, onFulfilled.bind(null, newEntry)); | 840 [newEntry], false, onFulfilled.bind(null, newEntry)); |
841 }.bind(this)); | 841 }.bind(this)); |
842 }.bind(this)). | 842 }.bind(this)). |
843 | 843 |
844 then(function(newEntry) { | 844 then(function(newEntry) { |
845 // Do not change anything or call the callback if current | 845 // Do not change anything or call the callback if current |
846 // directory changed. | 846 // directory changed. |
847 if (this.changeDirectorySequence_ !== sequence) { | 847 if (this.changeDirectorySequence_ !== sequence) { |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 if (this.onSearchCompleted_) { | 1200 if (this.onSearchCompleted_) { |
1201 this.removeEventListener('scan-completed', this.onSearchCompleted_); | 1201 this.removeEventListener('scan-completed', this.onSearchCompleted_); |
1202 this.onSearchCompleted_ = null; | 1202 this.onSearchCompleted_ = null; |
1203 } | 1203 } |
1204 | 1204 |
1205 if (this.onClearSearch_) { | 1205 if (this.onClearSearch_) { |
1206 this.onClearSearch_(); | 1206 this.onClearSearch_(); |
1207 this.onClearSearch_ = null; | 1207 this.onClearSearch_ = null; |
1208 } | 1208 } |
1209 }; | 1209 }; |
OLD | NEW |