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

Side by Side Diff: compiled/storage/FilterStorage.cpp

Issue 29606600: Issue 5146 - Implement DownloadableSubscription parsing in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Simplify the logic of Process() Created Dec. 4, 2017, 10:04 a.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 | « compiled/storage/FilterStorage.h ('k') | compiled/subscription/DownloadableSubscription.h » ('j') | 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 subscription.SetListed(false); 102 subscription.SetListed(false);
103 103
104 FilterNotifier::SubscriptionChange( 104 FilterNotifier::SubscriptionChange(
105 FilterNotifier::Topic::SUBSCRIPTION_REMOVED, 105 FilterNotifier::Topic::SUBSCRIPTION_REMOVED,
106 subscription 106 subscription
107 ); 107 );
108 return true; 108 return true;
109 } 109 }
110 110
111 void FilterStorage::ClearSubscriptionFilters(Subscription& subscription)
112 {
113 subscription.ClearFilters();
114
115 FilterNotifier::SubscriptionChange(
116 FilterNotifier::Topic::SUBSCRIPTION_FILTERS_REPLACED,
117 subscription
118 );
119 }
120
111 bool FilterStorage::MoveSubscription(Subscription& subscription, 121 bool FilterStorage::MoveSubscription(Subscription& subscription,
112 const Subscription* insertBefore) 122 const Subscription* insertBefore)
113 { 123 {
114 int oldPos = IndexOfSubscription(subscription); 124 int oldPos = IndexOfSubscription(subscription);
115 assert2(oldPos >= 0, u"Attempt to move a subscription that is not in the list" _str); 125 assert2(oldPos >= 0, u"Attempt to move a subscription that is not in the list" _str);
116 if (oldPos == -1) 126 if (oldPos == -1)
117 return false; 127 return false;
118 128
119 int newPos = -1; 129 int newPos = -1;
120 if (insertBefore) 130 if (insertBefore)
121 newPos = IndexOfSubscription(*insertBefore); 131 newPos = IndexOfSubscription(*insertBefore);
122 if (newPos == -1) 132 if (newPos == -1)
123 newPos = mSubscriptions.size(); 133 newPos = mSubscriptions.size();
124 134
125 if (newPos > oldPos) 135 if (newPos > oldPos)
126 newPos--; 136 newPos--;
127 137
128 if (newPos == oldPos) 138 if (newPos == oldPos)
129 return false; 139 return false;
130 140
131 mSubscriptions.erase(mSubscriptions.begin() + oldPos); 141 mSubscriptions.erase(mSubscriptions.begin() + oldPos);
132 mSubscriptions.emplace(mSubscriptions.begin() + newPos, &subscription); 142 mSubscriptions.emplace(mSubscriptions.begin() + newPos, &subscription);
133 143
134 FilterNotifier::SubscriptionChange( 144 FilterNotifier::SubscriptionChange(
135 FilterNotifier::Topic::SUBSCRIPTION_MOVED, 145 FilterNotifier::Topic::SUBSCRIPTION_MOVED,
136 subscription 146 subscription
137 ); 147 );
138 return true; 148 return true;
139 } 149 }
OLDNEW
« no previous file with comments | « compiled/storage/FilterStorage.h ('k') | compiled/subscription/DownloadableSubscription.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld