Bug 1126454 - Load mozglue in PasswordsProvider.onCreate() instead of constructor and install crash handler. r=rnewman, a=sledru
authorJames Willcox <snorp@snorp.net>
Mon, 02 Feb 2015 15:25:22 -0600
changeset 243754 61a56699e22d
parent 243753 e95df19f3b70
child 243755 ca56ab5d9989
push id4464
push userryanvm@gmail.com
push date2015-02-11 16:02 +0000
treeherdermozilla-beta@69a8d311ddd6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, sledru
bugs1126454
milestone36.0
Bug 1126454 - Load mozglue in PasswordsProvider.onCreate() instead of constructor and install crash handler. r=rnewman, a=sledru
mobile/android/base/db/PasswordsProvider.java
mobile/android/base/db/SQLiteBridgeContentProvider.java
--- a/mobile/android/base/db/PasswordsProvider.java
+++ b/mobile/android/base/db/PasswordsProvider.java
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.db;
 
 import java.util.HashMap;
 
+import org.mozilla.gecko.CrashHandler;
 import org.mozilla.gecko.GeckoApp;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.NSSBridge;
 import org.mozilla.gecko.db.BrowserContract.DeletedPasswords;
 import org.mozilla.gecko.db.BrowserContract.Passwords;
 import org.mozilla.gecko.mozglue.GeckoLoader;
 import org.mozilla.gecko.sqlite.MatrixBlobCursor;
@@ -45,16 +46,18 @@ public class PasswordsProvider extends S
     // this should be kept in sync with the version in toolkit/components/passwordmgr/storage-mozStorage.js
     private static final int DB_VERSION = 5;
     private static final String DB_FILENAME = "signons.sqlite";
     private static final String WHERE_GUID_IS_NULL = BrowserContract.DeletedPasswords.GUID + " IS NULL";
     private static final String WHERE_GUID_IS_VALUE = BrowserContract.DeletedPasswords.GUID + " = ?";
 
     private static final String LOG_TAG = "GeckPasswordsProvider";
 
+    private CrashHandler mCrashHandler;
+
     static {
         URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH);
 
         // content://org.mozilla.gecko.providers.browser/passwords/#
         URI_MATCHER.addURI(BrowserContract.PASSWORDS_AUTHORITY, "passwords", PASSWORDS);
 
         PASSWORDS_PROJECTION_MAP = new HashMap<String, String>();
         PASSWORDS_PROJECTION_MAP.put(Passwords.ID, Passwords.ID);
@@ -77,20 +80,36 @@ public class PasswordsProvider extends S
         DELETED_PASSWORDS_PROJECTION_MAP = new HashMap<String, String>();
         DELETED_PASSWORDS_PROJECTION_MAP.put(DeletedPasswords.ID, DeletedPasswords.ID);
         DELETED_PASSWORDS_PROJECTION_MAP.put(DeletedPasswords.GUID, DeletedPasswords.GUID);
         DELETED_PASSWORDS_PROJECTION_MAP.put(DeletedPasswords.TIME_DELETED, DeletedPasswords.TIME_DELETED);
     }
 
     public PasswordsProvider() {
         super(LOG_TAG);
+    }
+
+    @Override
+    public boolean onCreate() {
+        mCrashHandler = CrashHandler.createDefaultCrashHandler(getContext());
 
         // We don't use .loadMozGlue because we're in a different process,
         // and we just want to reuse code rather than use the loader lock etc.
         GeckoLoader.doLoadLibrary(getContext(), "mozglue");
+        return super.onCreate();
+    }
+
+    @Override
+    public void shutdown() {
+        super.shutdown();
+
+        if (mCrashHandler != null) {
+            mCrashHandler.unregister();
+            mCrashHandler = null;
+        }
     }
 
     @Override
     protected String getDBName(){
         return DB_FILENAME;
     }
 
     @Override
--- a/mobile/android/base/db/SQLiteBridgeContentProvider.java
+++ b/mobile/android/base/db/SQLiteBridgeContentProvider.java
@@ -2,16 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.db;
 
 import java.io.File;
 import java.util.HashMap;
 
+import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.GeckoThread;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.mozglue.GeckoLoader;
 import org.mozilla.gecko.sqlite.SQLiteBridge;
 import org.mozilla.gecko.sqlite.SQLiteBridgeException;
 
 import android.content.ContentProvider;
@@ -92,16 +93,20 @@ public abstract class SQLiteBridgeConten
                 if (bridge != null) {
                     try {
                         bridge.close();
                     } catch (Exception ex) { }
                 }
             }
             mDatabasePerProfile = null;
         }
+
+        if (AppConstants.Versions.feature11Plus) {
+            super.shutdown();
+        }
     }
 
     @Override
     public void finalize() {
         shutdown();
     }
 
     /**