Bug 614787 - Delay expiration database setup to the first expiration.
authorMarco Bonardo <mbonardo@mozilla.com>
Mon, 29 Nov 2010 21:47:42 +0100
changeset 59363 c952bf835f6bc6416323d1a60b7c54635d2146ab
parent 59362 c5c6f317e9b71b1f476737555ad4f85c188e6156
child 59364 1893bbaa35620e768f99748081337449c8ae7832
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
bugs614787
milestone2.0b8pre
Bug 614787 - Delay expiration database setup to the first expiration. r=dietrich,sdwilsh a=blocking
toolkit/components/places/src/nsPlacesExpiration.js
--- a/toolkit/components/places/src/nsPlacesExpiration.js
+++ b/toolkit/components/places/src/nsPlacesExpiration.js
@@ -403,34 +403,39 @@ const EXPIRATION_QUERIES = {
   }
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsPlacesExpiration definition
 
 function nsPlacesExpiration()
 {
-  this._db = Cc["@mozilla.org/browser/nav-history-service;1"].
+  //////////////////////////////////////////////////////////////////////////////
+  //// Smart Getters
+
+  XPCOMUtils.defineLazyGetter(this, "_db", function () {
+    let db = Cc["@mozilla.org/browser/nav-history-service;1"].
              getService(Ci.nsPIPlacesDatabase).
              DBConnection;
 
-  // Create a temp table for notifications.
-  this._db.executeSimpleSQL(
-    "CREATE TEMP TABLE expiration_notify ( "
-  + "  id INTEGER PRIMARY KEY "
-  + ", v_id INTEGER "
-  + ", p_id INTEGER "
-  + ", url TEXT NOT NULL "
-  + ", visit_date INTEGER "
-  + ", expected_results INTEGER NOT NULL "
-  + ")"
-  );
+    // Create the temporary notifications table.
+    let stmt = db.createAsyncStatement(
+      "CREATE TEMP TABLE expiration_notify ( "
+    + "  id INTEGER PRIMARY KEY "
+    + ", v_id INTEGER "
+    + ", p_id INTEGER "
+    + ", url TEXT NOT NULL "
+    + ", visit_date INTEGER "
+    + ", expected_results INTEGER NOT NULL "
+    + ") ");
+    stmt.executeAsync();
+    stmt.finalize();
 
-  //////////////////////////////////////////////////////////////////////////////
-  //// Smart Getters
+    return db;
+  });
 
   XPCOMUtils.defineLazyServiceGetter(this, "_hsn",
                                      "@mozilla.org/browser/nav-history-service;1",
                                      "nsPIPlacesHistoryListenersNotifier");
   XPCOMUtils.defineLazyServiceGetter(this, "_sys",
                                      "@mozilla.org/system-info;1",
                                      "nsIPropertyBag2");
   XPCOMUtils.defineLazyServiceGetter(this, "_idle",