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

Unified Diff: src/FilterEngine.cpp

Issue 29410664: Issue 5013 - Use const JsValue and pass reference where applicable (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Fixed comment Created April 13, 2017, 3:45 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/FileSystemJsObject.cpp ('k') | src/GlobalJsObject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FilterEngine.cpp
===================================================================
--- a/src/FilterEngine.cpp
+++ b/src/FilterEngine.cpp
@@ -168,17 +168,17 @@
auto sync = std::make_shared<Sync>();
auto isConnectionAllowedCallback = params.isConnectionAllowedCallback;
if (isConnectionAllowedCallback)
jsEngine->SetIsConnectionAllowedCallback([sync, jsEngine]()->bool
{
sync->Wait();
return jsEngine->IsConnectionAllowed();
});
- jsEngine->SetEventCallback("_init", [jsEngine, filterEngine, onCreated, sync, isConnectionAllowedCallback](const JsValueList& params)
+ jsEngine->SetEventCallback("_init", [jsEngine, filterEngine, onCreated, sync, isConnectionAllowedCallback](const JsConstValueList& params)
{
filterEngine->firstRun = params.size() && params[0]->AsBool();
if (isConnectionAllowedCallback)
{
std::weak_ptr<FilterEngine> weakFilterEngine = filterEngine;
jsEngine->SetIsConnectionAllowedCallback([weakFilterEngine, isConnectionAllowedCallback]()->bool
{
auto filterEngine = weakFilterEngine.lock();
@@ -457,17 +457,17 @@
}
void FilterEngine::RemoveUpdateAvailableCallback()
{
jsEngine->RemoveEventCallback("updateAvailable");
}
void FilterEngine::UpdateAvailable(
- const FilterEngine::UpdateAvailableCallback& callback, const JsValueList& params) const
+ const FilterEngine::UpdateAvailableCallback& callback, const JsConstValueList& params) const
{
if (params.size() >= 1 && !params[0]->IsNull())
callback(params[0]->AsString());
}
void FilterEngine::ForceUpdateCheck(
const FilterEngine::UpdateCheckDoneCallback& callback)
{
@@ -479,17 +479,17 @@
jsEngine->SetEventCallback(eventName, std::bind(&FilterEngine::UpdateCheckDone,
this, eventName, callback, std::placeholders::_1));
params.push_back(jsEngine->NewValue(eventName));
}
func->Call(params);
}
void FilterEngine::UpdateCheckDone(const std::string& eventName,
- const FilterEngine::UpdateCheckDoneCallback& callback, const JsValueList& params)
+ const FilterEngine::UpdateCheckDoneCallback& callback, const JsConstValueList& params)
{
jsEngine->RemoveEventCallback(eventName);
std::string error(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsString() : "");
callback(error);
}
void FilterEngine::SetFilterChangeCallback(const FilterEngine::FilterChangeCallback& callback)
@@ -511,34 +511,34 @@
std::unique_ptr<std::string> FilterEngine::GetAllowedConnectionType() const
{
auto prefValue = GetPref("allowed_connection_type");
if (prefValue->AsString().empty())
return nullptr;
return std::unique_ptr<std::string>(new std::string(prefValue->AsString()));
}
-void FilterEngine::FilterChanged(const FilterEngine::FilterChangeCallback& callback, const JsValueList& params) const
+void FilterEngine::FilterChanged(const FilterEngine::FilterChangeCallback& callback, const JsConstValueList& params) const
{
std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsString() : "");
- JsValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false));
+ JsConstValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false));
callback(action, *item);
}
void FilterEngine::ShowNotification(const ShowNotificationCallback& callback,
- const JsValueList& params) const
+ const JsConstValueList& params) const
{
if (params.size() < 1)
return;
if (!params[0]->IsObject())
{
return;
}
- callback(NotificationPtr(new Notification(std::move(*params[0]))));
+ callback(NotificationPtr(new Notification(params[0]->Clone())));
}
int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) const
{
JsConstValueList params;
params.push_back(jsEngine->NewValue(v1));
params.push_back(jsEngine->NewValue(v2));
« no previous file with comments | « src/FileSystemJsObject.cpp ('k') | src/GlobalJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld