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

Unified Diff: src/FilterEngine.cpp

Issue 11018003: Filter changed callback (Closed)
Patch Set: Created June 18, 2013, 11:42 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
« libadblockplus.gyp ('K') | « libadblockplus.gyp ('k') | no next file » | 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
@@ -20,6 +20,7 @@
#include <functional>
#include <string>
+#include <AdblockPlus/LogSystem.h>
Andrey Novikov 2013/06/18 11:48:28 Forgot to remove this :(
#include <AdblockPlus.h>
#include "JsContext.h"
#include "Thread.h"
@@ -277,3 +278,23 @@
std::string error(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsString() : "");
callback(error);
}
+
+void FilterEngine::SetFilterChangeCallback(FilterEngine::FilterChangeCallback callback)
+{
+ std::string eventName = "filterChange";
Wladimir Palant 2013/06/18 15:02:15 The event name isn't dynamic, no real point passin
+
+ if (callback == 0)
+ jsEngine->RemoveEventCallback(eventName);
+ else
+ jsEngine->SetEventCallback(eventName, std::tr1::bind(&FilterEngine::FilterChanged,
+ this, eventName, callback, std::tr1::placeholders::_1));
+}
+
+void FilterEngine::FilterChanged(const std::string& eventName, FilterEngine::FilterChangeCallback callback, JsValueList& params)
+{
+ AdblockPlus::LogSystemPtr log = jsEngine->GetLogSystem();
Andrey Novikov 2013/06/18 11:48:28 Forgot to remove this :(
+ std::string url(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsString() : "");
+ std::string status(params.size() >= 2 && !params[1]->IsNull() ? params[1]->AsString() : "");
+ int64_t time(params.size() >= 3 && !params[2]->IsNull() ? params[2]->AsInt() : 0);
+ callback(url, status, time);
+}
« libadblockplus.gyp ('K') | « libadblockplus.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld