Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/filterStorage.js

Issue 29336735: Issue 394 - hit statistics tool data collection (core) (Closed)
Left Patch Set: Created Feb. 19, 2016, 5:26 p.m.
Right Patch Set: Use Downloader to send the data to server Created April 6, 2016, 2:55 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/filterListener.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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
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 let FilterHits = null;
Wladimir Palant 2016/02/29 14:40:30 Same here, you cannot expect this module to be pre
saroyanm 2016/03/18 18:24:47 Done.
33 try
34 {
35 ({FilterHits} = require("filterHits"));
36 }
37 catch (e) {}
33 38
34 /** 39 /**
35 * Version number of the filter storage file format. 40 * Version number of the filter storage file format.
36 * @type Integer 41 * @type Integer
37 */ 42 */
38 let formatVersion = 4; 43 let formatVersion = 4;
39 44
40 /** 45 /**
41 * This class reads user's filters from disk, manages them in memory and writes them back. 46 * This class reads user's filters from disk, manages them in memory and writes them back.
42 * @class 47 * @class
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 subscription.filters.splice(oldPosition, 1); 324 subscription.filters.splice(oldPosition, 1);
320 subscription.filters.splice(newPosition, 0, filter); 325 subscription.filters.splice(newPosition, 0, filter);
321 FilterNotifier.triggerListeners("filter.moved", filter, subscription, oldPos ition, newPosition); 326 FilterNotifier.triggerListeners("filter.moved", filter, subscription, oldPos ition, newPosition);
322 }, 327 },
323 328
324 /** 329 /**
325 * Increases the hit count for a filter by one 330 * Increases the hit count for a filter by one
326 * @param {Filter} filter 331 * @param {Filter} filter
327 * @param {String} hostname of top window where the match originated in 332 * @param {String} hostname of top window where the match originated in
328 */ 333 */
329 increaseHitCount: function(filter, hostname) 334 increaseHitCount: function(filter, hostname, thirdParty)
330 { 335 {
331 if (!Prefs.savestats || !(filter instanceof ActiveFilter)) 336 if (!Prefs.savestats || !(filter instanceof ActiveFilter))
332 return; 337 return;
333 338
334 filter.hitCount++; 339 filter.hitCount++;
335 filter.lastHit = Date.now(); 340 filter.lastHit = Date.now();
336 if (Prefs.sendstats) 341 if (Prefs.sendstats && FilterHits)
saroyanm 2016/02/19 18:31:35 Hmm, I think it's make sense to check if the modul
Wladimir Palant 2016/02/29 14:40:31 Currently that module has too much Firefox-specifi
337 FilterHits.increaseFilterHits(filter, hostname); 342 FilterHits.increaseFilterHits(filter, hostname, thirdParty);
338 }, 343 },
339 344
340 /** 345 /**
341 * Resets hit count for some filters 346 * Resets hit count for some filters
342 * @param {Filter[]} filters filters to be reset, if null all filters will be reset 347 * @param {Filter[]} filters filters to be reset, if null all filters will be reset
343 */ 348 */
344 resetHitCounts: function(filters) 349 resetHitCounts: function(filters)
345 { 350 {
346 if (!filters) 351 if (!filters)
347 { 352 {
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 Subscription.knownSubscriptions = origKnownSubscriptions; 800 Subscription.knownSubscriptions = origKnownSubscriptions;
796 } 801 }
797 802
798 // Allow events to be processed every now and then. 803 // Allow events to be processed every now and then.
799 // Note: IO.readFromFile() will deal with the potential reentrance here. 804 // Note: IO.readFromFile() will deal with the potential reentrance here.
800 this.linesProcessed++; 805 this.linesProcessed++;
801 if (this.linesProcessed % 1000 == 0) 806 if (this.linesProcessed % 1000 == 0)
802 Utils.yield(); 807 Utils.yield();
803 } 808 }
804 }; 809 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld