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 289478 95c8cb6f15151ddcc575efccabf8de28ad6b7673
parent 289477 dbba8191f3c1e22505f5e5d5b8537f719eafb51d
child 289479 ca8d1e1caeefdcd45bd608adec7a10c3632ceab5
push id30103
push userryanvm@gmail.com
push dateSat, 19 Mar 2016 15:24:26 +0000
treeherdermozilla-central@b3006e4e09af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1257667
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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);