| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 12 matching lines...) Expand all Loading... |
| 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 {TimeLine} = require("timeline"); | 32 let {TimeLine} = require("timeline"); |
| 33 let {FilterHits} = require("filterHits"); |
| 33 | 34 |
| 34 /** | 35 /** |
| 35 * Version number of the filter storage file format. | 36 * Version number of the filter storage file format. |
| 36 * @type Integer | 37 * @type Integer |
| 37 */ | 38 */ |
| 38 let formatVersion = 4; | 39 let formatVersion = 4; |
| 39 | 40 |
| 40 /** | 41 /** |
| 41 * This class reads user's filters from disk, manages them in memory and writes
them back. | 42 * This class reads user's filters from disk, manages them in memory and writes
them back. |
| 42 * @class | 43 * @class |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 increaseHitCount: function(filter, wnd) | 327 increaseHitCount: function(filter, wnd) |
| 327 { | 328 { |
| 328 if (!Prefs.savestats || PrivateBrowsing.enabledForWindow(wnd) || | 329 if (!Prefs.savestats || PrivateBrowsing.enabledForWindow(wnd) || |
| 329 PrivateBrowsing.enabled || !(filter instanceof ActiveFilter)) | 330 PrivateBrowsing.enabled || !(filter instanceof ActiveFilter)) |
| 330 { | 331 { |
| 331 return; | 332 return; |
| 332 } | 333 } |
| 333 | 334 |
| 334 filter.hitCount++; | 335 filter.hitCount++; |
| 335 filter.lastHit = Date.now(); | 336 filter.lastHit = Date.now(); |
| 337 if (Prefs.sendstats) |
| 338 FilterHits.increaseFilterHits(filter, wnd); |
| 336 }, | 339 }, |
| 337 | 340 |
| 338 /** | 341 /** |
| 339 * Resets hit count for some filters | 342 * Resets hit count for some filters |
| 340 * @param {Array of Filter} filters filters to be reset, if null all filters
will be reset | 343 * @param {Array of Filter} filters filters to be reset, if null all filters
will be reset |
| 341 */ | 344 */ |
| 342 resetHitCounts: function(filters) | 345 resetHitCounts: function(filters) |
| 343 { | 346 { |
| 344 if (!filters) | 347 if (!filters) |
| 345 { | 348 { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 this.addFilter(filter, null, undefined, true); | 444 this.addFilter(filter, null, undefined, true); |
| 442 } | 445 } |
| 443 } | 446 } |
| 444 TimeLine.log("Initializing data done, triggering observers") | 447 TimeLine.log("Initializing data done, triggering observers") |
| 445 | 448 |
| 446 this._loading = false; | 449 this._loading = false; |
| 447 FilterNotifier.triggerListeners("load"); | 450 FilterNotifier.triggerListeners("load"); |
| 448 | 451 |
| 449 if (sourceFile != this.sourceFile) | 452 if (sourceFile != this.sourceFile) |
| 450 this.saveToDisk(); | 453 this.saveToDisk(); |
| 451 | 454 |
| 455 if (Prefs.sendstats) |
| 456 FilterHits.loadFilterHitsFromDisk(); |
| 452 TimeLine.leave("FilterStorage.loadFromDisk() read callback done"); | 457 TimeLine.leave("FilterStorage.loadFromDisk() read callback done"); |
| 453 }.bind(this); | 458 }.bind(this); |
| 454 | 459 |
| 455 let explicitFile; | 460 let explicitFile; |
| 456 if (sourceFile) | 461 if (sourceFile) |
| 457 { | 462 { |
| 458 explicitFile = true; | 463 explicitFile = true; |
| 459 readFile(sourceFile, 0); | 464 readFile(sourceFile, 0); |
| 460 } | 465 } |
| 461 else | 466 else |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 Subscription.knownSubscriptions = origKnownSubscriptions; | 890 Subscription.knownSubscriptions = origKnownSubscriptions; |
| 886 } | 891 } |
| 887 | 892 |
| 888 // Allow events to be processed every now and then. | 893 // Allow events to be processed every now and then. |
| 889 // Note: IO.readFromFile() will deal with the potential reentrance here. | 894 // Note: IO.readFromFile() will deal with the potential reentrance here. |
| 890 this.linesProcessed++; | 895 this.linesProcessed++; |
| 891 if (this.linesProcessed % 1000 == 0) | 896 if (this.linesProcessed % 1000 == 0) |
| 892 Utils.yield(); | 897 Utils.yield(); |
| 893 } | 898 } |
| 894 }; | 899 }; |
| OLD | NEW |