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

Unified Diff: libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java

Issue 29556582: Issue 5643 - Make v8::Isolate injectable into JsEngine (Closed)
Patch Set: Created Sept. 26, 2017, 8:54 a.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-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java
diff --git a/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java b/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java
index 41592ace84661ace8e97c007e5a9caec66dc8e37..e97ef2fa7ed53470105469be8613fb3e57538851 100644
--- a/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java
+++ b/libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java
@@ -59,6 +59,7 @@ public class AdblockHelper
private AdblockEngine engine;
private AdblockSettingsStorage storage;
private CountDownLatch engineCreated;
+ private Long v8IsolatePtr;
/*
Simple ARC management for AdblockEngine
@@ -131,6 +132,11 @@ public class AdblockHelper
return this;
}
+ public void useV8Isolate(long ptr)
+ {
+ this.v8IsolatePtr = ptr;
+ }
+
private void createAdblock()
{
ConnectivityManager connectivityManager =
@@ -152,6 +158,11 @@ public class AdblockHelper
.setIsAllowedConnectionCallback(isAllowedConnectionCallback)
.enableElementHiding(true);
+ if (v8IsolatePtr != null)
+ {
+ builder.useV8Isolate(v8IsolatePtr);
+ }
+
// if preloaded subscriptions provided
if (preloadedPreferenceName != null)
{
@@ -239,11 +250,16 @@ public class AdblockHelper
* @param asynchronous If `true` engines will be created in background thread without locking of
* current thread. Use waitForReady() before getEngine() later.
* If `false` locks current thread.
+ * @return if a new instance is allocated
*/
- public synchronized void retain(boolean asynchronous)
+ public synchronized boolean retain(boolean asynchronous)
sergei 2017/09/26 09:44:13 It seems this code and `lastInstance` are not used
anton 2017/09/26 10:55:06 They are related but i will split it into separate
{
+ boolean firstInstance = false;
+
if (referenceCounter.getAndIncrement() == 0)
{
+ firstInstance = true;
+
if (!asynchronous)
{
createAdblock();
@@ -266,15 +282,21 @@ public class AdblockHelper
}).start();
}
}
+ return firstInstance;
}
/**
* Unregister AdblockHelper engine client
+ * @return if the last instance is destroyed
*/
- public synchronized void release()
+ public synchronized boolean release()
{
+ boolean lastInstance = false;
+
if (referenceCounter.decrementAndGet() == 0)
{
+ lastInstance = true;
+
if (engineCreated != null)
{
// retained asynchronously
@@ -290,5 +312,6 @@ public class AdblockHelper
disposeAdblock();
}
}
+ return lastInstance;
}
}
« no previous file with comments | « no previous file | libadblockplus-android/jni/JniFilterEngine.cpp » ('j') | libadblockplus-android/jni/JniFilterEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld