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

Unified Diff: libadblockplus-android/jni/JniJsEngine.cpp

Issue 29465639: Issue 5309 - Subscriptions update causes ANR (Closed) Base URL: github.com:abby-sergz/libadblockplus-android.git
Patch Set: @sergz Created June 14, 2017, 2:57 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: libadblockplus-android/jni/JniJsEngine.cpp
diff --git a/libadblockplus-android/jni/JniJsEngine.cpp b/libadblockplus-android/jni/JniJsEngine.cpp
index 5e8daf3903388fd48292b84ac112843e31d03b4c..7bc78faaace27a3ccd8300c8bada1bc6dc787e9b 100644
--- a/libadblockplus-android/jni/JniJsEngine.cpp
+++ b/libadblockplus-android/jni/JniJsEngine.cpp
@@ -18,6 +18,7 @@
#include <AdblockPlus.h>
#include "Utils.h"
#include "JniCallbacks.h"
+#include "JniJsEngine.h"
static void TransformAppInfo(JNIEnv* env, jobject jAppInfo, AdblockPlus::AppInfo& appInfo)
{
@@ -34,7 +35,7 @@ static void TransformAppInfo(JNIEnv* env, jobject jAppInfo, AdblockPlus::AppInfo
static AdblockPlus::JsEnginePtr& GetJsEnginePtrRef(jlong ptr)
{
- return *JniLongToTypePtr<AdblockPlus::JsEnginePtr>(ptr);
+ return JniLongToTypePtr<JniJsEngine>(ptr)->jsEngine;
}
static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jobject jAppInfo)
@@ -45,14 +46,18 @@ static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jobject jAppInfo)
try
{
- return JniPtrToLong(new AdblockPlus::JsEnginePtr(AdblockPlus::JsEngine::New(appInfo)));
+ AdblockPlus::TimerPtr timer = AdblockPlus::CreateDefaultTimer();
+ JniJsEngine* jniJsEngine = new JniJsEngine();
+ jniJsEngine->timer = timer.get();
+ jniJsEngine->jsEngine = AdblockPlus::JsEngine::New(appInfo, std::move(timer));
+ return JniPtrToLong(jniJsEngine);
}
CATCH_THROW_AND_RETURN(env, 0)
}
static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr)
{
- delete JniLongToTypePtr<AdblockPlus::JsEnginePtr>(ptr);
+ delete JniLongToTypePtr<JniJsEngine>(ptr);
}
static void JNICALL JniSetEventCallback(JNIEnv* env, jclass clazz, jlong ptr, jstring jEventName, jlong jCallbackPtr)

Powered by Google App Engine
This is Rietveld