Bug 956218 - Make sure that all callbacks are called, r=bent.

This commit is contained in:
Steve Workman 2014-02-06 10:42:29 +01:00
Родитель a80f9315df
Коммит 4685ba00ff
1 изменённых файлов: 37 добавлений и 14 удалений

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

@ -1541,7 +1541,10 @@ ChildImpl::CreateCallbackRunnable::GetNextCallback()
auto threadLocalInfo =
static_cast<ThreadLocalInfo*>(PR_GetThreadPrivate(sThreadLocalIndex));
MOZ_ASSERT(threadLocalInfo);
MOZ_ASSERT(!threadLocalInfo->mCallbacks.IsEmpty());
if (threadLocalInfo->mCallbacks.IsEmpty()) {
return nullptr;
}
nsCOMPtr<nsIIPCBackgroundChildCreateCallback> callback;
threadLocalInfo->mCallbacks[0].swap(callback);
@ -1558,16 +1561,18 @@ ChildImpl::CreateCallbackRunnable::Run()
{
// May run on any thread!
nsCOMPtr<nsIIPCBackgroundChildCreateCallback> callback = GetNextCallback();
MOZ_ASSERT(callback);
nsRefPtr<ChildImpl> actor;
mActor.swap(actor);
if (actor) {
callback->ActorCreated(actor);
} else {
callback->ActorFailed();
nsCOMPtr<nsIIPCBackgroundChildCreateCallback> callback = GetNextCallback();
while (callback) {
if (actor) {
callback->ActorCreated(actor);
} else {
callback->ActorFailed();
}
callback = GetNextCallback();
}
return NS_OK;
@ -1586,7 +1591,9 @@ ChildImpl::OpenChildProcessActorRunnable::Run()
MOZ_ASSERT(mTransport);
nsCOMPtr<nsIIPCBackgroundChildCreateCallback> callback = GetNextCallback();
MOZ_ASSERT(callback);
MOZ_ASSERT(callback,
"There should be at least one callback when first creating the "
"actor!");
nsRefPtr<ChildImpl> strongActor;
mActor.swap(strongActor);
@ -1595,7 +1602,11 @@ ChildImpl::OpenChildProcessActorRunnable::Run()
XRE_GetIOMessageLoop(), ChildSide)) {
CRASH_IN_CHILD_PROCESS("Failed to open ChildImpl!");
callback->ActorFailed();
while (callback) {
callback->ActorFailed();
callback = GetNextCallback();
}
return NS_OK;
}
@ -1611,7 +1622,10 @@ ChildImpl::OpenChildProcessActorRunnable::Run()
actor->SetBoundThread();
callback->ActorCreated(actor);
while (callback) {
callback->ActorCreated(actor);
callback = GetNextCallback();
}
return NS_OK;
}
@ -1630,7 +1644,9 @@ ChildImpl::OpenMainProcessActorRunnable::Run()
MOZ_ASSERT(mParentMessageLoop);
nsCOMPtr<nsIIPCBackgroundChildCreateCallback> callback = GetNextCallback();
MOZ_ASSERT(callback);
MOZ_ASSERT(callback,
"There should be at least one callback when first creating the "
"actor!");
nsRefPtr<ChildImpl> strongChildActor;
mActor.swap(strongChildActor);
@ -1646,7 +1662,11 @@ ChildImpl::OpenMainProcessActorRunnable::Run()
parentActor->Destroy();
callback->ActorFailed();
while (callback) {
callback->ActorFailed();
callback = GetNextCallback();
}
return NS_OK;
}
@ -1664,7 +1684,10 @@ ChildImpl::OpenMainProcessActorRunnable::Run()
childActor->SetBoundThread();
callback->ActorCreated(childActor);
while (callback) {
callback->ActorCreated(childActor);
callback = GetNextCallback();
}
return NS_OK;
}