mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1411257 - No MOZ_CRASH if BackgroundChild::GetOrCreateForCurrentThread() fails - part 2 - MessagePort, r=asuth
This commit is contained in:
parent
f96c5428b8
commit
1f86f7d2a2
@ -311,7 +311,10 @@ MessagePort::Initialize(const nsID& aUUID,
|
||||
}
|
||||
|
||||
if (mState == eStateEntangling) {
|
||||
ConnectToPBackground();
|
||||
if (!ConnectToPBackground()) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(mState == eStateUnshippedEntangled);
|
||||
}
|
||||
@ -781,7 +784,11 @@ MessagePort::CloneAndDisentangle(MessagePortIdentifier& aIdentifier)
|
||||
MOZ_ASSERT(mMessagesForTheOtherPort.IsEmpty());
|
||||
|
||||
// Disconnect the entangled port and connect it to PBackground.
|
||||
mUnshippedEntangledPort->ConnectToPBackground();
|
||||
if (!mUnshippedEntangledPort->ConnectToPBackground()) {
|
||||
// We are probably shutting down. We cannot proceed.
|
||||
return;
|
||||
}
|
||||
|
||||
mUnshippedEntangledPort = nullptr;
|
||||
|
||||
// In this case, we don't need to be connected to the PBackground service.
|
||||
@ -794,7 +801,10 @@ MessagePort::CloneAndDisentangle(MessagePortIdentifier& aIdentifier)
|
||||
}
|
||||
|
||||
// Register this component to PBackground.
|
||||
ConnectToPBackground();
|
||||
if (!ConnectToPBackground()) {
|
||||
// We are probably shutting down. We cannot proceed.
|
||||
return;
|
||||
}
|
||||
|
||||
mState = eStateEntanglingForDisentangle;
|
||||
return;
|
||||
@ -827,7 +837,7 @@ MessagePort::Closed()
|
||||
UpdateMustKeepAlive();
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
MessagePort::ConnectToPBackground()
|
||||
{
|
||||
mState = eStateEntangling;
|
||||
@ -835,18 +845,22 @@ MessagePort::ConnectToPBackground()
|
||||
mozilla::ipc::PBackgroundChild* actorChild =
|
||||
mozilla::ipc::BackgroundChild::GetOrCreateForCurrentThread();
|
||||
if (NS_WARN_IF(!actorChild)) {
|
||||
MOZ_CRASH("Failed to create a PBackgroundChild actor!");
|
||||
return false;
|
||||
}
|
||||
|
||||
PMessagePortChild* actor =
|
||||
actorChild->SendPMessagePortConstructor(mIdentifier->uuid(),
|
||||
mIdentifier->destinationUuid(),
|
||||
mIdentifier->sequenceId());
|
||||
if (NS_WARN_IF(!actor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mActor = static_cast<MessagePortChild*>(actor);
|
||||
MOZ_ASSERT(mActor);
|
||||
|
||||
mActor->SetPort(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -141,7 +141,7 @@ private:
|
||||
uint32_t aSequenceID, bool mNeutered, State aState,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void ConnectToPBackground();
|
||||
bool ConnectToPBackground();
|
||||
|
||||
// Dispatch events from the Message Queue using a nsRunnable.
|
||||
void Dispatch();
|
||||
|
Loading…
Reference in New Issue
Block a user