Bug 1149987 - Part 6: Release the FetchPut object on the right thread in FetchObserver::OnResponseEnd(); r=bkelly

This commit is contained in:
Ehsan Akhgari 2015-04-10 17:09:15 -04:00
parent 402e7e602a
commit f56fe99956
2 changed files with 10 additions and 1 deletions

View File

@ -77,7 +77,15 @@ public:
virtual void OnResponseEnd() override
{
mFetchPut->FetchComplete(this, mInternalResponse);
mFetchPut = nullptr;
if (mFetchPut->mInitiatingThread == NS_GetCurrentThread()) {
mFetchPut = nullptr;
} else {
nsCOMPtr<nsIThread> initiatingThread(mFetchPut->mInitiatingThread);
nsCOMPtr<nsIRunnable> runnable =
NS_NewNonOwningRunnableMethod(mFetchPut.forget().take(), &FetchPut::Release);
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
initiatingThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)));
}
}
protected:

View File

@ -54,6 +54,7 @@ public:
private:
class Runnable;
class FetchObserver;
friend class FetchObserver;
struct State
{
PCacheRequest mPCacheRequest;