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

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

Issue 29465626: Noissue - move work with a raw jni pointer to a separate function (Closed) Base URL: github.com:abby-sergz/libadblockplus-android.git
Left Patch Set: Created June 14, 2017, 2:45 p.m.
Right Patch Set: address comment Created July 5, 2017, 1:45 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
« no previous file with change/comment | « no previous file | libadblockplus-android/jni/JniJsEngine.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-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
(...skipping 27 matching lines...) Expand all
38 JniLocalReference<jclass> contentTypeClass(env, 38 JniLocalReference<jclass> contentTypeClass(env,
39 env->GetObjectClass(jContentType)); 39 env->GetObjectClass(jContentType));
40 jmethodID nameMethod = env->GetMethodID(*contentTypeClass, "name", 40 jmethodID nameMethod = env->GetMethodID(*contentTypeClass, "name",
41 "()Ljava/lang/String;"); 41 "()Ljava/lang/String;");
42 JniLocalReference<jstring> jValue(env, 42 JniLocalReference<jstring> jValue(env,
43 (jstring) env->CallObjectMethod(jContentType, nameMethod)); 43 (jstring) env->CallObjectMethod(jContentType, nameMethod));
44 const std::string value = JniJavaToStdString(env, *jValue); 44 const std::string value = JniJavaToStdString(env, *jValue);
45 return AdblockPlus::FilterEngine::StringToContentType(value); 45 return AdblockPlus::FilterEngine::StringToContentType(value);
46 } 46 }
47 47
48 namespace 48 namespace
anton 2017/06/15 05:16:53 can we have the same code style like we use in htt
sergei 2017/06/16 10:44:36 Yes we can but this function is related to JniFilt
49 { 49 {
50 AdblockPlus::FilterEnginePtr& GetFilterEnginePtrRef(jlong ptr) 50 AdblockPlus::FilterEnginePtr& GetFilterEnginePtrRef(jlong ptr)
51 { 51 {
52 return *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr); 52 return *JniLongToTypePtr<AdblockPlus::FilterEnginePtr>(ptr);
53 } 53 }
54 } 54 }
55 55
56 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong jsEnginePtr, jlong isAllowedConnectionCallbackPtr) 56 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong jsEnginePtr, jlong isAllowedConnectionCallbackPtr)
57 { 57 {
58 try 58 try
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 *JniLocalReference<jstring>(env, 358 *JniLocalReference<jstring>(env,
359 static_cast<jstring>( 359 static_cast<jstring>(
360 env->GetObjectArrayElement(jArray, i))))); 360 env->GetObjectArrayElement(jArray, i)))));
361 } 361 }
362 } 362 }
363 } 363 }
364 364
365 static jobject JNICALL JniMatchesMany(JNIEnv* env, jclass clazz, jlong ptr, 365 static jobject JNICALL JniMatchesMany(JNIEnv* env, jclass clazz, jlong ptr,
366 jstring jUrl, jobject jContentType, jobjectArray jDocumentUrls) 366 jstring jUrl, jobject jContentType, jobjectArray jDocumentUrls)
367 { 367 {
368 AdblockPlus::FilterEnginePtr& engine = 368 AdblockPlus::FilterEnginePtr& engine = GetFilterEnginePtrRef(ptr);
jens 2017/07/05 09:27:53 Minor one, but why don't have the definition of en
anton 2017/07/05 09:30:32 yes, i believe previously the line was too long to
sergei 2017/07/05 13:46:20 Right, I guess it's been simply overlooked when I
369 GetFilterEnginePtrRef(ptr);
370 369
371 std::string url = JniJavaToStdString(env, jUrl); 370 std::string url = JniJavaToStdString(env, jUrl);
372 AdblockPlus::FilterEngine::ContentType contentType = 371 AdblockPlus::FilterEngine::ContentType contentType =
373 ConvertContentType(env, jContentType); 372 ConvertContentType(env, jContentType);
374 373
375 std::vector<std::string> documentUrls; 374 std::vector<std::string> documentUrls;
376 JavaStringArrayToStringVector(env, jDocumentUrls, documentUrls); 375 JavaStringArrayToStringVector(env, jDocumentUrls, documentUrls);
377 376
378 try 377 try
379 { 378 {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds Enabled }, 556 { (char*)"setAcceptableAdsEnabled", (char*)"(JZ)V", (void*)JniSetAcceptableAds Enabled },
558 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled }, 557 { (char*)"isAcceptableAdsEnabled", (char*)"(J)Z", (void*)JniIsAcceptableAdsEna bled },
559 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL }, 558 { (char*)"getAcceptableAdsSubscriptionURL", (char*)"(J)Ljava/lang/String;", (v oid*)JniGetAcceptableAdsSubscriptionURL },
560 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } 559 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }
561 }; 560 };
562 561
563 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)
564 { 563 {
565 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 564 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
566 } 565 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld