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

Delta Between Two Patch Sets: jni/JniFilterEngine.cpp

Issue 6245218638626816: Issue 1424 - Update libadblockplus-binaries to 6f79af14ad4e (Closed)
Left Patch Set: Created Sept. 22, 2014, 4:44 a.m.
Right Patch Set: Use GetObjectClass instead of FindClass Created Sept. 22, 2014, 1:16 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 | « jni/JniCallbacks.h ('k') | jni/JniUpdateCheckDoneCallback.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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 16 matching lines...) Expand all
27 { 27 {
28 JniAddObjectToList(env, list, NewJniSubscription(env, *it)); 28 JniAddObjectToList(env, list, NewJniSubscription(env, *it));
29 } 29 }
30 30
31 return list; 31 return list;
32 } 32 }
33 33
34 static AdblockPlus::FilterEngine::ContentType ConvertContentType(JNIEnv *env, 34 static AdblockPlus::FilterEngine::ContentType ConvertContentType(JNIEnv *env,
35 jobject jContentType) 35 jobject jContentType)
36 { 36 {
37 jclass enumClass = env->FindClass("java/lang/Enum"); 37 jclass contentTypeClass = env->GetObjectClass(jContentType);
René Jeschke 2014/09/22 12:56:26 Could you please use "env->GetObjectClass(jContent
Felix Dahlke 2014/09/22 13:20:16 Done.
38 jmethodID nameMethod = env->GetMethodID(enumClass, "name", 38 jmethodID nameMethod = env->GetMethodID(contentTypeClass, "name",
René Jeschke 2014/09/22 12:56:26 Is this line break really necessary?
Felix Dahlke 2014/09/22 13:20:16 IMO yes - we have an 80 column rule in C++ code af
René Jeschke 2014/09/22 13:30:06 Ah, right. The Android project can be confusing wh
39 "()Ljava/lang/String;"); 39 "()Ljava/lang/String;");
40 jstring jValue = (jstring) env->CallObjectMethod(jContentType, nameMethod); 40 jstring jValue = (jstring) env->CallObjectMethod(jContentType, nameMethod);
41 const std::string value = JniJavaToStdString(env, jValue); 41 const std::string value = JniJavaToStdString(env, jValue);
42 return AdblockPlus::FilterEngine::StringToContentType(value); 42 return AdblockPlus::FilterEngine::StringToContentType(value);
43 } 43 }
44 44
45 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong enginePtr) 45 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong enginePtr)
46 { 46 {
47 try 47 try
48 { 48 {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 try 164 try
165 { 165 {
166 engine->SetFilterChangeCallback(filterCallback); 166 engine->SetFilterChangeCallback(filterCallback);
167 } 167 }
168 CATCH_AND_THROW(env) 168 CATCH_AND_THROW(env)
169 } 169 }
170 170
171 static void JNICALL JniForceUpdateCheck(JNIEnv* env, jclass clazz, jlong ptr, jl ong updaterPtr) 171 static void JNICALL JniForceUpdateCheck(JNIEnv* env, jclass clazz, jlong ptr, jl ong updaterPtr)
172 { 172 {
173 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr); 173 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr);
174 JniUpdateCheckDoneCallback* callback = 174 JniUpdateCheckDoneCallback* callback =
René Jeschke 2014/09/22 12:56:26 Are those new line breaks really needed? (See also
Felix Dahlke 2014/09/22 13:20:16 IMO yes, see above.
175 JniLongToTypePtr<JniUpdateCheckDoneCallback>(updaterPtr); 175 JniLongToTypePtr<JniUpdateCheckDoneCallback>(updaterPtr);
176 176
177 AdblockPlus::FilterEngine::UpdateCheckDoneCallback 177 AdblockPlus::FilterEngine::UpdateCheckDoneCallback
178 updateCheckDoneCallback = 0; 178 updateCheckDoneCallback = 0;
179 179
180 if (updaterPtr) 180 if (updaterPtr)
181 { 181 {
182 updateCheckDoneCallback = 182 updateCheckDoneCallback =
183 std::tr1::bind(&JniUpdateCheckDoneCallback::Callback, callback, 183 std::tr1::bind(&JniUpdateCheckDoneCallback::Callback, callback,
184 std::tr1::placeholders::_1); 184 std::tr1::placeholders::_1);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "[Ljava/lang/String;)" TYP("Filter"), (void*)JniMatchesMany }, 303 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "[Ljava/lang/String;)" TYP("Filter"), (void*)JniMatchesMany },
304 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref }, 304 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref },
305 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, 305 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref },
306 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } 306 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }
307 }; 307 };
308 308
309 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) 309 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz)
310 { 310 {
311 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 311 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
312 } 312 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld