Bug 1806495 - Make PMIDIPort a top-level protocol. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D165439
This commit is contained in:
Bobby Holley 2023-01-09 17:07:34 +00:00
Родитель aaaf9a1c47
Коммит 86d41b87a0
6 изменённых файлов: 26 добавлений и 13 удалений

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

@ -9,6 +9,7 @@
#include "mozilla/dom/MIDIPortChild.h"
#include "mozilla/dom/MIDIAccess.h"
#include "mozilla/dom/MIDITypes.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/dom/Document.h"
@ -77,7 +78,16 @@ bool MIDIPort::Initialize(const MIDIPortInfo& aPortInfo, bool aSysexEnabled) {
MOZ_ASSERT(b,
"Should always have a valid BackgroundChild when creating a port "
"object!");
if (!b->SendPMIDIPortConstructor(port, aPortInfo, aSysexEnabled)) {
// Create the endpoints and bind the one on the child side.
Endpoint<PMIDIPortParent> parentEndpoint;
Endpoint<PMIDIPortChild> childEndpoint;
MOZ_ALWAYS_SUCCEEDS(
PMIDIPort::CreateEndpoints(&parentEndpoint, &childEndpoint));
MOZ_ALWAYS_TRUE(childEndpoint.Bind(port));
if (!b->SendCreateMIDIPort(std::move(parentEndpoint), aPortInfo,
aSysexEnabled)) {
return false;
}
mPortHolder.Init(port.forget());

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

@ -58,7 +58,7 @@ mozilla::ipc::IPCResult MIDIPortParent::RecvShutdown() {
if (mShuttingDown) {
return IPC_OK();
}
Unused << Send__delete__(this);
Close();
return IPC_OK();
}

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

@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PBackground;
include MIDITypes;
namespace mozilla {
@ -12,7 +11,6 @@ namespace dom {
async protocol PMIDIPort
{
manager PBackground;
parent:
async Shutdown();
async Send(MIDIMessage[] msg);
@ -24,7 +22,6 @@ child:
// Actually takes a MIDIDeviceConnectionState and MIDIPortConnectionState
// respectively.
async UpdateStatus(uint32_t deviceState, uint32_t connectionState);
async __delete__();
};
}

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

@ -1229,13 +1229,19 @@ BackgroundParentImpl::RecvPHttpBackgroundChannelConstructor(
return IPC_OK();
}
already_AddRefed<PMIDIPortParent> BackgroundParentImpl::AllocPMIDIPortParent(
const MIDIPortInfo& aPortInfo, const bool& aSysexEnabled) {
mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateMIDIPort(
Endpoint<PMIDIPortParent>&& aEndpoint, const MIDIPortInfo& aPortInfo,
const bool& aSysexEnabled) {
AssertIsInMainOrSocketProcess();
AssertIsOnBackgroundThread();
if (!aEndpoint.IsValid()) {
return IPC_FAIL(this, "invalid endpoint for MIDIPort");
}
RefPtr<MIDIPortParent> result = new MIDIPortParent(aPortInfo, aSysexEnabled);
return result.forget();
aEndpoint.Bind(result);
return IPC_OK();
}
mozilla::ipc::IPCResult BackgroundParentImpl::RecvCreateMIDIManager(

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

@ -345,8 +345,9 @@ class BackgroundParentImpl : public PBackgroundParent {
mozilla::ipc::IPCResult RecvPClientManagerConstructor(
PClientManagerParent* aActor) override;
already_AddRefed<PMIDIPortParent> AllocPMIDIPortParent(
const MIDIPortInfo& aPortInfo, const bool& aSysexEnabled) override;
mozilla::ipc::IPCResult RecvCreateMIDIPort(
Endpoint<PMIDIPortParent>&& aEndpoint, const MIDIPortInfo& aPortInfo,
const bool& aSysexEnabled) override;
mozilla::ipc::IPCResult RecvCreateMIDIManager(
Endpoint<PMIDIManagerParent>&& aEndpoint) override;

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

@ -120,7 +120,6 @@ sync protocol PBackground
manages PFileCreator;
manages PMessagePort;
manages PCameras;
manages PMIDIPort;
manages PQuota;
manages PSelectTLSClientAuthCert;
manages PServiceWorker;
@ -265,8 +264,8 @@ parent:
async PClientManager();
async CreateMIDIManager(Endpoint<PMIDIManagerParent> aEndpoint);
async PMIDIPort(MIDIPortInfo portInfo, bool sysexEnabled);
async CreateMIDIPort(Endpoint<PMIDIPortParent> aEndpoint,
MIDIPortInfo portInfo, bool sysexEnabled);
async HasMIDIDevice() returns (bool hasDevice);
// This method is used to propagate storage activities from the child actor