Bug 1257667 - Pre: Allow retrieving GeckoApplication's RefWatcher for leak-spotting r=sebastian
authorAndrzej Hunt <andrzej@ahunt.org>
Thu, 17 Mar 2016 13:54:00 -0700
changeset 313252 95c8cb6f15151ddcc575efccabf8de28ad6b7673
parent 313251 dbba8191f3c1e22505f5e5d5b8537f719eafb51d
child 313253 ca8d1e1caeefdcd45bd608adec7a10c3632ceab5
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1257667
milestone48.0a1
Bug 1257667 - Pre: Allow retrieving GeckoApplication's RefWatcher for leak-spotting r=sebastian MozReview-Commit-ID: GmGxDt72ljq
mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
@@ -7,16 +7,17 @@ package org.mozilla.gecko;
 import android.app.Application;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.res.Configuration;
 import android.os.SystemClock;
 import android.util.Log;
 
 import com.squareup.leakcanary.LeakCanary;
+import com.squareup.leakcanary.RefWatcher;
 
 import org.mozilla.gecko.db.BrowserContract;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.LocalBrowserDB;
 import org.mozilla.gecko.dlc.DownloadContentService;
 import org.mozilla.gecko.home.HomePanelsManager;
 import org.mozilla.gecko.lwt.LightweightTheme;
 import org.mozilla.gecko.mdns.MulticastDNSManager;
@@ -33,25 +34,32 @@ public class GeckoApplication extends Ap
 
     private static volatile GeckoApplication instance;
 
     private boolean mInBackground;
     private boolean mPausedGecko;
 
     private LightweightTheme mLightweightTheme;
 
+    private RefWatcher mRefWatcher;
+
     public GeckoApplication() {
         super();
         instance = this;
     }
 
     public static GeckoApplication get() {
         return instance;
     }
 
+    public static RefWatcher getRefWatcher(Context context) {
+        GeckoApplication app = (GeckoApplication) context.getApplicationContext();
+        return app.mRefWatcher;
+    }
+
     @Override
     public Context getContext() {
         return this;
     }
 
     @Override
     public SharedPreferences getSharedPreferences() {
         return GeckoSharedPrefs.forApp(this);
@@ -123,17 +131,17 @@ public class GeckoApplication extends Ap
 
         mInBackground = false;
     }
 
     @Override
     public void onCreate() {
         Log.i(LOG_TAG, "zerdatime " + SystemClock.uptimeMillis() + " - Fennec application start");
 
-        LeakCanary.install(this);
+        mRefWatcher = LeakCanary.install(this);
 
         final Context context = getApplicationContext();
         HardwareUtils.init(context);
         Clipboard.init(context);
         FilePicker.init(context);
         DownloadsIntegration.init();
         HomePanelsManager.getInstance().init(context);