Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 30 matching lines...) Expand all Loading... | |
41 jmethodID nameMethod = env->GetMethodID(*contentTypeClass, "name", | 41 jmethodID nameMethod = env->GetMethodID(*contentTypeClass, "name", |
42 "()Ljava/lang/String;"); | 42 "()Ljava/lang/String;"); |
43 JniLocalReference<jstring> jValue(env, | 43 JniLocalReference<jstring> jValue(env, |
44 (jstring) env->CallObjectMethod(jContentType, nameMethod)); | 44 (jstring) env->CallObjectMethod(jContentType, nameMethod)); |
45 const std::string value = JniJavaToStdString(env, *jValue); | 45 const std::string value = JniJavaToStdString(env, *jValue); |
46 return AdblockPlus::FilterEngine::StringToContentType(value); | 46 return AdblockPlus::FilterEngine::StringToContentType(value); |
47 } | 47 } |
48 | 48 |
49 namespace | 49 namespace |
50 { | 50 { |
51 AdblockPlus::FilterEngine& GetFilterEngineRef(jlong ptr) | 51 AdblockPlus::FilterEngine& GetFilterEngineRef(jlong jniPlatformPtr) |
anton
2017/09/06 06:21:27
rename to `platformPtr`
sergei
2017/09/08 09:45:01
renamed to jniPlatformPtr
| |
52 { | 52 { |
53 return JniLongToTypePtr<JniPlatform>(ptr)->platform->GetFilterEngine(); | 53 return JniLongToTypePtr<JniPlatform>(jniPlatformPtr)->platform->GetFilterEng ine(); |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 static jboolean JNICALL JniIsFirstRun(JNIEnv* env, jclass clazz, jlong ptr) | 57 static jboolean JNICALL JniIsFirstRun(JNIEnv* env, jclass clazz, jlong ptr) |
anton
2017/09/06 06:21:27
i'd suggest to rename all `ptr` to `platformPtr` i
sergei
2017/09/08 09:45:01
I'm not sure that there is a real necessity in it
anton
2017/09/08 10:19:18
i'd prefer it to be renamed as previously it was c
sergei
2017/09/08 12:25:30
I would like to wait for the third opinion here. I
diegocarloslima
2017/09/08 20:42:41
As I could see, the only place where the ptr had a
| |
58 { | 58 { |
59 try | 59 try |
60 { | 60 { |
61 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | 61 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); |
62 | 62 |
63 return engine.IsFirstRun() ? JNI_TRUE : JNI_FALSE; | 63 return engine.IsFirstRun() ? JNI_TRUE : JNI_FALSE; |
64 } | 64 } |
65 CATCH_THROW_AND_RETURN(env, JNI_FALSE); | 65 CATCH_THROW_AND_RETURN(env, JNI_FALSE); |
66 } | 66 } |
67 | 67 |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 { | 474 { |
475 try | 475 try |
476 { | 476 { |
477 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); | 477 AdblockPlus::FilterEngine& engine = GetFilterEngineRef(ptr); |
478 std::string url = engine.GetAAUrl(); | 478 std::string url = engine.GetAAUrl(); |
479 return JniStdStringToJava(env, url); | 479 return JniStdStringToJava(env, url); |
480 } | 480 } |
481 CATCH_THROW_AND_RETURN(env, 0) | 481 CATCH_THROW_AND_RETURN(env, 0) |
482 } | 482 } |
483 | 483 |
484 static void JNICALL JniUpdateFiltersAsync(JNIEnv* env, jclass clazz, jlong ptr, jstring jSubscriptionUrl) | 484 static void JNICALL JniUpdateFiltersAsync(JNIEnv* env, jclass clazz, jlong jniPl atformPtr, jstring jSubscriptionUrl) |
485 { | 485 { |
486 std::string subscriptionUrl = JniJavaToStdString(env, jSubscriptionUrl); | 486 std::string subscriptionUrl = JniJavaToStdString(env, jSubscriptionUrl); |
487 auto jniPlatform = JniLongToTypePtr<JniPlatform>(ptr); | 487 auto jniPlatform = JniLongToTypePtr<JniPlatform>(jniPlatformPtr); |
488 jniPlatform->scheduler([jniPlatform, subscriptionUrl] | 488 jniPlatform->scheduler([jniPlatform, subscriptionUrl] |
489 { | 489 { |
490 auto& filterEngine = jniPlatform->platform->GetFilterEngine(); | 490 auto& filterEngine = jniPlatform->platform->GetFilterEngine(); |
491 for (auto& subscription : filterEngine.GetListedSubscriptions()) | 491 for (auto& subscription : filterEngine.GetListedSubscriptions()) |
492 { | 492 { |
493 if (stringBeginsWith(subscriptionUrl, subscription.GetProperty("url").AsSt ring())) | 493 if (stringBeginsWith(subscriptionUrl, subscription.GetProperty("url").AsSt ring())) |
494 { | 494 { |
495 subscription.UpdateFilters(); | 495 subscription.UpdateFilters(); |
496 return; | 496 return; |
497 } | 497 } |
(...skipping 30 matching lines...) Expand all Loading... | |
528 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds Enabled }, | 528 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds Enabled }, |
529 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled }, | 529 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled }, |
530 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL }, | 530 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL }, |
531 { (char*)"updateFiltersAsync", (char*)"(JLjava/lang/String;)V", (void*)JniUpda teFiltersAsync } | 531 { (char*)"updateFiltersAsync", (char*)"(JLjava/lang/String;)V", (void*)JniUpda teFiltersAsync } |
532 }; | 532 }; |
533 | 533 |
534 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) | 534 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) |
535 { | 535 { |
536 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 536 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
537 } | 537 } |
LEFT | RIGHT |