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

Side by Side Diff: lib/filterClasses.js

Issue 29935568: Issue 7096 - Make it possible to lazy initialize a filter's subscriptions (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Small update Created Nov. 3, 2018, 9:34 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 | « no previous file | lib/filterListener.js » ('j') | lib/filterStorage.js » ('J')
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 /** 54 /**
55 * Abstract base class for filters 55 * Abstract base class for filters
56 * 56 *
57 * @param {string} text string representation of the filter 57 * @param {string} text string representation of the filter
58 * @constructor 58 * @constructor
59 */ 59 */
60 function Filter(text) 60 function Filter(text)
61 { 61 {
62 this.text = text; 62 this.text = text;
63
64 /**
65 * Subscriptions to which this filter belongs.
66 * @type {(Subscription|Set.<Subscription>)?}
67 * @private
68 */
69 this._subscriptions = null;
70 } 63 }
71 exports.Filter = Filter; 64 exports.Filter = Filter;
72 65
73 Filter.prototype = 66 Filter.prototype =
74 { 67 {
75 /** 68 /**
76 * String representation of the filter 69 * String representation of the filter
77 * @type {string} 70 * @type {string}
78 */ 71 */
79 text: null, 72 text: null,
80 73
81 /** 74 /**
82 * Filter type as a string, e.g. "blocking". 75 * Filter type as a string, e.g. "blocking".
83 * @type {string} 76 * @type {string}
84 */ 77 */
85 get type() 78 get type()
86 { 79 {
87 throw new Error("Please define filter type in the subclass"); 80 throw new Error("Please define filter type in the subclass");
88 }, 81 },
89 82
90 /** 83 /**
84 * Subscriptions to which this filter belongs.
85 * @type {(Subscription|Set.<Subscription>)?}
86 * @private
87 */
88 _subscriptions: null,
89
90 /**
91 * Whether the filter's subscriptions have already been added to the filter.
92 * @type {boolean}
93 * @package
94 */
95 get subscriptionsAdded()
96 {
97 return this.hasOwnProperty("_subscriptions");
98 },
99 set subscriptionsAdded(value)
100 {
101 // Once set to true, the cannot be set back to false even if all
hub 2018/11/10 04:33:21 typo.
102 // subscriptions are removed.
103 if (value)
104 this._subscriptions = this._subscriptions;
hub 2018/11/10 04:33:21 I don't understand what's happening here. This ass
Manish Jethani 2018/11/15 22:58:52 Not really, it sets the property on the this objec
hub 2018/11/16 17:04:39 Acknowledged.
105 },
106
107 /**
91 * Yields subscriptions to which the filter belongs. 108 * Yields subscriptions to which the filter belongs.
92 * @yields {Subscription} 109 * @yields {Subscription}
93 */ 110 */
94 *subscriptions() 111 *subscriptions()
95 { 112 {
96 if (this._subscriptions) 113 if (this._subscriptions)
97 { 114 {
98 if (this._subscriptions instanceof Set) 115 if (this._subscriptions instanceof Set)
99 yield* this._subscriptions; 116 yield* this._subscriptions;
100 else 117 else
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 1370
1354 /** 1371 /**
1355 * Script that should be executed 1372 * Script that should be executed
1356 * @type {string} 1373 * @type {string}
1357 */ 1374 */
1358 get script() 1375 get script()
1359 { 1376 {
1360 return this.body; 1377 return this.body;
1361 } 1378 }
1362 }); 1379 });
OLDNEW
« no previous file with comments | « no previous file | lib/filterListener.js » ('j') | lib/filterStorage.js » ('J')

Powered by Google App Engine
This is Rietveld