Bug 613360 - Safe use of thread observers in ContentParent. f=josh r=bsemdberg

This commit is contained in:
Andrew Quartey 2011-12-02 13:33:05 +01:00
Родитель 6f7be3b9fd
Коммит 15558a568d
2 изменённых файлов: 5 добавлений и 15 удалений

Просмотреть файл

@ -225,8 +225,7 @@ ContentParent::Init()
nsCOMPtr<nsIThreadInternal>
threadInt(do_QueryInterface(NS_GetCurrentThread()));
if (threadInt) {
threadInt->GetObserver(getter_AddRefs(mOldObserver));
threadInt->SetObserver(this);
threadInt->AddObserver(this);
}
if (obs) {
obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-created", nsnull);
@ -344,7 +343,7 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
nsCOMPtr<nsIThreadInternal>
threadInt(do_QueryInterface(NS_GetCurrentThread()));
if (threadInt)
threadInt->SetObserver(mOldObserver);
threadInt->RemoveObserver(this);
if (mRunToCompletionDepth)
mRunToCompletionDepth = 0;
@ -1118,11 +1117,9 @@ ContentParent::RecvLoadURIExternal(const IPC::URI& uri)
/* void onDispatchedEvent (in nsIThreadInternal thread); */
NS_IMETHODIMP
ContentParent::OnDispatchedEvent(nsIThreadInternal *thread)
{
if (mOldObserver)
return mOldObserver->OnDispatchedEvent(thread);
return NS_OK;
{
NS_NOTREACHED("OnDispatchedEvent unimplemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void onProcessNextEvent (in nsIThreadInternal thread, in boolean mayWait, in unsigned long recursionDepth); */
@ -1134,9 +1131,6 @@ ContentParent::OnProcessNextEvent(nsIThreadInternal *thread,
if (mRunToCompletionDepth)
++mRunToCompletionDepth;
if (mOldObserver)
return mOldObserver->OnProcessNextEvent(thread, mayWait, recursionDepth);
return NS_OK;
}
@ -1156,9 +1150,6 @@ ContentParent::AfterProcessNextEvent(nsIThreadInternal *thread,
}
}
if (mOldObserver)
return mOldObserver->AfterProcessNextEvent(thread, recursionDepth);
return NS_OK;
}

Просмотреть файл

@ -235,7 +235,6 @@ private:
PRInt32 mGeolocationWatchID;
int mRunToCompletionDepth;
bool mShouldCallUnblockChild;
nsCOMPtr<nsIThreadObserver> mOldObserver;
// This is a cache of all of the memory reporters
// registered in the child process. To update this, one