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)); |