Bug 748852 - Contacts API: Fix leak, error handling. r=fabrice
authorGregor Wagner <anygregor@gmail.com>
Wed, 25 Apr 2012 18:31:48 -0700
changeset 92463 ebad5dd7dea591f56fca92cc7112818b5af5945b
parent 92462 adc258d17ecbd7f4b17bf5020e338aff967502c9
child 92464 40b1bc1bdba12caa91f0fcac3f53574d7b87ae0a
push id22533
push useremorley@mozilla.com
push dateThu, 26 Apr 2012 12:46:19 +0000
treeherdermozilla-central@811b1ce5f4b2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs748852
milestone15.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 748852 - Contacts API: Fix leak, error handling. r=fabrice
dom/contacts/ContactManager.js
dom/contacts/fallback/ContactDB.jsm
dom/contacts/fallback/ContactService.jsm
--- a/dom/contacts/ContactManager.js
+++ b/dom/contacts/ContactManager.js
@@ -329,18 +329,16 @@ ContactManager.prototype = {
     if (!Services.prefs.getBoolPref("dom.mozContacts.enabled"))
       return null;
 
     this.initHelper(aWindow, ["Contacts:Find:Return:OK", "Contacts:Find:Return:KO",
                      "Contacts:Clear:Return:OK", "Contacts:Clear:Return:KO",
                      "Contact:Save:Return:OK", "Contact:Save:Return:KO",
                      "Contact:Remove:Return:OK", "Contact:Remove:Return:KO"]);
 
-    Services.obs.addObserver(this, "inner-window-destroyed", false);
-
     let principal = aWindow.document.nodePrincipal;
     let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
 
     let perm = principal == secMan.getSystemPrincipal() ? 
                  Ci.nsIPermissionManager.ALLOW_ACTION : 
                  Services.perms.testExactPermission(principal.URI, "webcontacts-manage");
  
     //only pages with perm set can use the contacts
--- a/dom/contacts/fallback/ContactDB.jsm
+++ b/dom/contacts/fallback/ContactDB.jsm
@@ -148,37 +148,20 @@ ContactDB.prototype = {
       let store = txn.objectStore(STORE_NAME);
 
       txn.oncomplete = function (event) {
         debug("Transaction complete. Returning to callback.");
         successCb(txn.result);
       };
 
       txn.onabort = function (event) {
-        debug("Caught error on transaction" + event.target.error.name);
-        switch(event.target.error.name) {
-          case "AbortError":
-          case "ConstraintError":
-          case "DataError":
-          case "SyntaxError":
-          case "InvalidStateError":
-          case "NotFoundError":
-          case "QuotaExceededError":
-          case "ReadOnlyError":
-          case "TimeoutError":
-          case "TransactionInactiveError":
-          case "VersionError":
-          case "UnknownError":
-            failureCb("UnknownError");
-            break;
-          default:
-            debug("Unknown error", event.target.error.name);
-            failureCb("UnknownError");
-            break;
-        }
+        debug("Caught error on transaction");
+        // FIXXMEE: this will work in the future. Bug 748630
+        // failureCb(event.target.error.name);
+        failureCb("UnknownError");
       };
       callback(txn, store);
     }, failureCb);
   },
 
   makeImport: function makeImport(aContact) {
     let contact = {};
     contact.properties = {
--- a/dom/contacts/fallback/ContactService.jsm
+++ b/dom/contacts/fallback/ContactService.jsm
@@ -56,16 +56,17 @@ let DOMContactManager = {
     this._messages.forEach((function(msgName) {
       ppmm.removeMessageListener(msgName, this);
     }).bind(this));
     Services.obs.removeObserver(this, "profile-before-change");
     ppmm = null;
     this._messages = null;
     if (this._db)
       this._db.close();
+    this._db = null;
   },
 
   receiveMessage: function(aMessage) {
     function sortfunction(a, b){
       let x, y;
       if (a.properties[msg.findOptions.sortBy])
         x = a.properties[msg.findOptions.sortBy][0].toLowerCase();
       if (b.properties[msg.findOptions.sortBy])