Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 11 matching lines...) Expand all Loading... | |
22 Cu.import("resource://gre/modules/Services.jsm"); | 22 Cu.import("resource://gre/modules/Services.jsm"); |
23 Cu.import("resource://gre/modules/FileUtils.jsm"); | 23 Cu.import("resource://gre/modules/FileUtils.jsm"); |
24 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | 24 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
25 | 25 |
26 let {IO} = require("io"); | 26 let {IO} = require("io"); |
27 let {Prefs} = require("prefs"); | 27 let {Prefs} = require("prefs"); |
28 let {Filter, ActiveFilter} = require("filterClasses"); | 28 let {Filter, ActiveFilter} = require("filterClasses"); |
29 let {Subscription, SpecialSubscription, ExternalSubscription} = require("subscri ptionClasses"); | 29 let {Subscription, SpecialSubscription, ExternalSubscription} = require("subscri ptionClasses"); |
30 let {FilterNotifier} = require("filterNotifier"); | 30 let {FilterNotifier} = require("filterNotifier"); |
31 let {Utils} = require("utils"); | 31 let {Utils} = require("utils"); |
32 let {FilterHits} = require("filterHits"); | |
32 | 33 |
33 /** | 34 /** |
34 * Version number of the filter storage file format. | 35 * Version number of the filter storage file format. |
35 * @type Integer | 36 * @type Integer |
36 */ | 37 */ |
37 let formatVersion = 4; | 38 let formatVersion = 4; |
38 | 39 |
39 /** | 40 /** |
40 * This class reads user's filters from disk, manages them in memory and writes them back. | 41 * This class reads user's filters from disk, manages them in memory and writes them back. |
41 * @class | 42 * @class |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 */ | 329 */ |
329 increaseHitCount: function(filter, wnd) | 330 increaseHitCount: function(filter, wnd) |
330 { | 331 { |
331 if (!Prefs.savestats || PrivateBrowsing.enabledForWindow(wnd) || | 332 if (!Prefs.savestats || PrivateBrowsing.enabledForWindow(wnd) || |
332 PrivateBrowsing.enabled || !(filter instanceof ActiveFilter)) | 333 PrivateBrowsing.enabled || !(filter instanceof ActiveFilter)) |
333 { | 334 { |
334 return; | 335 return; |
335 } | 336 } |
336 | 337 |
337 filter.hitCount++; | 338 filter.hitCount++; |
338 filter.lastHit = Date.now(); | 339 filter.lastHit = Date.now(); |
saroyanm
2015/02/17 17:05:51
@Dave here is where we are setting the lastHit for
| |
340 if (Prefs.sendstats) | |
341 FilterHits.increaseFilterHits(filter, wnd); | |
Thomas Greiner
2015/02/23 18:43:05
`FilterNotifier` allows you to listen to the "filt
saroyanm
2015/02/28 15:24:30
I also need the window object where the match has
Thomas Greiner
2015/03/06 11:29:19
Ah, right. We also cannot add it to the `FilterNot
| |
339 }, | 342 }, |
340 | 343 |
341 /** | 344 /** |
342 * Resets hit count for some filters | 345 * Resets hit count for some filters |
343 * @param {Array of Filter} filters filters to be reset, if null all filters will be reset | 346 * @param {Array of Filter} filters filters to be reset, if null all filters will be reset |
344 */ | 347 */ |
345 resetHitCounts: function(filters) | 348 resetHitCounts: function(filters) |
346 { | 349 { |
347 if (!filters) | 350 if (!filters) |
348 { | 351 { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 let filter = Filter.fromText(parser.userFilters[i]); | 439 let filter = Filter.fromText(parser.userFilters[i]); |
437 this.addFilter(filter, null, undefined, true); | 440 this.addFilter(filter, null, undefined, true); |
438 } | 441 } |
439 } | 442 } |
440 | 443 |
441 this._loading = false; | 444 this._loading = false; |
442 FilterNotifier.triggerListeners("load"); | 445 FilterNotifier.triggerListeners("load"); |
443 | 446 |
444 if (sourceFile != this.sourceFile) | 447 if (sourceFile != this.sourceFile) |
445 this.saveToDisk(); | 448 this.saveToDisk(); |
446 | 449 |
450 if (Prefs.sendstats) | |
451 FilterHits.loadFilterHitsFromDatabase(); | |
Thomas Greiner
2015/02/23 18:43:05
`FilterNotifier` allows you to listen to the "load
saroyanm
2015/02/28 15:24:30
Good point, done.
| |
447 }.bind(this); | 452 }.bind(this); |
448 | 453 |
449 let explicitFile; | 454 let explicitFile; |
450 if (sourceFile) | 455 if (sourceFile) |
451 { | 456 { |
452 explicitFile = true; | 457 explicitFile = true; |
453 readFile(sourceFile, 0); | 458 readFile(sourceFile, 0); |
454 } | 459 } |
455 else | 460 else |
456 { | 461 { |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 Subscription.knownSubscriptions = origKnownSubscriptions; | 868 Subscription.knownSubscriptions = origKnownSubscriptions; |
864 } | 869 } |
865 | 870 |
866 // Allow events to be processed every now and then. | 871 // Allow events to be processed every now and then. |
867 // Note: IO.readFromFile() will deal with the potential reentrance here. | 872 // Note: IO.readFromFile() will deal with the potential reentrance here. |
868 this.linesProcessed++; | 873 this.linesProcessed++; |
869 if (this.linesProcessed % 1000 == 0) | 874 if (this.linesProcessed % 1000 == 0) |
870 Utils.yield(); | 875 Utils.yield(); |
871 } | 876 } |
872 }; | 877 }; |
OLD | NEW |