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

Delta Between Two Patch Sets: compiled/storage/FilterStorage.cpp

Issue 29606600: Issue 5146 - Implement DownloadableSubscription parsing in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Improved logic for Process() Created Dec. 5, 2017, 7:16 a.m.
Right Patch Set: Removed Md5sum and associated code Created Aug. 14, 2018, 12:38 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « compiled/storage/FilterStorage.h ('k') | compiled/subscription/DownloadableSubscription.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <vector> 18 #include <vector>
19 19
20 #include "FilterStorage.h" 20 #include "FilterStorage.h"
21 #include "../filter/Filter.h" 21 #include "../filter/Filter.h"
22 #include "../subscription/UserDefinedSubscription.h" 22 #include "../subscription/UserDefinedSubscription.h"
23 #include "../FilterNotifier.h" 23 #include "../FilterNotifier.h"
24
25 ABP_NS_USING
24 26
25 FilterStorage* FilterStorage::mInstance = new FilterStorage(); 27 FilterStorage* FilterStorage::mInstance = new FilterStorage();
26 28
27 FilterStorage::Subscriptions::size_type FilterStorage::GetSubscriptionCount() co nst 29 FilterStorage::Subscriptions::size_type FilterStorage::GetSubscriptionCount() co nst
28 { 30 {
29 return mSubscriptions.size(); 31 return mSubscriptions.size();
30 } 32 }
31 33
32 Subscription* FilterStorage::SubscriptionAt(FilterStorage::Subscriptions::size_t ype index) const 34 Subscription* FilterStorage::SubscriptionAt(FilterStorage::Subscriptions::size_t ype index) const
33 { 35 {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 FilterNotifier::SubscriptionChange( 117 FilterNotifier::SubscriptionChange(
116 FilterNotifier::Topic::SUBSCRIPTION_FILTERS_REPLACED, 118 FilterNotifier::Topic::SUBSCRIPTION_FILTERS_REPLACED,
117 subscription 119 subscription
118 ); 120 );
119 } 121 }
120 122
121 bool FilterStorage::MoveSubscription(Subscription& subscription, 123 bool FilterStorage::MoveSubscription(Subscription& subscription,
122 const Subscription* insertBefore) 124 const Subscription* insertBefore)
123 { 125 {
124 int oldPos = IndexOfSubscription(subscription); 126 int oldPos = IndexOfSubscription(subscription);
125 assert2(oldPos >= 0, u"Attempt to move a subscription that is not in the list" _str); 127 assert2(oldPos >= 0, ABP_TEXT("Attempt to move a subscription that is not in t he list"_str));
126 if (oldPos == -1) 128 if (oldPos == -1)
127 return false; 129 return false;
128 130
129 int newPos = -1; 131 int newPos = -1;
130 if (insertBefore) 132 if (insertBefore)
131 newPos = IndexOfSubscription(*insertBefore); 133 newPos = IndexOfSubscription(*insertBefore);
132 if (newPos == -1) 134 if (newPos == -1)
133 newPos = mSubscriptions.size(); 135 newPos = mSubscriptions.size();
134 136
135 if (newPos > oldPos) 137 if (newPos > oldPos)
136 newPos--; 138 newPos--;
137 139
138 if (newPos == oldPos) 140 if (newPos == oldPos)
139 return false; 141 return false;
140 142
141 mSubscriptions.erase(mSubscriptions.begin() + oldPos); 143 mSubscriptions.erase(mSubscriptions.begin() + oldPos);
142 mSubscriptions.emplace(mSubscriptions.begin() + newPos, &subscription); 144 mSubscriptions.emplace(mSubscriptions.begin() + newPos, &subscription);
143 145
144 FilterNotifier::SubscriptionChange( 146 FilterNotifier::SubscriptionChange(
145 FilterNotifier::Topic::SUBSCRIPTION_MOVED, 147 FilterNotifier::Topic::SUBSCRIPTION_MOVED,
146 subscription 148 subscription
147 ); 149 );
148 return true; 150 return true;
149 } 151 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld