Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Unified Diff: content/public/android/java/src/org/chromium/content/common/CleanupReference.java

Issue 2241533002: android: Switch CleanupReference to PhantomReference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/common/CleanupReference.java
diff --git a/content/public/android/java/src/org/chromium/content/common/CleanupReference.java b/content/public/android/java/src/org/chromium/content/common/CleanupReference.java
index 95e61cea2fce437ca57e71da3dc6a13c7c6227c8..6c6fcd7195a2e3f0aa188a879bd0bc213c04dc66 100644
--- a/content/public/android/java/src/org/chromium/content/common/CleanupReference.java
+++ b/content/public/android/java/src/org/chromium/content/common/CleanupReference.java
@@ -12,8 +12,8 @@ import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.TraceEvent;
+import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
-import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.Set;
@@ -25,12 +25,13 @@ import java.util.Set;
* cleaned up in response to java side GC of API objects. (Private/internal
* interfaces should always favor explicit resource releases / destroy()
* protocol for this rather than depend on GC to trigger native cleanup).
- * NOTE this uses WeakReference rather than PhantomReference, to avoid delaying the
- * cleanup processing until after finalizers (if any) have run. In general usage of
- * this class indicates the client does NOT use finalizers anyway (Good), so this should
- * not be a visible difference in practice.
+ *
+ * NOTE Using PhantonReference instead of WeakReference is required for correctness.
+ * WeakReferences are enqueued before finalizers are called, and finalizers can
+ * resurrect the referent object. PhantomReference does delay clean up more compared
+ * to WeakReference.
*/
-public class CleanupReference extends WeakReference<Object> {
+public class CleanupReference extends PhantomReference<Object> {
private static final String TAG = "cr.CleanupReference";
private static final boolean DEBUG = false; // Always check in as false!
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698