mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 612455 - History.cpp should finalize statementCache on the background thread
Also fixes the favicon service to do this in a safer manner. r=mak a=blocking
This commit is contained in:
parent
f6d6332349
commit
7c5b41717c
@ -46,6 +46,7 @@
|
||||
#include "mozilla/storage.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsProxyRelease.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace places {
|
||||
@ -211,23 +212,33 @@ public:
|
||||
*
|
||||
* @param aStatementCache
|
||||
* The statementCache that should be finalized.
|
||||
* @param aOwner
|
||||
* The object that owns the statement cache. This runnable will hold
|
||||
* a strong reference to it so aStatementCache will not disappear from
|
||||
* under us.
|
||||
*/
|
||||
FinalizeStatementCacheProxy(
|
||||
mozilla::storage::StatementCache<StatementType>& aStatementCache
|
||||
mozilla::storage::StatementCache<StatementType>& aStatementCache,
|
||||
nsISupports* aOwner
|
||||
)
|
||||
: mStatementCache(aStatementCache)
|
||||
, mOwner(aOwner)
|
||||
, mCallingThread(do_GetCurrentThread())
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Run()
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
mStatementCache.FinalizeStatements();
|
||||
// Release the owner back on the calling thread.
|
||||
(void)NS_ProxyRelease(mCallingThread, mOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
mozilla::storage::StatementCache<StatementType>& mStatementCache;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
nsCOMPtr<nsIThread> mCallingThread;
|
||||
};
|
||||
|
||||
} // namespace places
|
||||
|
@ -863,10 +863,6 @@ History::~History()
|
||||
"Not all Links were removed before we disappear!");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Places shutdown event may not occur, but we *must* clean up before History
|
||||
// goes away.
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
void
|
||||
@ -984,10 +980,18 @@ History::GetDBConn()
|
||||
void
|
||||
History::Shutdown()
|
||||
{
|
||||
NS_ASSERTION(!mShuttingDown, "Shutdown was called more than once!");
|
||||
|
||||
mShuttingDown = true;
|
||||
|
||||
// Clean up our statements and connection.
|
||||
syncStatements.FinalizeStatements();
|
||||
nsISupports* obj = static_cast<IHistory*>(this);
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
new FinalizeStatementCacheProxy<mozIStorageStatement>(syncStatements, obj);
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetInterface(mDBConn);
|
||||
if (target) {
|
||||
(void)target->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
if (mReadOnlyDBConn) {
|
||||
if (mIsVisitedStatement) {
|
||||
|
@ -942,7 +942,7 @@ nsFaviconService::FinalizeStatements() {
|
||||
|
||||
// Finalize the statementCache on the correct thread.
|
||||
nsRefPtr<FinalizeStatementCacheProxy<mozIStorageStatement> > event =
|
||||
new FinalizeStatementCacheProxy<mozIStorageStatement>(mSyncStatements);
|
||||
new FinalizeStatementCacheProxy<mozIStorageStatement>(mSyncStatements, this);
|
||||
nsCOMPtr<nsIEventTarget> target = do_GetInterface(mDBConn);
|
||||
NS_ENSURE_TRUE(target, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsresult rv = target->Dispatch(event, NS_DISPATCH_NORMAL);
|
||||
|
Loading…
Reference in New Issue
Block a user