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 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 if (entries.length == 0) { | 1223 if (entries.length == 0) { |
1224 this.successCallback_(); | 1224 this.successCallback_(); |
1225 this.recordMetrics_(); | 1225 this.recordMetrics_(); |
1226 return; | 1226 return; |
1227 } | 1227 } |
1228 | 1228 |
1229 // Splice takes the to-be-spliced-in array as individual parameters, | 1229 // Splice takes the to-be-spliced-in array as individual parameters, |
1230 // rather than as an array, so we need to perform some acrobatics... | 1230 // rather than as an array, so we need to perform some acrobatics... |
1231 var spliceArgs = [].slice.call(entries); | 1231 var spliceArgs = [].slice.call(entries); |
1232 | 1232 |
1233 for (filterName in this.filters_) { | 1233 for (var filterName in this.filters_) { |
1234 spliceArgs = spliceArgs.filter(this.filters_[filterName]); | 1234 spliceArgs = spliceArgs.filter(this.filters_[filterName]); |
1235 } | 1235 } |
1236 | 1236 |
1237 var self = this; | 1237 var self = this; |
1238 self.preprocessChunk_(spliceArgs, function() { | 1238 self.preprocessChunk_(spliceArgs, function() { |
1239 spliceArgs.unshift(0, 0); // index, deleteCount | 1239 spliceArgs.unshift(0, 0); // index, deleteCount |
1240 self.list_.splice.apply(self.list_, spliceArgs); | 1240 self.list_.splice.apply(self.list_, spliceArgs); |
1241 | 1241 |
1242 // Keep reading until entries.length is 0. | 1242 // Keep reading until entries.length is 0. |
1243 self.readNextChunk_(); | 1243 self.readNextChunk_(); |
1244 }); | 1244 }); |
1245 }; | 1245 }; |
1246 | 1246 |
1247 /** | 1247 /** |
1248 * @private | 1248 * @private |
1249 */ | 1249 */ |
1250 DirectoryModel.Scanner.prototype.recordMetrics_ = function() { | 1250 DirectoryModel.Scanner.prototype.recordMetrics_ = function() { |
1251 metrics.recordInterval('DirectoryScan'); | 1251 metrics.recordInterval('DirectoryScan'); |
1252 if (this.dir_.fullPath == | 1252 if (this.dir_.fullPath == |
1253 '/' + DirectoryModel.DOWNLOADS_DIRECTORY) { | 1253 '/' + DirectoryModel.DOWNLOADS_DIRECTORY) { |
1254 metrics.recordMediumCount('DownloadsCount', this.list_.length); | 1254 metrics.recordMediumCount('DownloadsCount', this.list_.length); |
1255 } | 1255 } |
1256 }; | 1256 }; |
OLD | NEW |