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

Side by Side 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: add missed dependencies Created June 2, 2017, 1:45 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dependencies ('k') | libadblockplus-android/jni/JniJsEngine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <AdblockPlus.h> 18 #include <AdblockPlus.h>
19 #include "Utils.h" 19 #include "Utils.h"
20 #include "JniCallbacks.h" 20 #include "JniCallbacks.h"
21 #include <thread>
21 22
22 static jobject SubscriptionsToArrayList(JNIEnv* env, std::vector<AdblockPlus::Su bscription>&& subscriptions) 23 static jobject SubscriptionsToArrayList(JNIEnv* env, std::vector<AdblockPlus::Su bscription>&& subscriptions)
23 { 24 {
24 jobject list = NewJniArrayList(env); 25 jobject list = NewJniArrayList(env);
25 26
26 for (std::vector<AdblockPlus::Subscription>::iterator it = subscriptions.begin (), end = subscriptions.end(); it != end; it++) 27 for (std::vector<AdblockPlus::Subscription>::iterator it = subscriptions.begin (), end = subscriptions.end(); it != end; it++)
27 { 28 {
28 JniAddObjectToList(env, list, NewJniSubscription(env, std::move(*it))); 29 JniAddObjectToList(env, list, NewJniSubscription(env, std::move(*it)));
29 } 30 }
30 31
(...skipping 19 matching lines...) Expand all
50 { 51 {
51 AdblockPlus::JsEnginePtr& jsEngine = *JniLongToTypePtr<AdblockPlus::JsEngine Ptr>(jsEnginePtr); 52 AdblockPlus::JsEnginePtr& jsEngine = *JniLongToTypePtr<AdblockPlus::JsEngine Ptr>(jsEnginePtr);
52 AdblockPlus::FilterEnginePtr* filterEngine = NULL; 53 AdblockPlus::FilterEnginePtr* filterEngine = NULL;
53 54
54 if (isAllowedConnectionCallbackPtr != 0) 55 if (isAllowedConnectionCallbackPtr != 0)
55 { 56 {
56 AdblockPlus::FilterEngine::CreationParameters creationParameters; 57 AdblockPlus::FilterEngine::CreationParameters creationParameters;
57 JniIsAllowedConnectionTypeCallback* callback = 58 JniIsAllowedConnectionTypeCallback* callback =
58 JniLongToTypePtr<JniIsAllowedConnectionTypeCallback>(isAllowedConnection CallbackPtr); 59 JniLongToTypePtr<JniIsAllowedConnectionTypeCallback>(isAllowedConnection CallbackPtr);
59 60
60 AdblockPlus::FilterEngine::IsConnectionAllowedCallback cppCallback = 61 creationParameters.isSubscriptionDowloadAllowedCallback =
61 std::bind(&JniIsAllowedConnectionTypeCallback::Callback, callback, std:: placeholders::_1); 62 [callback](const std::string* allowedConnectionTypeArg, const std::funct ion<void(bool)>& doneCallback)
62 creationParameters.isConnectionAllowedCallback = cppCallback; 63 {
64 std::shared_ptr<std::string> allowedConnectionType;
65 if (allowedConnectionTypeArg)
66 {
67 allowedConnectionType = std::make_shared<std::string>(*allowedConnecti onTypeArg);
68 }
69 std::thread([callback, allowedConnectionType, doneCallback]
70 {
71 doneCallback(callback->Callback(allowedConnectionType.get()));
72 }).detach();
73 };
63 74
64 filterEngine = new AdblockPlus::FilterEnginePtr( 75 filterEngine = new AdblockPlus::FilterEnginePtr(
65 AdblockPlus::FilterEngine::Create(jsEngine, creationParameters)); 76 AdblockPlus::FilterEngine::Create(jsEngine, creationParameters));
66 } 77 }
67 else 78 else
68 { 79 {
69 filterEngine = new AdblockPlus::FilterEnginePtr( 80 filterEngine = new AdblockPlus::FilterEnginePtr(
70 AdblockPlus::FilterEngine::Create(jsEngine)); 81 AdblockPlus::FilterEngine::Create(jsEngine));
71 } 82 }
72 83
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds Enabled }, 556 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds Enabled },
546 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled }, 557 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled },
547 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL }, 558 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL },
548 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } 559 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }
549 }; 560 };
550 561
551 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) 562 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz)
552 { 563 {
553 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 564 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
554 } 565 }
OLDNEW
« no previous file with comments | « dependencies ('k') | libadblockplus-android/jni/JniJsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld