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

Side by Side Diff: lib/filterListener.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 12 matching lines...) Expand all
23 Cu.import("resource://gre/modules/Services.jsm"); 23 Cu.import("resource://gre/modules/Services.jsm");
24 24
25 let {FilterStorage} = require("filterStorage"); 25 let {FilterStorage} = require("filterStorage");
26 let {FilterNotifier} = require("filterNotifier"); 26 let {FilterNotifier} = require("filterNotifier");
27 let {ElemHide} = require("elemHide"); 27 let {ElemHide} = require("elemHide");
28 let {CSSRules} = require("cssRules"); 28 let {CSSRules} = require("cssRules");
29 let {defaultMatcher} = require("matcher"); 29 let {defaultMatcher} = require("matcher");
30 let {ActiveFilter, RegExpFilter, ElemHideBase, CSSPropertyFilter} = 30 let {ActiveFilter, RegExpFilter, ElemHideBase, CSSPropertyFilter} =
31 require("filterClasses"); 31 require("filterClasses");
32 let {Prefs} = require("prefs"); 32 let {Prefs} = require("prefs");
33 let {FilterHits} = require("filterHits");
33 34
34 /** 35 /**
35 * Value of the FilterListener.batchMode property. 36 * Value of the FilterListener.batchMode property.
36 * @type Boolean 37 * @type Boolean
37 */ 38 */
38 let batchMode = false; 39 let batchMode = false;
39 40
40 /** 41 /**
41 * Increases on filter changes, filters will be saved if it exceeds 1. 42 * Increases on filter changes, filters will be saved if it exceeds 1.
42 * @type Integer 43 * @type Integer
(...skipping 26 matching lines...) Expand all
69 * subsequent calls. If the parameter is 0 it forces saving filters if any 70 * subsequent calls. If the parameter is 0 it forces saving filters if any
70 * changes were recorded after the previous save. 71 * changes were recorded after the previous save.
71 */ 72 */
72 setDirty: function(/**Integer*/ factor) 73 setDirty: function(/**Integer*/ factor)
73 { 74 {
74 if (factor == 0 && isDirty > 0) 75 if (factor == 0 && isDirty > 0)
75 isDirty = 1; 76 isDirty = 1;
76 else 77 else
77 isDirty += factor; 78 isDirty += factor;
78 if (isDirty >= 1) 79 if (isDirty >= 1)
80 {
79 FilterStorage.saveToDisk(); 81 FilterStorage.saveToDisk();
82 if (Prefs.sendstats)
83 FilterHits.saveFilterHitsToDatabase();
84 }
80 } 85 }
81 }; 86 };
82 87
83 /** 88 /**
84 * Observer listening to history purge actions. 89 * Observer listening to history purge actions.
85 * @class 90 * @class
86 */ 91 */
87 let HistoryPurgeObserver = 92 let HistoryPurgeObserver =
88 { 93 {
89 observe: function(subject, topic, data) 94 observe: function(subject, topic, data)
90 { 95 {
91 if (topic == "browser:purge-session-history" && Prefs.clearStatsOnHistoryPur ge) 96 if (topic == "browser:purge-session-history" && Prefs.clearStatsOnHistoryPur ge)
92 { 97 {
93 FilterStorage.resetHitCounts(); 98 FilterStorage.resetHitCounts();
99 FilterHits.resetFilterHits();
94 FilterListener.setDirty(0); // Force saving to disk 100 FilterListener.setDirty(0); // Force saving to disk
95 101
96 Prefs.recentReports = []; 102 Prefs.recentReports = [];
97 } 103 }
98 }, 104 },
99 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver]) 105 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver])
100 }; 106 };
101 107
102 /** 108 /**
103 * Initializes filter listener on startup, registers the necessary hooks. 109 * Initializes filter listener on startup, registers the necessary hooks.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 ElemHide.clear(); 284 ElemHide.clear();
279 CSSRules.clear(); 285 CSSRules.clear();
280 for (let subscription of FilterStorage.subscriptions) 286 for (let subscription of FilterStorage.subscriptions)
281 if (!subscription.disabled) 287 if (!subscription.disabled)
282 subscription.filters.forEach(addFilter); 288 subscription.filters.forEach(addFilter);
283 flushElemHide(); 289 flushElemHide();
284 } 290 }
285 else if (action == "save") 291 else if (action == "save")
286 isDirty = 0; 292 isDirty = 0;
287 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld