зеркало из https://github.com/mozilla/gecko-dev.git
Bug 721603 - We should spin the loop after calling asyncClose in Database.cpp. r=mak.
--HG-- extra : rebase_source : 3defc8d4da90de3f1c4738ec7e56faff6afec521
This commit is contained in:
Родитель
8f4c1c22db
Коммит
f738baa87b
|
@ -251,6 +251,49 @@ SetJournalMode(nsCOMPtr<mozIStorageConnection>& aDBConn,
|
|||
return JOURNAL_DELETE;
|
||||
}
|
||||
|
||||
class BlockingConnectionCloseCallback : public mozIStorageCompletionCallback {
|
||||
bool mDone;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_MOZISTORAGECOMPLETIONCALLBACK
|
||||
BlockingConnectionCloseCallback();
|
||||
void Spin();
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
BlockingConnectionCloseCallback::Complete()
|
||||
{
|
||||
mDone = true;
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
MOZ_ASSERT(os);
|
||||
if (!os)
|
||||
return NS_OK;
|
||||
DebugOnly<nsresult> rv = os->NotifyObservers(nsnull,
|
||||
TOPIC_PLACES_CONNECTION_CLOSED,
|
||||
nsnull);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BlockingConnectionCloseCallback::BlockingConnectionCloseCallback()
|
||||
: mDone(false)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
||||
void BlockingConnectionCloseCallback::Spin() {
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
while (!mDone) {
|
||||
NS_ProcessNextEvent(thread);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(
|
||||
BlockingConnectionCloseCallback
|
||||
, mozIStorageCompletionCallback
|
||||
)
|
||||
|
||||
nsresult
|
||||
CreateRoot(nsCOMPtr<mozIStorageConnection>& aDBConn,
|
||||
const nsCString& aRootName,
|
||||
|
@ -1672,9 +1715,10 @@ Database::Shutdown()
|
|||
);
|
||||
DispatchToAsyncThread(event);
|
||||
|
||||
nsRefPtr<PlacesEvent> closeListener =
|
||||
new PlacesEvent(TOPIC_PLACES_CONNECTION_CLOSED);
|
||||
nsRefPtr<BlockingConnectionCloseCallback> closeListener =
|
||||
new BlockingConnectionCloseCallback();
|
||||
(void)mMainConn->AsyncClose(closeListener);
|
||||
closeListener->Spin();
|
||||
|
||||
// Don't set this earlier, otherwise some internal helper used on shutdown
|
||||
// may bail out.
|
||||
|
|
|
@ -400,13 +400,6 @@ PlacesEvent::Run()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PlacesEvent::Complete()
|
||||
{
|
||||
Notify();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
PlacesEvent::Notify()
|
||||
{
|
||||
|
@ -417,9 +410,8 @@ PlacesEvent::Notify()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(
|
||||
PlacesEvent
|
||||
, mozIStorageCompletionCallback
|
||||
, nsIRunnable
|
||||
)
|
||||
|
||||
|
|
|
@ -247,12 +247,10 @@ bool GetHiddenState(bool aIsRedirect,
|
|||
* Notifies a specified topic via the observer service.
|
||||
*/
|
||||
class PlacesEvent : public nsRunnable
|
||||
, public mozIStorageCompletionCallback
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIRUNNABLE
|
||||
NS_DECL_MOZISTORAGECOMPLETIONCALLBACK
|
||||
|
||||
PlacesEvent(const char* aTopic);
|
||||
protected:
|
||||
|
|
Загрузка…
Ссылка в новой задаче