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

Side by Side Diff: lib/filterStorage.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: Created Nov. 3, 2018, 9:19 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
« lib/filterListener.js ('K') | « 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-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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 /** 121 /**
122 * The number of subscriptions in the storage. 122 * The number of subscriptions in the storage.
123 * @type {number} 123 * @type {number}
124 */ 124 */
125 get subscriptionCount() 125 get subscriptionCount()
126 { 126 {
127 return this.knownSubscriptions.size; 127 return this.knownSubscriptions.size;
128 } 128 }
129 129
130 /** 130 /**
131 * Adds any subscriptions to which a filter belongs to the filter.
132 * @param {Filter} filter
133 */
134 addSubscriptionsToFilter(filter)
135 {
136 for (let subscription of this.subscriptions())
137 {
138 if (subscription.filters.indexOf(filter) != -1)
Manish Jethani 2018/11/03 21:31:25 This is super inefficient, but currently it is not
139 filter.addSubscription(subscription);
140 }
141
142 filter.subscriptionsAssigned = true;
143 }
144
145 /**
131 * Finds the filter group that a filter should be added to by default. Will 146 * Finds the filter group that a filter should be added to by default. Will
132 * return <code>null</code> if this group doesn't exist yet. 147 * return <code>null</code> if this group doesn't exist yet.
133 * @param {Filter} filter 148 * @param {Filter} filter
134 * @returns {?SpecialSubscription} 149 * @returns {?SpecialSubscription}
135 */ 150 */
136 getGroupForFilter(filter) 151 getGroupForFilter(filter)
137 { 152 {
138 let generalSubscription = null; 153 let generalSubscription = null;
139 for (let subscription of this.knownSubscriptions.values()) 154 for (let subscription of this.knownSubscriptions.values())
140 { 155 {
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 * disconnected from its filters. 678 * disconnected from its filters.
664 */ 679 */
665 function disconnectSubscriptionFilters(subscription) 680 function disconnectSubscriptionFilters(subscription)
666 { 681 {
667 if (!filterStorage.knownSubscriptions.has(subscription.url)) 682 if (!filterStorage.knownSubscriptions.has(subscription.url))
668 return; 683 return;
669 684
670 for (let filter of subscription.filters) 685 for (let filter of subscription.filters)
671 filter.removeSubscription(subscription); 686 filter.removeSubscription(subscription);
672 } 687 }
OLDNEW
« lib/filterListener.js ('K') | « lib/filterListener.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld