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

Side by Side Diff: lib/filterStorage.js

Issue 29336735: Issue 394 - hit statistics tool data collection (core) (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « lib/filterListener.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 = null;
33 try
34 {
35 ({FilterHits} = require("filterHits"));
36 }
37 catch (e) {}
32 38
33 /** 39 /**
34 * Version number of the filter storage file format. 40 * Version number of the filter storage file format.
35 * @type Integer 41 * @type Integer
36 */ 42 */
37 let formatVersion = 4; 43 let formatVersion = 4;
38 44
39 /** 45 /**
40 * 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.
41 * @class 47 * @class
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 return; 322 return;
317 323
318 subscription.filters.splice(oldPosition, 1); 324 subscription.filters.splice(oldPosition, 1);
319 subscription.filters.splice(newPosition, 0, filter); 325 subscription.filters.splice(newPosition, 0, filter);
320 FilterNotifier.triggerListeners("filter.moved", filter, subscription, oldPos ition, newPosition); 326 FilterNotifier.triggerListeners("filter.moved", filter, subscription, oldPos ition, newPosition);
321 }, 327 },
322 328
323 /** 329 /**
324 * Increases the hit count for a filter by one 330 * Increases the hit count for a filter by one
325 * @param {Filter} filter 331 * @param {Filter} filter
332 * @param {String} hostname of top window where the match originated in
326 */ 333 */
327 increaseHitCount: function(filter) 334 increaseHitCount: function(filter, hostname, thirdParty)
328 { 335 {
329 if (!Prefs.savestats || !(filter instanceof ActiveFilter)) 336 if (!Prefs.savestats || !(filter instanceof ActiveFilter))
330 return; 337 return;
331 338
332 filter.hitCount++; 339 filter.hitCount++;
333 filter.lastHit = Date.now(); 340 filter.lastHit = Date.now();
341 if (Prefs.sendstats && FilterHits)
342 FilterHits.increaseFilterHits(filter, hostname, thirdParty);
334 }, 343 },
335 344
336 /** 345 /**
337 * Resets hit count for some filters 346 * Resets hit count for some filters
338 * @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
339 */ 348 */
340 resetHitCounts: function(filters) 349 resetHitCounts: function(filters)
341 { 350 {
342 if (!filters) 351 if (!filters)
343 { 352 {
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 Subscription.knownSubscriptions = origKnownSubscriptions; 800 Subscription.knownSubscriptions = origKnownSubscriptions;
792 } 801 }
793 802
794 // Allow events to be processed every now and then. 803 // Allow events to be processed every now and then.
795 // Note: IO.readFromFile() will deal with the potential reentrance here. 804 // Note: IO.readFromFile() will deal with the potential reentrance here.
796 this.linesProcessed++; 805 this.linesProcessed++;
797 if (this.linesProcessed % 1000 == 0) 806 if (this.linesProcessed % 1000 == 0)
798 Utils.yield(); 807 Utils.yield();
799 } 808 }
800 }; 809 };
OLDNEW
« no previous file with comments | « lib/filterListener.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld