| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 return; | 317 return; |
| 317 | 318 |
| 318 subscription.filters.splice(oldPosition, 1); | 319 subscription.filters.splice(oldPosition, 1); |
| 319 subscription.filters.splice(newPosition, 0, filter); | 320 subscription.filters.splice(newPosition, 0, filter); |
| 320 FilterNotifier.triggerListeners("filter.moved", filter, subscription, oldPos
ition, newPosition); | 321 FilterNotifier.triggerListeners("filter.moved", filter, subscription, oldPos
ition, newPosition); |
| 321 }, | 322 }, |
| 322 | 323 |
| 323 /** | 324 /** |
| 324 * Increases the hit count for a filter by one | 325 * Increases the hit count for a filter by one |
| 325 * @param {Filter} filter | 326 * @param {Filter} filter |
| 327 * @param {Window} window Window that the match originated in |
| 326 */ | 328 */ |
| 327 increaseHitCount: function(filter) | 329 increaseHitCount: function(filter, wnd) |
| 328 { | 330 { |
| 329 if (!Prefs.savestats || !(filter instanceof ActiveFilter)) | 331 if (!Prefs.savestats || !(filter instanceof ActiveFilter)) |
| 330 return; | 332 return; |
| 331 | 333 |
| 332 filter.hitCount++; | 334 filter.hitCount++; |
| 333 filter.lastHit = Date.now(); | 335 filter.lastHit = Date.now(); |
| 336 if (Prefs.sendstats) |
| 337 { |
| 338 let wndLocation = Utils.getOriginWindow(wnd).location.href; |
| 339 FilterHits.increaseFilterHits(filter, Utils.unwrapURL(wndLocation).host); |
| 340 } |
| 334 }, | 341 }, |
| 335 | 342 |
| 336 /** | 343 /** |
| 337 * Resets hit count for some filters | 344 * Resets hit count for some filters |
| 338 * @param {Filter[]} filters filters to be reset, if null all filters will be
reset | 345 * @param {Filter[]} filters filters to be reset, if null all filters will be
reset |
| 339 */ | 346 */ |
| 340 resetHitCounts: function(filters) | 347 resetHitCounts: function(filters) |
| 341 { | 348 { |
| 342 if (!filters) | 349 if (!filters) |
| 343 { | 350 { |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 Subscription.knownSubscriptions = origKnownSubscriptions; | 798 Subscription.knownSubscriptions = origKnownSubscriptions; |
| 792 } | 799 } |
| 793 | 800 |
| 794 // Allow events to be processed every now and then. | 801 // Allow events to be processed every now and then. |
| 795 // Note: IO.readFromFile() will deal with the potential reentrance here. | 802 // Note: IO.readFromFile() will deal with the potential reentrance here. |
| 796 this.linesProcessed++; | 803 this.linesProcessed++; |
| 797 if (this.linesProcessed % 1000 == 0) | 804 if (this.linesProcessed % 1000 == 0) |
| 798 Utils.yield(); | 805 Utils.yield(); |
| 799 } | 806 } |
| 800 }; | 807 }; |
| OLD | NEW |