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: Rebase to changeset: 4095 Created Dec. 15, 2015, 6:09 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
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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {String} hostname of top window where the match originated in
326 */ 328 */
327 increaseHitCount: function(filter) 329 increaseHitCount: function(filter, hostanme)
Wladimir Palant 2016/02/15 12:25:41 Typo: hostname
saroyanm 2016/02/19 17:38:12 Done.
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 FilterHits.increaseFilterHits(filter, hostanme);
334 }, 338 },
335 339
336 /** 340 /**
337 * Resets hit count for some filters 341 * Resets hit count for some filters
338 * @param {Filter[]} filters filters to be reset, if null all filters will be reset 342 * @param {Filter[]} filters filters to be reset, if null all filters will be reset
339 */ 343 */
340 resetHitCounts: function(filters) 344 resetHitCounts: function(filters)
341 { 345 {
342 if (!filters) 346 if (!filters)
343 { 347 {
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 Subscription.knownSubscriptions = origKnownSubscriptions; 795 Subscription.knownSubscriptions = origKnownSubscriptions;
792 } 796 }
793 797
794 // Allow events to be processed every now and then. 798 // Allow events to be processed every now and then.
795 // Note: IO.readFromFile() will deal with the potential reentrance here. 799 // Note: IO.readFromFile() will deal with the potential reentrance here.
796 this.linesProcessed++; 800 this.linesProcessed++;
797 if (this.linesProcessed % 1000 == 0) 801 if (this.linesProcessed % 1000 == 0)
798 Utils.yield(); 802 Utils.yield();
799 } 803 }
800 }; 804 };
OLDNEW

Powered by Google App Engine
This is Rietveld