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

Unified Diff: src/JsEngine.cpp

Issue 29369479: Issue #4694 - Add mutex protection to JS event handling
Patch Set: Created Dec. 21, 2016, 7:35 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
Index: src/JsEngine.cpp
===================================================================
--- a/src/JsEngine.cpp
+++ b/src/JsEngine.cpp
@@ -114,6 +114,11 @@
// TODO: Move the rest of the global object initializations here
}
+JsEngineInternal& AdblockPlus::JsEngine::Internal()
+{
+ return *static_cast<JsEngineInternal*>(this);
+}
+
/**
* \par Design Notes
* It is technically necessary to construct JsEngine instances *only* within a factory.
@@ -201,21 +206,19 @@
}
void AdblockPlus::JsEngine::SetEventCallback(const std::string& eventName,
- AdblockPlus::JsEngine::EventCallback callback)
+ AdblockPlus::JsEngine::EventCallback callback)
{
- eventCallbacks[eventName] = callback;
+ Internal().eventMan.Set(eventName, callback);
}
void AdblockPlus::JsEngine::RemoveEventCallback(const std::string& eventName)
{
- eventCallbacks.erase(eventName);
+ Internal().eventMan.Remove(eventName);
}
void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName, AdblockPlus::JsValueList& params)
{
- EventMap::iterator it = eventCallbacks.find(eventName);
- if (it != eventCallbacks.end())
- it->second(params);
+ Internal().eventMan.Trigger(eventName, params);
}
void AdblockPlus::JsEngine::Gc()

Powered by Google App Engine
This is Rietveld