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

Delta Between Two Patch Sets: src/FilterEngine.cpp

Issue 29377570: Issue 4931 - add possibility to not send data depending on connection properties (Closed)
Left Patch Set: address comment Created March 16, 2017, 2:38 p.m.
Right Patch Set: rebase Created March 16, 2017, 4:02 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 | « lib/prefs.js ('k') | src/JsEngine.cpp » ('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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 }; 167 };
168 } 168 }
169 169
170 FilterEngine::FilterEngine(const JsEnginePtr& jsEngine) 170 FilterEngine::FilterEngine(const JsEnginePtr& jsEngine)
171 : jsEngine(jsEngine), firstRun(false), updateCheckId(0) 171 : jsEngine(jsEngine), firstRun(false), updateCheckId(0)
172 { 172 {
173 } 173 }
174 174
175 void FilterEngine::CreateAsync(const JsEnginePtr& jsEngine, 175 void FilterEngine::CreateAsync(const JsEnginePtr& jsEngine,
176 const FilterEngine::OnCreatedCallback& onCreated, 176 const FilterEngine::OnCreatedCallback& onCreated,
177 const FilterEngine::CreateParameters& params) 177 const FilterEngine::CreationParameters& params)
178 { 178 {
179 FilterEnginePtr filterEngine(new FilterEngine(jsEngine)); 179 FilterEnginePtr filterEngine(new FilterEngine(jsEngine));
180 auto sync = std::make_shared<Sync>(); 180 auto sync = std::make_shared<Sync>();
181 auto isConnectionAllowedCallback = params.isConnectionAllowedCallback; 181 auto isConnectionAllowedCallback = params.isConnectionAllowedCallback;
182 if (isConnectionAllowedCallback) 182 if (isConnectionAllowedCallback)
183 jsEngine->SetIsConnectionAllowedCallback([sync, jsEngine]()->bool 183 jsEngine->SetIsConnectionAllowedCallback([sync, jsEngine]()->bool
184 { 184 {
185 sync->Wait(); 185 sync->Wait();
186 return jsEngine->IsConnectionAllowed(); 186 return jsEngine->IsConnectionAllowed();
187 }); 187 });
(...skipping 27 matching lines...) Expand all
215 { 215 {
216 preconfiguredPrefsObject->SetProperty(it->first, it->second); 216 preconfiguredPrefsObject->SetProperty(it->first, it->second);
217 } 217 }
218 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject); 218 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject);
219 // Load adblockplus scripts 219 // Load adblockplus scripts
220 for (int i = 0; !jsSources[i].empty(); i += 2) 220 for (int i = 0; !jsSources[i].empty(); i += 2)
221 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); 221 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]);
222 } 222 }
223 223
224 FilterEnginePtr FilterEngine::Create(const JsEnginePtr& jsEngine, 224 FilterEnginePtr FilterEngine::Create(const JsEnginePtr& jsEngine,
225 const FilterEngine::CreateParameters& params) 225 const FilterEngine::CreationParameters& params)
226 { 226 {
227 FilterEnginePtr retValue; 227 FilterEnginePtr retValue;
228 Sync sync; 228 Sync sync;
229 CreateAsync(jsEngine, [&retValue, &sync](const FilterEnginePtr& filterEngine) 229 CreateAsync(jsEngine, [&retValue, &sync](const FilterEnginePtr& filterEngine)
230 { 230 {
231 retValue = filterEngine; 231 retValue = filterEngine;
232 sync.Set(); 232 sync.Set();
233 }, params); 233 }, params);
234 sync.Wait(); 234 sync.Wait();
235 return retValue; 235 return retValue;
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); 584 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url);
585 if (filter) 585 if (filter)
586 { 586 {
587 return filter; 587 return filter;
588 } 588 }
589 currentUrl = parentUrl; 589 currentUrl = parentUrl;
590 } 590 }
591 while (urlIterator != documentUrls.end()); 591 while (urlIterator != documentUrls.end());
592 return FilterPtr(); 592 return FilterPtr();
593 } 593 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld