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

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

Issue 29426559: Issue 5137 - [emscripten] Added basic filter storage implementation (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Left Patch Set: Addressed comments and linting issues Created Aug. 31, 2017, 11:31 a.m.
Right Patch Set: Fixed bogus assert Created Aug. 31, 2017, 12:44 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
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 ); 111 );
112 return true; 112 return true;
113 } 113 }
114 114
115 bool FilterStorage::MoveSubscription(Subscription* subscription, 115 bool FilterStorage::MoveSubscription(Subscription* subscription,
116 const Subscription* insertBefore) 116 const Subscription* insertBefore)
117 { 117 {
118 assert(subscription, u"Attempt to move a null subscription"_str); 118 assert(subscription, u"Attempt to move a null subscription"_str);
119 119
120 int oldPos = IndexOfSubscription(subscription); 120 int oldPos = IndexOfSubscription(subscription);
121 assert(oldPos >= 0, u"Attempt to move a subscription that is not in the list"_ str);
121 if (oldPos == -1) 122 if (oldPos == -1)
122 {
123 assert(subscription, u"Attempt to move a subscription that is not in the lis t"_str);
124 return false; 123 return false;
125 }
126 124
127 int newPos = -1; 125 int newPos = -1;
128 if (insertBefore) 126 if (insertBefore)
129 newPos = IndexOfSubscription(insertBefore); 127 newPos = IndexOfSubscription(insertBefore);
130 if (newPos == -1) 128 if (newPos == -1)
131 newPos = mSubscriptions.size(); 129 newPos = mSubscriptions.size();
132 130
133 if (newPos > oldPos) 131 if (newPos > oldPos)
134 newPos--; 132 newPos--;
135 133
136 if (newPos == oldPos) 134 if (newPos == oldPos)
137 return false; 135 return false;
138 136
139 mSubscriptions.erase(mSubscriptions.begin() + oldPos); 137 mSubscriptions.erase(mSubscriptions.begin() + oldPos);
140 mSubscriptions.emplace(mSubscriptions.begin() + newPos, subscription); 138 mSubscriptions.emplace(mSubscriptions.begin() + newPos, subscription);
141 139
142 FilterNotifier::SubscriptionChange( 140 FilterNotifier::SubscriptionChange(
143 FilterNotifier::Topic::SUBSCRIPTION_MOVED, 141 FilterNotifier::Topic::SUBSCRIPTION_MOVED,
144 subscription 142 subscription
145 ); 143 );
146 return true; 144 return true;
147 } 145 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld