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

Delta Between Two Patch Sets: libadblockplus-android/jni/JniFilterEngine.cpp

Issue 29379647: Issue 4948 - add possibility to not send data depending on connection properties (Closed)
Left Patch Set: removed ->get() to be consistent with JniJsEngine Created March 21, 2017, 8:08 a.m.
Right Patch Set: updated dependency to binaries, updated comment for allowed connection type Created March 30, 2017, 2:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong jsEnginePtr, jlong isAllowedConnectionCallbackPtr) 47 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong jsEnginePtr, jlong isAllowedConnectionCallbackPtr)
48 { 48 {
49 try 49 try
50 { 50 {
51 AdblockPlus::JsEnginePtr& jsEngine = *JniLongToTypePtr<AdblockPlus::JsEngine Ptr>(jsEnginePtr); 51 AdblockPlus::JsEnginePtr& jsEngine = *JniLongToTypePtr<AdblockPlus::JsEngine Ptr>(jsEnginePtr);
52 AdblockPlus::FilterEnginePtr* filterEngine = NULL; 52 AdblockPlus::FilterEnginePtr* filterEngine = NULL;
53 53
54 if (isAllowedConnectionCallbackPtr != 0) 54 if (isAllowedConnectionCallbackPtr != 0)
55 { 55 {
56 AdblockPlus::FilterEngine::CreateParameters createParameters; 56 AdblockPlus::FilterEngine::CreationParameters creationParameters;
57 JniIsAllowedConnectionTypeCallback* callback = 57 JniIsAllowedConnectionTypeCallback* callback =
58 JniLongToTypePtr<JniIsAllowedConnectionTypeCallback>(isAllowedConnection CallbackPtr); 58 JniLongToTypePtr<JniIsAllowedConnectionTypeCallback>(isAllowedConnection CallbackPtr);
59 59
60 AdblockPlus::FilterEngine::IsConnectionAllowedCallback cppCallback = 60 AdblockPlus::FilterEngine::IsConnectionAllowedCallback cppCallback =
61 std::bind(&JniIsAllowedConnectionTypeCallback::Callback, callback, std:: placeholders::_1); 61 std::bind(&JniIsAllowedConnectionTypeCallback::Callback, callback, std:: placeholders::_1);
62 createParameters.isConnectionAllowed = cppCallback; 62 creationParameters.isConnectionAllowedCallback = cppCallback;
63 63
64 filterEngine = new AdblockPlus::FilterEnginePtr( 64 filterEngine = new AdblockPlus::FilterEnginePtr(
65 AdblockPlus::FilterEngine::Create(jsEngine, createParameters)); 65 AdblockPlus::FilterEngine::Create(jsEngine, creationParameters));
66 } 66 }
67 else 67 else
68 { 68 {
69 filterEngine = new AdblockPlus::FilterEnginePtr( 69 filterEngine = new AdblockPlus::FilterEnginePtr(
70 AdblockPlus::FilterEngine::Create(jsEngine)); 70 AdblockPlus::FilterEngine::Create(jsEngine));
71 } 71 }
72 72
73 return JniPtrToLong(filterEngine); 73 return JniPtrToLong(filterEngine);
74 } 74 }
75 CATCH_THROW_AND_RETURN(env, 0) 75 CATCH_THROW_AND_RETURN(env, 0)
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", ( void*)JniGetHostFromURL }, 515 { (char*)"getHostFromURL", (char*)"(JLjava/lang/String;)Ljava/lang/String;", ( void*)JniGetHostFromURL },
516 { (char*)"setAllowedConnectionType", (char*)"(JLjava/lang/String;)V", (void*)J niSetAllowedConnectionType }, 516 { (char*)"setAllowedConnectionType", (char*)"(JLjava/lang/String;)V", (void*)J niSetAllowedConnectionType },
517 { (char*)"getAllowedConnectionType", (char*)"(J)Ljava/lang/String;", (void*)Jn iGetAllowedConnectionType }, 517 { (char*)"getAllowedConnectionType", (char*)"(J)Ljava/lang/String;", (void*)Jn iGetAllowedConnectionType },
518 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } 518 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }
519 }; 519 };
520 520
521 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) 521 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz)
522 { 522 {
523 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 523 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
524 } 524 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld