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

Side by Side Diff: lib/filterStorage.js

Issue 6337686776315904: Issue 394 - hit statistics tool data collection (Closed)
Patch Set: Addressed Dave Comments and updated increaseFilterHits parameter Created April 16, 2015, 10:36 a.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') | lib/ui.js » ('j') | 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-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
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
340 if (Prefs.sendstats)
341 {
342 let wndLocation = Utils.getOriginWindow(wnd).location.href;
343 FilterHits.increaseFilterHits(filter, Utils.unwrapURL(wndLocation).host);
344 }
339 }, 345 },
340 346
341 /** 347 /**
342 * Resets hit count for some filters 348 * Resets hit count for some filters
343 * @param {Filter[]} filters filters to be reset, if null all filters will be reset 349 * @param {Filter[]} filters filters to be reset, if null all filters will be reset
344 */ 350 */
345 resetHitCounts: function(filters) 351 resetHitCounts: function(filters)
346 { 352 {
347 if (!filters) 353 if (!filters)
348 { 354 {
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 Subscription.knownSubscriptions = origKnownSubscriptions; 869 Subscription.knownSubscriptions = origKnownSubscriptions;
864 } 870 }
865 871
866 // Allow events to be processed every now and then. 872 // Allow events to be processed every now and then.
867 // Note: IO.readFromFile() will deal with the potential reentrance here. 873 // Note: IO.readFromFile() will deal with the potential reentrance here.
868 this.linesProcessed++; 874 this.linesProcessed++;
869 if (this.linesProcessed % 1000 == 0) 875 if (this.linesProcessed % 1000 == 0)
870 Utils.yield(); 876 Utils.yield();
871 } 877 }
872 }; 878 };
OLDNEW
« no previous file with comments | « lib/filterListener.js ('k') | lib/ui.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld