[mq]: backout-bug-463471
authorDietrich Ayala <dietrich@mozilla.com>
Wed, 12 Nov 2008 23:50:19 -0800
changeset 21606 925fe560ecce86f5d60f8936c27b5a2c0a6198b0
parent 21605 5ff478afc3f4f6b369fd393541f5728656ec363a
child 21607 0f40aa039d2b7c07a5c80800c9d4faac23cebf85
push idunknown
push userunknown
push dateunknown
bugs463471
milestone1.9.1b2pre
[mq]: backout-bug-463471
toolkit/components/places/public/nsPIPlacesDatabase.idl
toolkit/components/places/src/nsAnnotationService.cpp
toolkit/components/places/src/nsAnnotationService.h
toolkit/components/places/src/nsFaviconService.cpp
toolkit/components/places/src/nsFaviconService.h
toolkit/components/places/src/nsNavBookmarks.cpp
toolkit/components/places/src/nsNavBookmarks.h
toolkit/components/places/src/nsNavHistory.cpp
toolkit/components/places/src/nsNavHistory.h
toolkit/components/places/src/nsNavHistoryExpire.cpp
toolkit/components/places/src/nsNavHistoryResult.cpp
toolkit/components/places/src/nsPlacesDBFlush.js
toolkit/components/places/tests/sync/head_sync.js
--- a/toolkit/components/places/public/nsPIPlacesDatabase.idl
+++ b/toolkit/components/places/public/nsPIPlacesDatabase.idl
@@ -41,22 +41,16 @@
 
 interface mozIStorageConnection;
 
 /**
  * This is a private interface used by Places components to get access to the
  * database.  If outside consumers wish to use this, they should only read from
  * the database so they do not break any internal invariants.
  */
-[scriptable, uuid(8e6d4f8a-4b8e-4026-9fca-517c4494ddb7)]
+[scriptable, uuid(daa7d3ba-8e24-4228-93b5-2c188bad7d36)]
 interface nsPIPlacesDatabase : nsISupports
 {
   /**
    * The database connection used by Places.
    */
   readonly attribute mozIStorageConnection DBConnection;
-
-  /**
-   * Finalizes all Places internal statements, allowing to safely close the
-   * database connection.
-   */
-  void finalizeInternalStatements();
 };
--- a/toolkit/components/places/src/nsAnnotationService.cpp
+++ b/toolkit/components/places/src/nsAnnotationService.cpp
@@ -2002,27 +2002,8 @@ nsAnnotationService::CallSetForPageObser
 // nsAnnotationService::CallSetForItemObservers
 
 void
 nsAnnotationService::CallSetForItemObservers(PRInt64 aItemId, const nsACString& aName)
 {
   for (PRInt32 i = 0; i < mObservers.Count(); i ++)
     mObservers[i]->OnItemAnnotationSet(aItemId, aName);
 }
-
-void
-nsAnnotationService::FinalizeStatements() {
-    mDBSetAnnotation = nsnull;
-    mDBSetItemAnnotation = nsnull;
-    mDBGetAnnotation = nsnull;
-    mDBGetItemAnnotation = nsnull;
-    mDBGetAnnotationNames = nsnull;
-    mDBGetItemAnnotationNames = nsnull;
-    mDBGetAnnotationFromURI = nsnull;
-    mDBGetAnnotationFromItemId = nsnull;
-    mDBGetAnnotationNameID = nsnull;
-    mDBAddAnnotationName = nsnull;
-    mDBAddAnnotation = nsnull;
-    mDBAddItemAnnotation = nsnull;
-    mDBRemoveAnnotation = nsnull;
-    mDBRemoveItemAnnotation = nsnull;
-    mDBGetItemsWithAnnotation = nsnull;
-}
--- a/toolkit/components/places/src/nsAnnotationService.h
+++ b/toolkit/components/places/src/nsAnnotationService.h
@@ -73,21 +73,16 @@ public:
       // something is wrong.
       NS_ASSERTION(gAnnotationService, "Annotation service creation failed");
     }
     // the service manager will keep the pointer to our service around, so
     // this should always be valid even if nobody currently has a reference.
     return gAnnotationService;
   }
 
-  /**
-   * Finalize all internal statements.
-   */
-  void FinalizeStatements();
-
   NS_DECL_ISUPPORTS
   NS_DECL_NSIANNOTATIONSERVICE
 
 private:
   ~nsAnnotationService();
 
 protected:
   nsCOMPtr<mozIStorageService> mDBService;
--- a/toolkit/components/places/src/nsFaviconService.cpp
+++ b/toolkit/components/places/src/nsFaviconService.cpp
@@ -1006,25 +1006,16 @@ nsFaviconService::OptimizeFaviconImage(c
 
   // Read the stream into a new buffer.
   rv = NS_ConsumeStream(iconStream, PR_UINT32_MAX, aNewData);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
-void
-nsFaviconService::FinalizeStatements() {
-  mDBGetURL = nsnull;
-  mDBGetData = nsnull;
-  mDBGetIconInfo = nsnull;
-  mDBInsertIcon = nsnull;
-  mDBUpdateIcon = nsnull;
-  mDBSetPageFavicon = nsnull;
-}
 
 NS_IMPL_ISUPPORTS4(FaviconLoadListener,
                    nsIRequestObserver,
                    nsIStreamListener,
                    nsIInterfaceRequestor,
                    nsIChannelEventSink)
 
 // FaviconLoadListener::FaviconLoadListener
--- a/toolkit/components/places/src/nsFaviconService.h
+++ b/toolkit/components/places/src/nsFaviconService.h
@@ -85,25 +85,20 @@ public:
 
   // addition to API for strings to prevent excessive parsing of URIs
   nsresult GetFaviconLinkForIconString(const nsCString& aIcon, nsIURI** aOutput);
   void GetFaviconSpecForIconString(const nsCString& aIcon, nsACString& aOutput);
 
   static nsresult OptimizeFaviconImage(const PRUint8* aData, PRUint32 aDataLen,
                                        const nsACString& aMimeType,
                                        nsACString& aNewData, nsACString& aNewMimeType);
-
-  /**
-   * Finalize all internal statements.
-   */
-  void FinalizeStatements();
-
   NS_DECL_ISUPPORTS
   NS_DECL_NSIFAVICONSERVICE
 
+
 private:
   ~nsFaviconService();
 
   nsCOMPtr<mozIStorageConnection> mDBConn; // from history service
 
   nsCOMPtr<mozIStorageStatement> mDBGetURL; // returns URL, data len given page
   nsCOMPtr<mozIStorageStatement> mDBGetData; // returns actual data given URL
   nsCOMPtr<mozIStorageStatement> mDBGetIconInfo;
--- a/toolkit/components/places/src/nsNavBookmarks.cpp
+++ b/toolkit/components/places/src/nsNavBookmarks.cpp
@@ -427,36 +427,16 @@ nsNavBookmarks::InitStatements()
       "WHERE k.keyword = ?1 "
         "AND h.id NOT IN (SELECT id FROM moz_places_temp)"),
     getter_AddRefs(mDBGetURIForKeyword));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
-void
-nsNavBookmarks::FinalizeStatements() {
-  mDBGetChildren = nsnull;
-  mDBFindURIBookmarks = nsnull;
-  mDBFolderCount = nsnull;
-  mDBGetItemIndex = nsnull;
-  mDBGetChildAt = nsnull;
-  mDBGetItemProperties = nsnull;
-  mDBGetItemIdForGUID = nsnull;
-  mDBGetRedirectDestinations = nsnull;
-  mDBInsertBookmark = nsnull;
-  mDBIsBookmarkedInDatabase = nsnull;
-  mDBGetLastBookmarkID = nsnull;
-  mDBSetItemDateAdded = nsnull;
-  mDBSetItemLastModified = nsnull;
-  mDBSetItemIndex = nsnull;
-  mDBGetKeywordForURI = nsnull;
-  mDBGetKeywordForBookmark = nsnull;
-  mDBGetURIForKeyword = nsnull;
-}
 
 // nsNavBookmarks::InitRoots
 //
 //    This locates and creates if necessary the root items in the bookmarks
 //    folder hierarchy. These items are stored in a special roots table that
 //    maps short predefined names to folder IDs.
 //
 //    Normally, these folders will exist already and we will save their IDs
--- a/toolkit/components/places/src/nsNavBookmarks.h
+++ b/toolkit/components/places/src/nsNavBookmarks.h
@@ -99,21 +99,16 @@ public:
   // Called by History service when quitting.
   nsresult OnQuit();
 
   nsresult BeginUpdateBatch();
   nsresult EndUpdateBatch();
 
   PRBool ItemExists(PRInt64 aItemId);
 
-  /**
-   * Finalize all internal statements.
-   */
-  void FinalizeStatements();
-
 private:
   static nsNavBookmarks *sInstance;
 
   ~nsNavBookmarks();
 
   nsresult InitRoots();
   nsresult InitDefaults();
   nsresult InitStatements();
--- a/toolkit/components/places/src/nsNavHistory.cpp
+++ b/toolkit/components/places/src/nsNavHistory.cpp
@@ -5274,42 +5274,16 @@ nsNavHistory::AddDownload(nsIURI* aSourc
 
 NS_IMETHODIMP
 nsNavHistory::GetDBConnection(mozIStorageConnection **_DBConnection)
 {
   NS_ADDREF(*_DBConnection = mDBConn);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsNavHistory::FinalizeInternalStatements()
-{
-  NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
-
-  // nsNavHistory
-  FinalizeStatements();
-
-  // nsNavBookmarks
-  nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
-  NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
-  bookmarks->FinalizeStatements();
-
-  // nsAnnotationService
-  nsAnnotationService* annosvc = nsAnnotationService::GetAnnotationService();
-  NS_ENSURE_TRUE(annosvc, NS_ERROR_OUT_OF_MEMORY);
-  annosvc->FinalizeStatements();
-
-  // nsFaviconService
-  nsFaviconService* iconsvc = nsFaviconService::GetFaviconService();
-  NS_ENSURE_TRUE(iconsvc, NS_ERROR_OUT_OF_MEMORY);
-  iconsvc->FinalizeStatements();
-
-  return NS_OK;
-}
-
 // nsIObserver *****************************************************************
 
 NS_IMETHODIMP
 nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic,
                     const PRUnichar *aData)
 {
   NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
 
@@ -7476,51 +7450,16 @@ nsNavHistory::GetDBOldFrecencies()
      "WHERE ROWID >= ABS(RANDOM() % (SELECT MAX(ROWID) FROM moz_places)) "
      "LIMIT ?1"),
     getter_AddRefs(mDBOldFrecencies));
   NS_ENSURE_SUCCESS(rv, nsnull);
 
   return mDBOldFrecencies;
 }
 
-void
-nsNavHistory::FinalizeStatements() {
-  mDBGetURLPageInfo = nsnull;
-  mDBGetIdPageInfo = nsnull;
-  mDBRecentVisitOfURL = nsnull;
-  mDBRecentVisitOfPlace = nsnull;
-  mDBInsertVisit = nsnull;
-  mDBGetPageVisitStats = nsnull;
-  mDBIsPageVisited = nsnull;
-  mDBUpdatePageVisitStats = nsnull;
-  mDBAddNewPage = nsnull;
-  mDBGetTags = nsnull;
-  mFoldersWithAnnotationQuery = nsnull;
-  mDBSetPlaceTitle = nsnull;
-  mDBVisitToURLResult = nsnull;
-  mDBVisitToVisitResult = nsnull;
-  mDBBookmarkToUrlResult = nsnull;
-  mDBVisitsForFrecency = nsnull;
-  mDBUpdateFrecencyAndHidden = nsnull;
-  mDBGetPlaceVisitStats = nsnull;
-  mDBGetBookmarkParentsForPlace = nsnull;
-  mDBFullVisitCount = nsnull;
-  mDBInvalidFrecencies = nsnull;
-  mDBOldFrecencies = nsnull;
-  mDBCurrentQuery = nsnull;
-  mDBAutoCompleteQuery = nsnull;
-  mDBAutoCompleteHistoryQuery = nsnull;
-  mDBAutoCompleteStarQuery = nsnull;
-  mDBAutoCompleteTagsQuery = nsnull;
-  mDBPreviousQuery = nsnull;
-  mDBAdaptiveQuery = nsnull;
-  mDBKeywordQuery = nsnull;
-  mDBFeedbackIncrease = nsnull;
-}
-
 // nsICharsetResolver **********************************************************
 
 NS_IMETHODIMP
 nsNavHistory::RequestCharset(nsIWebNavigation* aWebNavigation,
                              nsIChannel* aChannel,
                              PRBool* aWantCharset,
                              nsISupports** aClosure,
                              nsACString& aResult)
--- a/toolkit/components/places/src/nsNavHistory.h
+++ b/toolkit/components/places/src/nsNavHistory.h
@@ -439,21 +439,16 @@ protected:
   // Consumers need to use the getters since these statements are lazily created
   mozIStorageStatement *GetDBVisitToURLResult();
   nsCOMPtr<mozIStorageStatement> mDBVisitToURLResult; // kGetInfoIndex_* results
   mozIStorageStatement *GetDBVisitToVisitResult();
   nsCOMPtr<mozIStorageStatement> mDBVisitToVisitResult; // kGetInfoIndex_* results
   mozIStorageStatement *GetDBBookmarkToUrlResult();
   nsCOMPtr<mozIStorageStatement> mDBBookmarkToUrlResult; // kGetInfoIndex_* results
 
-  /**
-   * Finalize all internal statements.
-   */
-  void FinalizeStatements();
-
   // nsICharsetResolver
   NS_DECL_NSICHARSETRESOLVER
 
   /**
    * Recalculates aCount frecencies.  If aRecalcOld, it will also calculate
    * the frecency of aCount history visits that have not occurred recently.
    *
    * @param aCount
--- a/toolkit/components/places/src/nsNavHistoryExpire.cpp
+++ b/toolkit/components/places/src/nsNavHistoryExpire.cpp
@@ -252,20 +252,28 @@ nsNavHistoryExpire::ClearHistory()
   // idle query to figure out which places to recalcuate frecency first.
   // We must do this before deleting visits
   nsresult rv = connection->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
     "UPDATE moz_places_view SET frecency = -MAX(visit_count, 1) "
     "WHERE id IN("
       "SELECT h.id FROM moz_places_temp h "
       "WHERE "
         "EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) "
+        "OR EXISTS "
+          "(SELECT id FROM moz_annos WHERE place_id = h.id AND expiration = ") +
+          nsPrintfCString("%d", nsIAnnotationService::EXPIRE_NEVER) +
+          NS_LITERAL_CSTRING(") "
       "UNION ALL "
       "SELECT h.id FROM moz_places h "
       "WHERE "
         "EXISTS (SELECT id FROM moz_bookmarks WHERE fk = h.id) "
+        "OR EXISTS "
+          "(SELECT id FROM moz_annos WHERE place_id = h.id AND expiration = ") +
+          nsPrintfCString("%d", nsIAnnotationService::EXPIRE_NEVER) +
+          NS_LITERAL_CSTRING(") "
     ")"));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // expire visits, then let the paranoid functions do the cleanup for us
   rv = connection->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
       "DELETE FROM moz_historyvisits_view"));
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -824,48 +832,40 @@ nsNavHistoryExpire::ExpireAnnotations(mo
 
   // remove days annos
   rv = expirePagesStatement->BindInt32Parameter(0, nsIAnnotationService::EXPIRE_DAYS);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = expirePagesStatement->BindInt64Parameter(1, (now - EXPIRATION_POLICY_DAYS));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = expirePagesStatement->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = expirePagesStatement->Reset();
-  NS_ENSURE_SUCCESS(rv, rv);
-
+  
   // remove days item annos
   rv = expireItemsStatement->BindInt32Parameter(0, nsIAnnotationService::EXPIRE_DAYS);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = expireItemsStatement->BindInt64Parameter(1, (now - EXPIRATION_POLICY_DAYS));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = expireItemsStatement->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = expireItemsStatement->Reset();
-  NS_ENSURE_SUCCESS(rv, rv);
 
   // remove weeks annos
   rv = expirePagesStatement->BindInt32Parameter(0, nsIAnnotationService::EXPIRE_WEEKS);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = expirePagesStatement->BindInt64Parameter(1, (now - EXPIRATION_POLICY_WEEKS));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = expirePagesStatement->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = expirePagesStatement->Reset();
-  NS_ENSURE_SUCCESS(rv, rv);
 
   // remove weeks item annos
   rv = expireItemsStatement->BindInt32Parameter(0, nsIAnnotationService::EXPIRE_WEEKS);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = expireItemsStatement->BindInt64Parameter(1, (now - EXPIRATION_POLICY_WEEKS));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = expireItemsStatement->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = expireItemsStatement->Reset();
-  NS_ENSURE_SUCCESS(rv, rv);
 
   // remove months annos
   rv = expirePagesStatement->BindInt32Parameter(0, nsIAnnotationService::EXPIRE_MONTHS);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = expirePagesStatement->BindInt64Parameter(1, (now - EXPIRATION_POLICY_MONTHS));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = expirePagesStatement->Execute();
   NS_ENSURE_SUCCESS(rv, rv);
--- a/toolkit/components/places/src/nsNavHistoryResult.cpp
+++ b/toolkit/components/places/src/nsNavHistoryResult.cpp
@@ -2190,20 +2190,17 @@ nsNavHistoryQueryResultNode::GetHasChild
     nsCOMPtr<mozIStorageStatement> hasTagsStatement;
     rv = dbConn->CreateStatement(NS_LITERAL_CSTRING(
         "SELECT id FROM moz_bookmarks WHERE parent = ?1 LIMIT 1"),
       getter_AddRefs(hasTagsStatement));
     NS_ENSURE_SUCCESS(rv, rv);
     rv = hasTagsStatement->BindInt64Parameter(0, tagsFolderId);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = hasTagsStatement->ExecuteStep(aHasChildren);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    return NS_OK;
+    return hasTagsStatement->ExecuteStep(aHasChildren);
   }
 
   // For history containers query we must check if we have any history
   if (resultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_QUERY ||
       resultType == nsINavHistoryQueryOptions::RESULTS_AS_DATE_SITE_QUERY ||
       resultType == nsINavHistoryQueryOptions::RESULTS_AS_SITE_QUERY) {
     nsNavHistory* history = nsNavHistory::GetHistoryService();
     NS_ENSURE_TRUE(history, NS_ERROR_OUT_OF_MEMORY);
--- a/toolkit/components/places/src/nsPlacesDBFlush.js
+++ b/toolkit/components/places/src/nsPlacesDBFlush.js
@@ -98,34 +98,17 @@ nsPlacesDBFlush.prototype = {
   observe: function DBFlush_observe(aSubject, aTopic, aData)
   {
     if (aTopic == kQuitApplication) {
       this._bs.removeObserver(this);
       this._os.removeObserver(this, kQuitApplication);
       this._prefs.QueryInterface(Ci.nsIPrefBranch2).removeObserver("", this);
       this._timer.cancel();
       this._timer = null;
-      // Other components could still make changes to history at this point,
-      // for example to clear private data on shutdown, so here we dispatch
-      // an event to the main thread so that we will sync after
-      // quit-application ensuring all data have been saved.
-      let tm = Cc["@mozilla.org/thread-manager;1"].
-          getService(Ci.nsIThreadManager);
-      tm.mainThread.dispatch({
-        _self: this,
-        run: function() {
-          this._self._syncTables(["places", "historyvisits"]);
-          // Close the database connection, this was the last sync and we can't
-          // ensure database coherence from now on.
-          Cc["@mozilla.org/browser/nav-history-service;1"].
-            getService(Ci.nsPIPlacesDatabase).finalizeInternalStatements();
-          this._self._db.close();
-        }
-      }, Ci.nsIThread.DISPATCH_NORMAL);
-
+      this._syncTables(["places", "historyvisits"]);
     }
     else if (aTopic == "nsPref:changed" && aData == kSyncPrefName) {
       // Get the new pref value, and then update our timer
       this._syncInterval = aSubject.getIntPref(kSyncPrefName);
       if (this._syncInterval <= 0)
         this._syncInterval = kDefaultSyncInterval;
 
       // We may have canceled the timer already for batch updates, so we want to
--- a/toolkit/components/places/tests/sync/head_sync.js
+++ b/toolkit/components/places/tests/sync/head_sync.js
@@ -106,17 +106,19 @@ clearDB();
 /**
  * Dumps the rows of a table out to the console.
  *
  * @param aName
  *        The name of the table or view to output.
  */
 function dump_table(aName)
 {
-  let db = DBConn()
+  let db = Cc["@mozilla.org/browser/nav-history-service;1"].
+           getService(Ci.nsPIPlacesDatabase).
+           DBConnection;
   let stmt = db.createStatement("SELECT * FROM " + aName);
 
   dump("\n*** Printing data from " + aName + ":\n");
   let count = 0;
   while (stmt.executeStep()) {
     let columns = stmt.numEntries;
 
     if (count == 0) {
@@ -178,17 +180,19 @@ function finish_test()
  *        The URI we expect to be in moz_places.
  * @param aExpected
  *        Indicates if we expect to get a result or not.
  * @param [optional] aFinish
  *        Indicates if the test should be completed or not.
  */
 function new_test_bookmark_uri_event(aBookmarkId, aExpectedURI, aExpected, aFinish)
 {
-  let db = DBConn();
+  let db = Cc["@mozilla.org/browser/nav-history-service;1"].
+           getService(Ci.nsPIPlacesDatabase).
+           DBConnection;
   let stmt = db.createStatement(
     "SELECT moz_places.url " +
     "FROM moz_bookmarks INNER JOIN moz_places " +
     "ON moz_bookmarks.fk = moz_places.id " +
     "WHERE moz_bookmarks.id = ?1"
   );
   stmt.bindInt64Parameter(0, aBookmarkId);
 
@@ -218,17 +222,19 @@ function new_test_bookmark_uri_event(aBo
  *        The URI we expect to be in moz_places.
  * @param aExpected
  *        Indicates if we expect to get a result or not.
  * @param [optional] aFinish
  *        Indicates if the test should be completed or not.
  */
 function new_test_visit_uri_event(aVisitId, aExpectedURI, aExpected, aFinish)
 {
-  let db = DBConn();
+  let db = Cc["@mozilla.org/browser/nav-history-service;1"].
+           getService(Ci.nsPIPlacesDatabase).
+           DBConnection;
   let stmt = db.createStatement(
     "SELECT moz_places.url " +
     "FROM moz_historyvisits INNER JOIN moz_places " +
     "ON moz_historyvisits.place_id = moz_places.id " +
     "WHERE moz_historyvisits.id = ?1"
   );
   stmt.bindInt64Parameter(0, aVisitId);
 
@@ -242,36 +248,11 @@ function new_test_visit_uri_event(aVisit
   stmt.reset();
   stmt.finalize();
   stmt = null;
 
   if (aFinish)
     finish_test();
 }
 
-/**
- * Function gets current database connection, if the connection has been closed
- * it will try to reconnect to the places.sqlite database.
- */
-function DBConn()
-{
-  let db = Cc["@mozilla.org/browser/nav-history-service;1"].
-           getService(Ci.nsPIPlacesDatabase).
-           DBConnection;
-  if (db.connectionReady)
-    return db;
-
-  // open a new connection if needed
-  let file = dirSvc.get('ProfD', Ci.nsIFile);
-  file.append("places.sqlite");
-  let storageService = Cc["@mozilla.org/storage/service;1"].
-                       getService(Ci.mozIStorageService);
-  try {
-    var dbConn = storageService.openDatabase(file);
-  } catch (ex) {
-    return null;
-  }
-  return dbConn;
-}
-
 // profile-after-change doesn't create components in xpcshell, so we have to do
 // it ourselves
 Cc["@mozilla.org/places/sync;1"].getService(Ci.nsISupports);