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

Delta Between Two Patch Sets: src/FilterEngine.cpp

Issue 29410664: Issue 5013 - Use const JsValue and pass reference where applicable (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Created April 12, 2017, 3:24 p.m.
Right Patch Set: Fixed comment Created April 13, 2017, 3:45 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 | « src/FileSystemJsObject.cpp ('k') | src/GlobalJsObject.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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // Lock the JS engine while we are loading scripts, no timeouts should fire 195 // Lock the JS engine while we are loading scripts, no timeouts should fire
196 // until we are done. 196 // until we are done.
197 const JsContext context(jsEngine); 197 const JsContext context(jsEngine);
198 198
199 // Set the preconfigured prefs 199 // Set the preconfigured prefs
200 JsValuePtr preconfiguredPrefsObject = jsEngine->NewObject(); 200 JsValuePtr preconfiguredPrefsObject = jsEngine->NewObject();
201 for (FilterEngine::Prefs::const_iterator it = params.preconfiguredPrefs.begin( ); 201 for (FilterEngine::Prefs::const_iterator it = params.preconfiguredPrefs.begin( );
202 it != params.preconfiguredPrefs.end(); it++) 202 it != params.preconfiguredPrefs.end(); it++)
203 { 203 {
204 preconfiguredPrefsObject->SetProperty(it->first, *it->second); 204 preconfiguredPrefsObject->SetProperty(it->first, it->second);
205 } 205 }
206 jsEngine->SetGlobalProperty("_preconfiguredPrefs", *preconfiguredPrefsObject); 206 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject);
207 // Load adblockplus scripts 207 // Load adblockplus scripts
208 for (int i = 0; !jsSources[i].empty(); i += 2) 208 for (int i = 0; !jsSources[i].empty(); i += 2)
209 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); 209 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]);
210 } 210 }
211 211
212 FilterEnginePtr FilterEngine::Create(const JsEnginePtr& jsEngine, 212 FilterEnginePtr FilterEngine::Create(const JsEnginePtr& jsEngine,
213 const FilterEngine::CreationParameters& params) 213 const FilterEngine::CreationParameters& params)
214 { 214 {
215 FilterEnginePtr retValue; 215 FilterEnginePtr retValue;
216 Sync sync; 216 Sync sync;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 void FilterEngine::ShowNotification(const ShowNotificationCallback& callback, 526 void FilterEngine::ShowNotification(const ShowNotificationCallback& callback,
527 const JsConstValueList& params) const 527 const JsConstValueList& params) const
528 { 528 {
529 if (params.size() < 1) 529 if (params.size() < 1)
530 return; 530 return;
531 531
532 if (!params[0]->IsObject()) 532 if (!params[0]->IsObject())
533 { 533 {
534 return; 534 return;
535 } 535 }
536 callback(NotificationPtr(new Notification(params[0]->Clone()))); 536 callback(NotificationPtr(new Notification(params[0]->Clone())));
hub 2017/04/12 15:28:20 This is the tricky part. Before that patch we rece
537 } 537 }
538 538
539 539
540 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) const 540 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) const
541 { 541 {
542 JsConstValueList params; 542 JsConstValueList params;
543 params.push_back(jsEngine->NewValue(v1)); 543 params.push_back(jsEngine->NewValue(v1));
544 params.push_back(jsEngine->NewValue(v2)); 544 params.push_back(jsEngine->NewValue(v2));
545 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); 545 JsValuePtr func = jsEngine->Evaluate("API.compareVersions");
546 return func->Call(params).AsInt(); 546 return func->Call(params).AsInt();
(...skipping 27 matching lines...) Expand all
574 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); 574 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url);
575 if (filter) 575 if (filter)
576 { 576 {
577 return filter; 577 return filter;
578 } 578 }
579 currentUrl = parentUrl; 579 currentUrl = parentUrl;
580 } 580 }
581 while (urlIterator != documentUrls.end()); 581 while (urlIterator != documentUrls.end());
582 return FilterPtr(); 582 return FilterPtr();
583 } 583 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld