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

Unified Diff: libadblockplus-android/jni/JniFilterEngine.cpp

Issue 29453616: Issue 5286 - Update to use libadblockplus rev. b88d098aeab5 (Closed) Base URL: github.com:abby-sergz/libadblockplus-android.git
Patch Set: Created June 1, 2017, 1:41 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: libadblockplus-android/jni/JniFilterEngine.cpp
diff --git a/libadblockplus-android/jni/JniFilterEngine.cpp b/libadblockplus-android/jni/JniFilterEngine.cpp
index 25a9225af081c12b32ab78ea2864273d449b65b2..9893349247f2d12b0e8023fdd4776e37ba17d312 100644
--- a/libadblockplus-android/jni/JniFilterEngine.cpp
+++ b/libadblockplus-android/jni/JniFilterEngine.cpp
@@ -18,6 +18,7 @@
#include <AdblockPlus.h>
#include "Utils.h"
#include "JniCallbacks.h"
+#include <thread>
static jobject SubscriptionsToArrayList(JNIEnv* env, std::vector<AdblockPlus::Subscription>&& subscriptions)
{
@@ -57,9 +58,17 @@ static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong jsEnginePtr, jlong
JniIsAllowedConnectionTypeCallback* callback =
JniLongToTypePtr<JniIsAllowedConnectionTypeCallback>(isAllowedConnectionCallbackPtr);
- AdblockPlus::FilterEngine::IsConnectionAllowedCallback cppCallback =
- std::bind(&JniIsAllowedConnectionTypeCallback::Callback, callback, std::placeholders::_1);
- creationParameters.isConnectionAllowedCallback = cppCallback;
+ creationParameters.isSubscriptionDowloadAllowedCallback =
+ [callback](const std::string* allowedConnectionTypeArg, const std::function<void(bool)>& doneCallback)
+ {
+ std::shared_ptr<std::string> allowedConnectionType;
+ if (allowedConnectionTypeArg)
anton 2017/06/02 06:55:23 "{" required
sergei 2017/06/02 07:32:43 Done.
+ allowedConnectionType = std::make_shared<std::string>(*allowedConnectionTypeArg);
+ std::thread([callback, allowedConnectionType, doneCallback]
sergei 2017/06/01 14:41:57 Detached thread is still a hack with data race, ba
anton 2017/06/02 06:55:23 "}" required
sergei 2017/06/02 07:32:43 Done.
+ {
+ doneCallback(callback->Callback(allowedConnectionType.get()));
+ }).detach();
+ };
filterEngine = new AdblockPlus::FilterEnginePtr(
AdblockPlus::FilterEngine::Create(jsEngine, creationParameters));

Powered by Google App Engine
This is Rietveld