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 29556626: Issue 5790 - Get ready for integration into Chromium (Closed)
Patch Set: Renamed to getNativePtr() Created Sept. 28, 2017, 9:08 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..4f4929e64574a5ab784cddf685a6db4d9d451dea 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
@@ -239,11 +239,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)
{
+ boolean firstInstance = false;
+
if (referenceCounter.getAndIncrement() == 0)
{
+ firstInstance = true;
+
if (!asynchronous)
{
createAdblock();
@@ -266,15 +271,21 @@ public class AdblockHelper
}).start();
}
}
+ return firstInstance;
}
/**
* Unregister AdblockHelper engine client
+ * @return `true` 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 +301,6 @@ public class AdblockHelper
disposeAdblock();
}
}
+ return lastInstance;
}
}

Powered by Google App Engine
This is Rietveld