Index: src/JsEngine.cpp |
=================================================================== |
--- a/src/JsEngine.cpp |
+++ b/src/JsEngine.cpp |
@@ -107,17 +107,17 @@ |
std::weak_ptr<JsEngine> weakJsEngine = jsEngine; |
jsEngine->timer->SetTimer(std::chrono::milliseconds(arguments[1]->IntegerValue()), [weakJsEngine, timerTaskIterator] |
{ |
if (auto jsEngine = weakJsEngine.lock()) |
jsEngine->CallTimerTask(timerTaskIterator); |
}); |
} |
-void JsEngine::CallTimerTask(TimerTasks::const_iterator timerTaskIterator) |
+void JsEngine::CallTimerTask(const TimerTasks::const_iterator& timerTaskIterator) |
{ |
const JsContext context(shared_from_this()); |
JsValue callback(shared_from_this(), v8::Local<v8::Value>::New(GetIsolate(), *timerTaskIterator->arguments[0])); |
JsConstValueList callbackArgs; |
for (int i = 2; i < timerTaskIterator->arguments.size(); i++) |
callbackArgs.emplace_back(new JsValue(shared_from_this(), |
v8::Local<v8::Value>::New(GetIsolate(), *timerTaskIterator->arguments[i]))); |
callback.Call(callbackArgs); |
@@ -164,34 +164,34 @@ |
filename); |
CheckTryCatch(tryCatch); |
v8::Local<v8::Value> result = script->Run(); |
CheckTryCatch(tryCatch); |
return JsValuePtr(new JsValue(shared_from_this(), result)); |
} |
void AdblockPlus::JsEngine::SetEventCallback(const std::string& eventName, |
- AdblockPlus::JsEngine::EventCallback callback) |
+ const AdblockPlus::JsEngine::EventCallback& callback) |
{ |
if (!callback) |
{ |
RemoveEventCallback(eventName); |
return; |
} |
std::lock_guard<std::mutex> lock(eventCallbacksMutex); |
eventCallbacks[eventName] = callback; |
} |
void AdblockPlus::JsEngine::RemoveEventCallback(const std::string& eventName) |
{ |
std::lock_guard<std::mutex> lock(eventCallbacksMutex); |
eventCallbacks.erase(eventName); |
} |
-void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName, AdblockPlus::JsValueList& params) |
+void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName, const AdblockPlus::JsValueList& params) |
{ |
EventCallback callback; |
{ |
std::lock_guard<std::mutex> lock(eventCallbacksMutex); |
auto it = eventCallbacks.find(eventName); |
if (it == eventCallbacks.end()) |
return; |
callback = it->second; |
@@ -226,17 +226,17 @@ |
AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewObject() |
{ |
const JsContext context(shared_from_this()); |
return JsValuePtr(new JsValue(shared_from_this(), v8::Object::New())); |
} |
AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewCallback( |
- v8::InvocationCallback callback) |
+ const v8::InvocationCallback& callback) |
{ |
const JsContext context(shared_from_this()); |
// Note: we are leaking this weak pointer, no obvious way to destroy it when |
// it's no longer used |
std::weak_ptr<JsEngine>* data = |
new std::weak_ptr<JsEngine>(shared_from_this()); |
v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(callback, |
@@ -265,30 +265,30 @@ |
return list; |
} |
AdblockPlus::FileSystemPtr AdblockPlus::JsEngine::GetFileSystem() const |
{ |
return fileSystem; |
} |
-void AdblockPlus::JsEngine::SetFileSystem(AdblockPlus::FileSystemPtr val) |
+void AdblockPlus::JsEngine::SetFileSystem(const AdblockPlus::FileSystemPtr& val) |
{ |
if (!val) |
throw std::runtime_error("FileSystem cannot be null"); |
fileSystem = val; |
} |
AdblockPlus::WebRequestPtr AdblockPlus::JsEngine::GetWebRequest() const |
{ |
return webRequest; |
} |
-void AdblockPlus::JsEngine::SetWebRequest(AdblockPlus::WebRequestPtr val) |
+void AdblockPlus::JsEngine::SetWebRequest(const AdblockPlus::WebRequestPtr& val) |
{ |
if (!val) |
throw std::runtime_error("WebRequest cannot be null"); |
webRequest = val; |
} |
void AdblockPlus::JsEngine::SetIsConnectionAllowedCallback(const IsConnectionAllowedCallback& callback) |
@@ -311,25 +311,25 @@ |
return !localCopy || localCopy(); |
} |
AdblockPlus::LogSystemPtr AdblockPlus::JsEngine::GetLogSystem() const |
{ |
return logSystem; |
} |
-void AdblockPlus::JsEngine::SetLogSystem(AdblockPlus::LogSystemPtr val) |
+void AdblockPlus::JsEngine::SetLogSystem(const AdblockPlus::LogSystemPtr& val) |
{ |
if (!val) |
throw std::runtime_error("LogSystem cannot be null"); |
logSystem = val; |
} |
void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, |
- AdblockPlus::JsValuePtr value) |
+ const AdblockPlus::JsValuePtr& value) |
{ |
auto global = GetGlobalObject(); |
if (!global) |
throw std::runtime_error("Global object cannot be null"); |
global->SetProperty(name, value); |
} |