зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1658419 - Change PGamepadEventChannelParent to have a constructor r=handyman
PGamepadEventChannelParent will need to send an async message back to the child with info about the new shared memory region upon creation. The IPDL channel is not ready during allocation, so we need to defer registering the actor with GamepadPlatformService until the IPDL "RecvConstructor" message so the channel will be available. This is just a straight refactor to prepare for the upcoming change. Differential Revision: https://phabricator.services.mozilla.com/D105127
This commit is contained in:
Родитель
fb50e372a9
Коммит
0c5f377529
|
@ -44,23 +44,25 @@ GamepadEventChannelParent::Create() {
|
|||
.forget();
|
||||
}
|
||||
|
||||
GamepadEventChannelParent::GamepadEventChannelParent() : mIsShutdown{false} {
|
||||
GamepadEventChannelParent::GamepadEventChannelParent() {
|
||||
MOZ_DIAGNOSTIC_ASSERT(IsOnBackgroundThread());
|
||||
|
||||
mBackgroundEventTarget = GetCurrentEventTarget();
|
||||
}
|
||||
|
||||
bool GamepadEventChannelParent::ActorInit() {
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<GamepadPlatformService> service =
|
||||
GamepadPlatformService::GetParentService();
|
||||
MOZ_ASSERT(service);
|
||||
|
||||
service->AddChannelParent(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GamepadEventChannelParent::ActorDestroy(ActorDestroyReason aWhy) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(IsOnBackgroundThread());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mIsShutdown);
|
||||
|
||||
mIsShutdown = true;
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
RefPtr<GamepadPlatformService> service =
|
||||
GamepadPlatformService::GetParentService();
|
||||
|
|
|
@ -16,6 +16,8 @@ class GamepadEventChannelParent final : public PGamepadEventChannelParent {
|
|||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GamepadEventChannelParent, override)
|
||||
|
||||
static already_AddRefed<GamepadEventChannelParent> Create();
|
||||
|
||||
bool ActorInit();
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
mozilla::ipc::IPCResult RecvVibrateHaptic(
|
||||
|
@ -41,7 +43,6 @@ class GamepadEventChannelParent final : public PGamepadEventChannelParent {
|
|||
GamepadEventChannelParent();
|
||||
~GamepadEventChannelParent() = default;
|
||||
|
||||
bool mIsShutdown;
|
||||
nsCOMPtr<nsIEventTarget> mBackgroundEventTarget;
|
||||
};
|
||||
|
||||
|
|
|
@ -1166,6 +1166,16 @@ BackgroundParentImpl::AllocPGamepadEventChannelParent() {
|
|||
return dom::GamepadEventChannelParent::Create();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
BackgroundParentImpl::RecvPGamepadEventChannelConstructor(
|
||||
PGamepadEventChannelParent* actor) {
|
||||
if (!static_cast<mozilla::dom::GamepadEventChannelParent*>(actor)
|
||||
->ActorInit()) {
|
||||
return IPC_FAIL(this, "ActorInit failed");
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
already_AddRefed<dom::PGamepadTestChannelParent>
|
||||
BackgroundParentImpl::AllocPGamepadTestChannelParent() {
|
||||
return dom::GamepadTestChannelParent::Create();
|
||||
|
|
|
@ -328,6 +328,9 @@ class BackgroundParentImpl : public PBackgroundParent,
|
|||
already_AddRefed<PGamepadEventChannelParent> AllocPGamepadEventChannelParent()
|
||||
override;
|
||||
|
||||
mozilla::ipc::IPCResult RecvPGamepadEventChannelConstructor(
|
||||
PGamepadEventChannelParent* actor) override;
|
||||
|
||||
already_AddRefed<PGamepadTestChannelParent> AllocPGamepadTestChannelParent()
|
||||
override;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче