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

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

Issue 29424615: Issue 4231 - Fix unstable FilterEngineTest.testSetRemoveFilterChangeCallback (Closed)
Patch Set: now using smart_ptr, changed impl for reading file as string, minor changes Created May 22, 2017, 1:03 p.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-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 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<AdblockPlus::FileS ystemPtr>(fileSystemPtr);
146 engine->SetFileSystem(fileSystem);
147 }
148 CATCH_AND_THROW(env)
149 }
150
139 static void JNICALL JniSetDefaultWebRequest(JNIEnv* env, jclass clazz, jlong ptr ) 151 static void JNICALL JniSetDefaultWebRequest(JNIEnv* env, jclass clazz, jlong ptr )
140 { 152 {
141 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr> (ptr); 153 AdblockPlus::JsEnginePtr& engine = *JniLongToTypePtr<AdblockPlus::JsEnginePtr> (ptr);
142 154
143 try 155 try
144 { 156 {
145 AdblockPlus::WebRequestPtr webRequest(new AdblockPlus::DefaultWebRequest()); 157 AdblockPlus::WebRequestPtr webRequest(new AdblockPlus::DefaultWebRequest());
146 158
147 engine->SetWebRequest(webRequest); 159 engine->SetWebRequest(webRequest);
148 } 160 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 { 247 {
236 { (char*)"ctor", (char*)"(" TYP("AppInfo") ")J", (void*)JniCtor }, 248 { (char*)"ctor", (char*)"(" TYP("AppInfo") ")J", (void*)JniCtor },
237 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }, 249 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor },
238 250
239 { (char*)"setEventCallback", (char*)"(JLjava/lang/String;J)V", (void*)JniSetEv entCallback }, 251 { (char*)"setEventCallback", (char*)"(JLjava/lang/String;J)V", (void*)JniSetEv entCallback },
240 { (char*)"removeEventCallback", (char*)"(JLjava/lang/String;)V", (void*)JniRem oveEventCallback }, 252 { (char*)"removeEventCallback", (char*)"(JLjava/lang/String;)V", (void*)JniRem oveEventCallback },
241 { (char*)"triggerEvent", (char*)"(JLjava/lang/String;[J)V", (void*)JniTriggerE vent }, 253 { (char*)"triggerEvent", (char*)"(JLjava/lang/String;[J)V", (void*)JniTriggerE vent },
242 254
243 { (char*)"evaluate", (char*)"(JLjava/lang/String;Ljava/lang/String;)" TYP("JsV alue"), (void*)JniEvaluate }, 255 { (char*)"evaluate", (char*)"(JLjava/lang/String;Ljava/lang/String;)" TYP("JsV alue"), (void*)JniEvaluate },
244 256
257 { (char*)"setFileSystem", (char*)"(JJ)V", (void*)JniSetFileSystem },
245 { (char*)"setDefaultFileSystem", (char*)"(JLjava/lang/String;)V", (void*)JniSe tDefaultFileSystem }, 258 { (char*)"setDefaultFileSystem", (char*)"(JLjava/lang/String;)V", (void*)JniSe tDefaultFileSystem },
246 { (char*)"setLogSystem", (char*)"(JJ)V", (void*)JniSetLogSystem }, 259 { (char*)"setLogSystem", (char*)"(JJ)V", (void*)JniSetLogSystem },
247 { (char*)"setDefaultLogSystem", (char*)"(J)V", (void*)JniSetDefaultLogSystem } , 260 { (char*)"setDefaultLogSystem", (char*)"(J)V", (void*)JniSetDefaultLogSystem } ,
248 { (char*)"setWebRequest", (char*)"(JJ)V", (void*)JniSetWebRequest }, 261 { (char*)"setWebRequest", (char*)"(JJ)V", (void*)JniSetWebRequest },
249 { (char*)"setDefaultWebRequest", (char*)"(J)V", (void*)JniSetDefaultWebRequest }, 262 { (char*)"setDefaultWebRequest", (char*)"(J)V", (void*)JniSetDefaultWebRequest },
250 263
251 { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue }, 264 { (char*)"newValue", (char*)"(JJ)" TYP("JsValue"), (void*)JniNewLongValue },
252 { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue } , 265 { (char*)"newValue", (char*)"(JZ)" TYP("JsValue"), (void*)JniNewBooleanValue } ,
253 { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni NewStringValue } 266 { (char*)"newValue", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)Jni NewStringValue }
254 }; 267 };
255 268
256 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r egisterNatives(JNIEnv *env, jclass clazz) 269 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_JsEngine_r egisterNatives(JNIEnv *env, jclass clazz)
257 { 270 {
258 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 271 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
259 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld