[mq]: backout-bug-463471

This commit is contained in:
Dietrich Ayala 2008-11-12 23:50:19 -08:00
parent 56517d34eb
commit 5e5d254f63
13 changed files with 22 additions and 196 deletions

View File

@ -46,17 +46,11 @@ interface mozIStorageConnection;
* 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();
};

View File

@ -2007,22 +2007,3 @@ nsAnnotationService::CallSetForItemObservers(PRInt64 aItemId, const nsACString&
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;
}

View File

@ -78,11 +78,6 @@ public:
return gAnnotationService;
}
/**
* Finalize all internal statements.
*/
void FinalizeStatements();
NS_DECL_ISUPPORTS
NS_DECL_NSIANNOTATIONSERVICE

View File

@ -1011,15 +1011,6 @@ nsFaviconService::OptimizeFaviconImage(const PRUint8* aData, PRUint32 aDataLen,
return NS_OK;
}
void
nsFaviconService::FinalizeStatements() {
mDBGetURL = nsnull;
mDBGetData = nsnull;
mDBGetIconInfo = nsnull;
mDBInsertIcon = nsnull;
mDBUpdateIcon = nsnull;
mDBSetPageFavicon = nsnull;
}
NS_IMPL_ISUPPORTS4(FaviconLoadListener,
nsIRequestObserver,

View File

@ -90,15 +90,10 @@ public:
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();

View File

@ -432,26 +432,6 @@ nsNavBookmarks::InitStatements()
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
//

View File

@ -104,11 +104,6 @@ public:
PRBool ItemExists(PRInt64 aItemId);
/**
* Finalize all internal statements.
*/
void FinalizeStatements();
private:
static nsNavBookmarks *sInstance;

View File

@ -5279,32 +5279,6 @@ nsNavHistory::GetDBConnection(mozIStorageConnection **_DBConnection)
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
@ -7481,41 +7455,6 @@ nsNavHistory::GetDBOldFrecencies()
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

View File

@ -444,11 +444,6 @@ protected:
mozIStorageStatement *GetDBBookmarkToUrlResult();
nsCOMPtr<mozIStorageStatement> mDBBookmarkToUrlResult; // kGetInfoIndex_* results
/**
* Finalize all internal statements.
*/
void FinalizeStatements();
// nsICharsetResolver
NS_DECL_NSICHARSETRESOLVER

View File

@ -257,10 +257,18 @@ nsNavHistoryExpire::ClearHistory()
"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);
@ -829,9 +837,7 @@ nsNavHistoryExpire::ExpireAnnotations(mozIStorageConnection* aConnection)
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);
@ -839,8 +845,6 @@ nsNavHistoryExpire::ExpireAnnotations(mozIStorageConnection* aConnection)
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);
@ -849,8 +853,6 @@ nsNavHistoryExpire::ExpireAnnotations(mozIStorageConnection* aConnection)
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);
@ -859,8 +861,6 @@ nsNavHistoryExpire::ExpireAnnotations(mozIStorageConnection* aConnection)
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);

View File

@ -2195,10 +2195,7 @@ nsNavHistoryQueryResultNode::GetHasChildren(PRBool* aHasChildren)
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

View File

@ -103,24 +103,7 @@ nsPlacesDBFlush.prototype = {
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

View File

@ -111,7 +111,9 @@ clearDB();
*/
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");
@ -183,7 +185,9 @@ function finish_test()
*/
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 " +
@ -223,7 +227,9 @@ function new_test_bookmark_uri_event(aBookmarkId, aExpectedURI, aExpected, aFini
*/
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 " +
@ -247,31 +253,6 @@ function new_test_visit_uri_event(aVisitId, aExpectedURI, aExpected, 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);