Bug 1160013 CachePushStreamChild should hold the parent DOM object alive. r=baku

This commit is contained in:
Ben Kelly 2015-05-05 07:03:52 -07:00
parent 86a6b07e7c
commit f529480953
5 changed files with 11 additions and 6 deletions

2
dom/cache/Cache.cpp vendored
View File

@ -512,7 +512,7 @@ Cache::CreatePushStream(nsIAsyncInputStream* aStream)
NS_ASSERT_OWNINGTHREAD(Cache);
MOZ_ASSERT(mActor);
MOZ_ASSERT(aStream);
return mActor->CreatePushStream(aStream);
return mActor->CreatePushStream(this, aStream);
}
Cache::~Cache()

View File

@ -73,11 +73,11 @@ CacheChild::ExecuteOp(nsIGlobalObject* aGlobal, Promise* aPromise,
}
CachePushStreamChild*
CacheChild::CreatePushStream(nsIAsyncInputStream* aStream)
CacheChild::CreatePushStream(nsISupports* aParent, nsIAsyncInputStream* aStream)
{
mNumChildActors += 1;
auto actor = SendPCachePushStreamConstructor(
new CachePushStreamChild(GetFeature(), aStream));
new CachePushStreamChild(GetFeature(), aParent, aStream));
MOZ_ASSERT(actor);
return static_cast<CachePushStreamChild*>(actor);
}

View File

@ -43,7 +43,7 @@ public:
nsISupports* aParent, const CacheOpArgs& aArgs);
CachePushStreamChild*
CreatePushStream(nsIAsyncInputStream* aStream);
CreatePushStream(nsISupports* aParent, nsIAsyncInputStream* aStream);
// Our parent Listener object has gone out of scope and is being destroyed.
void StartDestroyFromListener();

View File

@ -93,10 +93,13 @@ NS_IMPL_ISUPPORTS(CachePushStreamChild::Callback, nsIInputStreamCallback,
nsICancelableRunnable);
CachePushStreamChild::CachePushStreamChild(Feature* aFeature,
nsISupports* aParent,
nsIAsyncInputStream* aStream)
: mStream(aStream)
: mParent(aParent)
, mStream(aStream)
, mClosed(false)
{
MOZ_ASSERT(mParent);
MOZ_ASSERT(mStream);
MOZ_ASSERT_IF(!NS_IsMainThread(), aFeature);
SetFeature(aFeature);

View File

@ -31,7 +31,8 @@ private:
class Callback;
// This class must be constructed using CacheChild::CreatePushStream()
CachePushStreamChild(Feature* aFeature, nsIAsyncInputStream* aStream);
CachePushStreamChild(Feature* aFeature, nsISupports* aParent,
nsIAsyncInputStream* aStream);
~CachePushStreamChild();
// PCachePushStreamChild methods
@ -46,6 +47,7 @@ private:
void OnEnd(nsresult aRv);
nsCOMPtr<nsISupports> mParent;
nsCOMPtr<nsIAsyncInputStream> mStream;
nsRefPtr<Callback> mCallback;
bool mClosed;