Bug 1549321 - Pass AudioIPC init failure back to child rather than IPC_FAIL() killing parent. r=achronop

Differential Revision: https://phabricator.services.mozilla.com/D34105

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matthew Gregan 2019-06-07 11:52:54 +00:00
Родитель b12392f04f
Коммит 34f757d483
3 изменённых файлов: 25 добавлений и 12 удалений

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

@ -4423,10 +4423,13 @@ mozilla::ipc::IPCResult ContentParent::RecvRequestAnonymousTemporaryFile(
mozilla::ipc::IPCResult ContentParent::RecvCreateAudioIPCConnection(
CreateAudioIPCConnectionResolver&& aResolver) {
FileDescriptor fd = CubebUtils::CreateAudioIPCConnection();
if (!fd.IsValid()) {
return IPC_FAIL(this, "CubebUtils::CreateAudioIPCConnection failed");
FileDescOrError result;
if (fd.IsValid()) {
result = fd;
} else {
result = NS_ERROR_FAILURE;
}
aResolver(std::move(fd));
aResolver(std::move(result));
return IPC_OK();
}

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

@ -873,7 +873,7 @@ parent:
async PPresentation();
async CreateAudioIPCConnection() returns (FileDescriptor fd);
async CreateAudioIPCConnection() returns (FileDescOrError fd);
sync PURLClassifier(Principal principal)
returns (bool success);

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

@ -401,14 +401,19 @@ void InitAudioIPCConnection() {
auto promise = contentChild->SendCreateAudioIPCConnection();
promise->Then(
AbstractThread::MainThread(), __func__,
[](ipc::FileDescriptor&& aFD) {
[](dom::FileDescOrError&& aFD) {
StaticMutexAutoLock lock(sMutex);
MOZ_ASSERT(!sIPCConnection);
sIPCConnection = new ipc::FileDescriptor(std::move(aFD));
if (aFD.type() == dom::FileDescOrError::Type::TFileDescriptor) {
sIPCConnection = new ipc::FileDescriptor(std::move(aFD));
} else {
MOZ_LOG(gCubebLog, LogLevel::Error,
("SendCreateAudioIPCConnection failed: invalid FD"));
}
},
[](mozilla::ipc::ResponseRejectReason&& aReason) {
MOZ_LOG(gCubebLog, LogLevel::Error,
("SendCreateAudioIPCConnection failed: %d", int(aReason)));
("SendCreateAudioIPCConnection rejected: %d", int(aReason)));
});
}
#endif
@ -469,12 +474,17 @@ cubeb* GetCubebContextUnlocked() {
("%s: %s", PREF_CUBEB_SANDBOX, sCubebSandbox ? "true" : "false"));
if (sCubebSandbox) {
if (XRE_IsParentProcess()) {
if (XRE_IsParentProcess() && !sIPCConnection) {
// TODO: Don't use audio IPC when within the same process.
MOZ_ASSERT(!sIPCConnection);
sIPCConnection = new ipc::FileDescriptor(CreateAudioIPCConnection());
} else {
MOZ_DIAGNOSTIC_ASSERT(sIPCConnection);
auto fd = CreateAudioIPCConnection();
if (fd.IsValid()) {
sIPCConnection = new ipc::FileDescriptor(fd);
}
}
if (NS_WARN_IF(!sIPCConnection)) {
// Either the IPC connection failed to init or we're still waiting for
// InitAudioIPCConnection to complete (bug 1454782).
return nullptr;
}
AudioIpcInitParams initParams;