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

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

Issue 29347315: Issue 4231 - Fix unstable FilterEngineTest.testSetRemoveFilterChangeCallback (Closed)
Patch Set: made helper methods static, fixed 'remove' for fs callback Created Dec. 13, 2016, 9:32 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-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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 AdblockPlus::FileSystemPtr fileSystem(new AdblockPlus::DefaultFileSystem()); 129 AdblockPlus::FileSystemPtr fileSystem(new AdblockPlus::DefaultFileSystem());
130 130
131 std::string basePath = JniJavaToStdString(env, jBasePath); 131 std::string basePath = JniJavaToStdString(env, jBasePath);
132 reinterpret_cast<AdblockPlus::DefaultFileSystem*>(fileSystem.get())->SetBase Path(basePath); 132 reinterpret_cast<AdblockPlus::DefaultFileSystem*>(fileSystem.get())->SetBase Path(basePath);
133 133
134 engine->SetFileSystem(fileSystem); 134 engine->SetFileSystem(fileSystem);
135 } 135 }
136 CATCH_AND_THROW(env) 136 CATCH_AND_THROW(env)
137 } 137 }
138 138
139 static void JNICALL JniSetFileSystem(JNIEnv* env, jclass clazz, jlong ptr, jlong fileSystemPtr)
140 {
141 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr> (ptr);
142
143 try
144 {
145 AdblockPlus::FileSystemPtr fileSystem(JniLongToTypePtr<JniFileSystemCallback >(fileSystemPtr));
146
147 engine->SetFileSystem(fileSystem);
148 }
149 CATCH_AND_THROW(env)
150 }
151
139 static void JNICALL JniSetDefaultWebRequest(JNIEnv* env, jclass clazz, jlong ptr ) 152 static void JNICALL JniSetDefaultWebRequest(JNIEnv* env, jclass clazz, jlong ptr )
140 { 153 {
141 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr> (ptr); 154 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr> (ptr);
142 155
143 try 156 try
144 { 157 {
145 AdblockPlus::WebRequestPtr webRequest(new AdblockPlus::DefaultWebRequest()); 158 AdblockPlus::WebRequestPtr webRequest(new AdblockPlus::DefaultWebRequest());
146 159
147 engine->SetWebRequest(webRequest); 160 engine->SetWebRequest(webRequest);
148 } 161 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 { 248 {
236 { (char*)"ctor", (char*)"(" TYP("AppInfo") ")J", (void*)JniCtor }, 249 { (char*)"ctor", (char*)"(" TYP("AppInfo") ")J", (void*)JniCtor },
237 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }, 250 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor },
238 251
239 { (char*)"setEventCallback", (char*)"(JLjava/lang/String;J)V", (void*)JniSetEv entCallback }, 252 { (char*)"setEventCallback", (char*)"(JLjava/lang/String;J)V", (void*)JniSetEv entCallback },
240 { (char*)"removeEventCallback", (char*)"(JLjava/lang/String;)V", (void*)JniRem oveEventCallback }, 253 { (char*)"removeEventCallback", (char*)"(JLjava/lang/String;)V", (void*)JniRem oveEventCallback },
241 { (char*)"triggerEvent", (char*)"(JLjava/lang/String;[J)V", (void*)JniTriggerE vent }, 254 { (char*)"triggerEvent", (char*)"(JLjava/lang/String;[J)V", (void*)JniTriggerE vent },
242 255
243 { (char*)"evaluate", (char*)"(JLjava/lang/String;Ljava/lang/String;)" TYP("JsV alue"), (void*)JniEvaluate }, 256 { (char*)"evaluate", (char*)"(JLjava/lang/String;Ljava/lang/String;)" TYP("JsV alue"), (void*)JniEvaluate },
244 257
258 { (char*)"setFileSystem", (char*)"(JJ)V", (void*)JniSetFileSystem },
245 { (char*)"setDefaultFileSystem", (char*)"(JLjava/lang/String;)V", (void*)JniSe tDefaultFileSystem }, 259 { (char*)"setDefaultFileSystem", (char*)"(JLjava/lang/String;)V", (void*)JniSe tDefaultFileSystem },
246 { (char*)"setLogSystem", (char*)"(JJ)V", (void*)JniSetLogSystem }, 260 { (char*)"setLogSystem", (char*)"(JJ)V", (void*)JniSetLogSystem },
247 { (char*)"setDefaultLogSystem", (char*)"(J)V", (void*)JniSetDefaultLogSystem } , 261 { (char*)"setDefaultLogSystem", (char*)"(J)V", (void*)JniSetDefaultLogSystem } ,
248 { (char*)"setWebRequest", (char*)"(JJ)V", (void*)JniSetWebRequest }, 262 { (char*)"setWebRequest", (char*)"(JJ)V", (void*)JniSetWebRequest },
249 { (char*)"setDefaultWebRequest", (char*)"(J)V", (void*)JniSetDefaultWebRequest }, 263 { (char*)"setDefaultWebRequest", (char*)"(J)V", (void*)JniSetDefaultWebRequest },
250 264
251 { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue }, 265 { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue },
252 { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue } , 266 { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue } ,
253 { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni NewStringValue } 267 { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni NewStringValue }
254 }; 268 };
255 269
256 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r egisterNatives(JNIEnv *env, jclass clazz) 270 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r egisterNatives(JNIEnv *env, jclass clazz)
257 { 271 {
258 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 272 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
259 } 273 }
OLDNEW

Powered by Google App Engine
This is Rietveld