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

Side by Side Diff: libadblockplus-android/jni/JniFilterEngine.cpp

Issue 29533572: Issue 5556 - Update to use libadblockplus revision hg:566f64c8a2a8 (Closed) Base URL: github.com:abby-sergz/libadblockplus-android.git
Patch Set: Created Sept. 1, 2017, 9:41 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 AdblockPlus::ITimer* timer; 53 AdblockPlus::ITimer* timer;
54 AdblockPlus::FilterEnginePtr filterEngine; 54 AdblockPlus::FilterEnginePtr filterEngine;
55 }; 55 };
56 56
57 AdblockPlus::FilterEngine& GetFilterEngineRef(jlong ptr) 57 AdblockPlus::FilterEngine& GetFilterEngineRef(jlong ptr)
58 { 58 {
59 return *JniLongToTypePtr<JniFilterEngine>(ptr)->filterEngine; 59 return *JniLongToTypePtr<JniFilterEngine>(ptr)->filterEngine;
60 } 60 }
61 } 61 }
62 62
63 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong jniJsEnginePtr, jl ong isAllowedConnectionCallbackPtr) 63 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong jniJsEnginePtr, jo bject jIsSubscriptionDownloadAllowedCallback)
64 { 64 {
65 try 65 try
66 { 66 {
67 auto jniJsEngine = JniLongToTypePtr<JniJsEngine>(jniJsEnginePtr); 67 auto jniJsEngine = JniLongToTypePtr<JniJsEngine>(jniJsEnginePtr);
68 auto jsEngine = jniJsEngine->jsEngine; 68 auto jsEngine = jniJsEngine->jsEngine;
69 auto jniFilterEngine = new JniFilterEngine(); 69 auto jniFilterEngine = new JniFilterEngine();
70 jniFilterEngine->timer = jniJsEngine->timer; 70 jniFilterEngine->timer = jniJsEngine->timer;
71 71
72 if (isAllowedConnectionCallbackPtr != 0) 72 if (jIsSubscriptionDownloadAllowedCallback)
73 { 73 {
74 AdblockPlus::FilterEngine::CreationParameters creationParameters; 74 AdblockPlus::FilterEngine::CreationParameters creationParameters;
75 JniIsAllowedConnectionTypeCallback* callback = 75 auto callback = std::make_shared<JniIsAllowedConnectionTypeCallback>(env, jIsSubscriptionDownloadAllowedCallback);
76 JniLongToTypePtr<JniIsAllowedConnectionTypeCallback>(isAllowedConnection CallbackPtr);
77 76
78 creationParameters.isSubscriptionDownloadAllowedCallback = 77 creationParameters.isSubscriptionDownloadAllowedCallback =
79 [callback](const std::string* allowedConnectionTypeArg, const std::funct ion<void(bool)>& doneCallback) 78 [callback](const std::string* allowedConnectionTypeArg, const std::funct ion<void(bool)>& doneCallback)
80 { 79 {
81 std::shared_ptr<std::string> allowedConnectionType; 80 std::shared_ptr<std::string> allowedConnectionType;
82 if (allowedConnectionTypeArg) 81 if (allowedConnectionTypeArg)
83 { 82 {
84 allowedConnectionType = std::make_shared<std::string>(*allowedConnecti onTypeArg); 83 allowedConnectionType = std::make_shared<std::string>(*allowedConnecti onTypeArg);
85 } 84 }
86 std::thread([callback, allowedConnectionType, doneCallback] 85 std::thread([callback, allowedConnectionType, doneCallback]
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 { 545 {
547 subscription.UpdateFilters(); 546 subscription.UpdateFilters();
548 return; 547 return;
549 } 548 }
550 } 549 }
551 }); 550 });
552 } 551 }
553 552
554 static JNINativeMethod methods[] = 553 static JNINativeMethod methods[] =
555 { 554 {
556 { (char*)"ctor", (char*)"(JJ)J", (void*)JniCtor }, 555 { (char*)"ctor", (char*)"(J" TYP("IsAllowedConnectionCallback") ")J", (void*)J niCtor },
557 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun }, 556 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun },
558 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter }, 557 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter },
559 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters }, 558 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters },
560 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription }, 559 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription },
561 { (char*)"showNextNotification", (char*)"(JLjava/lang/String;)V", (void*)JniSh owNextNotification }, 560 { (char*)"showNextNotification", (char*)"(JLjava/lang/String;)V", (void*)JniSh owNextNotification },
562 { (char*)"setShowNotificationCallback", (char*)"(JJ)V", (void*)JniSetShowNotif icationCallback }, 561 { (char*)"setShowNotificationCallback", (char*)"(JJ)V", (void*)JniSetShowNotif icationCallback },
563 { (char*)"removeShowNotificationCallback", (char*)"(J)V", (void*)JniRemoveShow NotificationCallback }, 562 { (char*)"removeShowNotificationCallback", (char*)"(J)V", (void*)JniRemoveShow NotificationCallback },
564 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions }, 563 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions },
565 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions }, 564 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions },
566 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback }, 565 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback },
(...skipping 15 matching lines...) Expand all
582 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled }, 581 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled },
583 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL }, 582 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL },
584 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }, 583 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor },
585 { (char*)"updateFiltersAsync", (char*)"(JLjava/lang/String;)V", (void*)JniUpda teFiltersAsync } 584 { (char*)"updateFiltersAsync", (char*)"(JLjava/lang/String;)V", (void*)JniUpda teFiltersAsync }
586 }; 585 };
587 586
588 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) 587 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz)
589 { 588 {
590 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 589 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
591 } 590 }
OLDNEW

Powered by Google App Engine
This is Rietveld