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 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 dirEntry, opt_callback) { | 938 dirEntry, opt_callback) { |
939 // Increment the sequence value. | 939 // Increment the sequence value. |
940 this.changeDirectorySequence_++; | 940 this.changeDirectorySequence_++; |
941 this.clearSearch_(); | 941 this.clearSearch_(); |
942 | 942 |
943 // If there is on-going scan, cancel it. | 943 // If there is on-going scan, cancel it. |
944 if (this.currentDirContents_.isScanning()) | 944 if (this.currentDirContents_.isScanning()) |
945 this.currentDirContents_.cancelScan(); | 945 this.currentDirContents_.cancelScan(); |
946 | 946 |
947 this.directoryChangeQueue_.run(function(sequence, queueTaskCallback) { | 947 this.directoryChangeQueue_.run(function(sequence, queueTaskCallback) { |
948 this.fileWatcher_.changeWatchedDirectory( | 948 this.fileWatcher_.changeWatchedDirectory(dirEntry) |
949 dirEntry, | 949 .then(function() { |
950 function() { | |
951 if (this.changeDirectorySequence_ !== sequence) { | 950 if (this.changeDirectorySequence_ !== sequence) { |
952 queueTaskCallback(); | 951 queueTaskCallback(); |
953 return; | 952 return; |
954 } | 953 } |
955 | 954 |
956 var newDirectoryContents = this.createDirectoryContents_( | 955 var newDirectoryContents = this.createDirectoryContents_( |
957 this.currentFileListContext_, dirEntry, ''); | 956 this.currentFileListContext_, dirEntry, ''); |
958 if (!newDirectoryContents) { | 957 if (!newDirectoryContents) { |
959 queueTaskCallback(); | 958 queueTaskCallback(); |
960 return; | 959 return; |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 if (this.onSearchCompleted_) { | 1312 if (this.onSearchCompleted_) { |
1314 this.removeEventListener('scan-completed', this.onSearchCompleted_); | 1313 this.removeEventListener('scan-completed', this.onSearchCompleted_); |
1315 this.onSearchCompleted_ = null; | 1314 this.onSearchCompleted_ = null; |
1316 } | 1315 } |
1317 | 1316 |
1318 if (this.onClearSearch_) { | 1317 if (this.onClearSearch_) { |
1319 this.onClearSearch_(); | 1318 this.onClearSearch_(); |
1320 this.onClearSearch_ = null; | 1319 this.onClearSearch_ = null; |
1321 } | 1320 } |
1322 }; | 1321 }; |
OLD | NEW |