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

Unified Diff: src/JsEngine.cpp

Issue 10420020: Made sure FilterEngine instances are always initialized (Closed)
Patch Set: Using a generic messaging mechanism Created May 23, 2013, 6:35 a.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/GlobalJsObject.cpp ('k') | test/BaseJsTest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/JsEngine.cpp
===================================================================
--- a/src/JsEngine.cpp
+++ b/src/JsEngine.cpp
@@ -88,16 +88,34 @@ AdblockPlus::JsValuePtr AdblockPlus::JsE
const v8::TryCatch tryCatch;
const v8::Handle<v8::Script> script = CompileScript(source, 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)
+{
+ eventCallbacks[eventName] = callback;
+}
+
+void AdblockPlus::JsEngine::RemoveEventCallback(const std::string& eventName)
+{
+ eventCallbacks.erase(eventName);
+}
+
+void AdblockPlus::JsEngine::TriggerEvent(const std::string& eventName)
+{
+ EventMap::iterator it = eventCallbacks.find(eventName);
+ if (it != eventCallbacks.end())
+ it->second();
+}
+
void AdblockPlus::JsEngine::Gc()
{
while (!v8::V8::IdleNotification());
}
AdblockPlus::JsValuePtr AdblockPlus::JsEngine::NewValue(const std::string& val)
{
const Context context(shared_from_this());
« no previous file with comments | « src/GlobalJsObject.cpp ('k') | test/BaseJsTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld