backout bug 492797 due to test failure
authorDietrich Ayala <dietrich@mozilla.com>
Sun, 31 Jan 2010 21:10:07 -0800
changeset 37788 7006acb49dfb6560274b11ba82c5cb41c4a353f9
parent 37787 1ffccd3864e12f75a10dff304f5ace1b16aa5090
child 37789 f57b95afb57e72b65a4e56de0d5582e8248442bb
push id11434
push userdietrich@mozilla.com
push dateMon, 01 Feb 2010 05:11:44 +0000
treeherdermozilla-central@7006acb49dfb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs492797
milestone1.9.3a1pre
backout bug 492797 due to test failure
toolkit/components/places/src/nsNavHistory.cpp
toolkit/components/places/src/nsNavHistory.h
--- a/toolkit/components/places/src/nsNavHistory.cpp
+++ b/toolkit/components/places/src/nsNavHistory.cpp
@@ -393,17 +393,16 @@ nsNavHistory::nsNavHistory()
 , mLastSessionID(0)
 , mHistoryEnabled(PR_TRUE)
 , mNumVisitsForFrecency(10)
 , mTagsFolder(-1)
 , mInPrivateBrowsing(PRIVATEBROWSING_NOTINITED)
 , mDatabaseStatus(DATABASE_STATUS_OK)
 , mCanNotify(true)
 , mCacheObservers("history-observers")
-, mHasHistoryEntries(-1)
 {
 #ifdef LAZY_ADD
   mLazyTimerSet = PR_TRUE;
   mLazyTimerDeferments = 0;
 #endif
   NS_ASSERTION(!gHistoryService,
                "Attempting to create two instances of the service!");
   gHistoryService = this;
@@ -2466,34 +2465,24 @@ nsNavHistory::DomainNameFromURI(nsIURI *
 // nsNavHistory::GetHasHistoryEntries
 
 NS_IMETHODIMP
 nsNavHistory::GetHasHistoryEntries(PRBool* aHasEntries)
 {
   NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
   NS_ENSURE_ARG_POINTER(aHasEntries);
 
-  // Use cached value if it's been set
-  if (mHasHistoryEntries != -1) {
-    *aHasEntries = (mHasHistoryEntries == 1);
-    return NS_OK;
-  }
-
   nsCOMPtr<mozIStorageStatement> dbSelectStatement;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
       "SELECT 1 "
       "WHERE EXISTS (SELECT id FROM moz_historyvisits_temp LIMIT 1) "
         "OR EXISTS (SELECT id FROM moz_historyvisits LIMIT 1)"),
     getter_AddRefs(dbSelectStatement));
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = dbSelectStatement->ExecuteStep(aHasEntries);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mHasHistoryEntries = *aHasEntries ? 1 : 0;
-  return NS_OK;
+  return dbSelectStatement->ExecuteStep(aHasEntries);
 }
 
 nsresult
 nsNavHistory::FixInvalidFrecenciesForExcludedPlaces()
 {
   // for every moz_place that has an invalid frecency (< 0) and
   // is an unvisited child of a livemark feed, or begins with "place:",
   // set frecency to 0 so that it is excluded from url bar autocomplete.
@@ -4376,38 +4365,35 @@ nsNavHistory::GetCount(PRUint32 *aCount)
 //    This is an internal method used by RemovePages, RemovePagesFromHost and
 //    RemovePagesByTimeframe.
 //    Takes a comma separated list of place ids.
 //    This method does not do any observer notification.
 
 nsresult
 nsNavHistory::RemovePagesInternal(const nsCString& aPlaceIdsQueryString)
 {
-  // Return early if there is nothing to delete.
+  // early return if there is nothing to delete
   if (aPlaceIdsQueryString.IsEmpty())
     return NS_OK;
 
   mozStorageTransaction transaction(mDBConn, PR_FALSE);
 
   nsresult rv = PreparePlacesForVisitsDelete(aPlaceIdsQueryString);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // Delete all visits for the specified place ids.
+  // delete all visits
   rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
       "DELETE FROM moz_historyvisits_view WHERE place_id IN (") +
         aPlaceIdsQueryString +
         NS_LITERAL_CSTRING(")"));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = CleanupPlacesOnVisitsDelete(aPlaceIdsQueryString);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // Invalidate the cached value for whether there's history or not.
-  mHasHistoryEntries = -1;
-
   return transaction.Commit();
 }
 
 
 /**
  * Prepares for deletion places that are about to have all their visits removed.
  * This is an internal method used by RemovePagesInternal and
  * RemoveVisitsByTimeframe.  This method does not execute in a transaction, so
@@ -4837,19 +4823,16 @@ nsNavHistory::RemoveVisitsByTimeframe(PR
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = CleanupPlacesOnVisitsDelete(deletePlaceIdsQueryString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = transaction.Commit();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // Invalidate the cached value for whether there's history or not.
-  mHasHistoryEntries = -1;
-
   return NS_OK;
 }
 
 
 // nsNavHistory::RemoveAllPages
 //
 //    This function is used to clear history.
 
@@ -4891,19 +4874,16 @@ nsNavHistory::RemoveAllPages()
   // call FixInvalidFrecenciesForExcludedPlaces to handle that scenario.
   rv = FixInvalidFrecenciesForExcludedPlaces();
   if (NS_FAILED(rv))
     NS_WARNING("failed to fix invalid frecencies");
 
   rv = transaction.Commit();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // Invalidate the cached value for whether there's history or not.
-  mHasHistoryEntries = -1;
-
   // Expiration will take care of orphans.
   NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers,
                    nsINavHistoryObserver, OnClearHistory());
 
   // privacy cleanup, if there's an old history.dat around, just delete it
   nsCOMPtr<nsIFile> oldHistoryFile;
   rv = NS_GetSpecialDirectory(NS_APP_HISTORY_50_FILE,
                               getter_AddRefs(oldHistoryFile));
@@ -5514,19 +5494,16 @@ nsNavHistory::FinalizeInternalStatements
 }
 
 // nsPIPlacesHistoryListenersNotifier ******************************************
 
 NS_IMETHODIMP
 nsNavHistory::NotifyOnPageExpired(nsIURI *aURI, PRTime aVisitTime,
                                   PRBool aWholeEntry)
 {
-  // Invalidate the cached value for whether there's history or not.
-  mHasHistoryEntries = -1;
-
   if (aWholeEntry) {
     // Notify our observers that the page has been removed.
     NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers,
                      nsINavHistoryObserver, OnDeleteURI(aURI));
   }
   else {
     // Notify our observers that some visits for the page have been removed.
     NOTIFY_OBSERVERS(mCanNotify, mCacheObservers, mObservers,
--- a/toolkit/components/places/src/nsNavHistory.h
+++ b/toolkit/components/places/src/nsNavHistory.h
@@ -682,18 +682,16 @@ protected:
                            nsNavHistoryQueryOptions* aOptions);
 
   PRInt64 mTagsFolder;
 
   PRBool mInPrivateBrowsing;
 
   PRUint16 mDatabaseStatus;
 
-  PRInt8 mHasHistoryEntries;
-
   // Used to enable and disable the observer notifications
   bool mCanNotify;
   nsCategoryCache<nsINavHistoryObserver> mCacheObservers;
 };
 
 /**
  * Shared between the places components, this function binds the given URI as
  * UTF8 to the given parameter for the statement.