Backed out 4 changesets (bug 1657404) for perma failures on GamepadPlatformService.cpp. CLOSED TREE

Backed out changeset a79143c550d7 (bug 1657404)
Backed out changeset ae904c76b6cc (bug 1657404)
Backed out changeset b225f6a01afe (bug 1657404)
Backed out changeset e6e1924fb688 (bug 1657404)
This commit is contained in:
Razvan Maries 2020-10-09 21:56:28 +03:00
Родитель 824fb768e1
Коммит ea34810caa
11 изменённых файлов: 78 добавлений и 52 удалений

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

@ -71,17 +71,16 @@ void GamepadServiceTest::InitPBackgroundActor() {
MOZ_CRASH("Failed to create a PBackgroundChild actor!");
}
mChild = GamepadTestChannelChild::Create();
mChild = new GamepadTestChannelChild();
PGamepadTestChannelChild* initedChild =
actor->SendPGamepadTestChannelConstructor(mChild.get());
actor->SendPGamepadTestChannelConstructor(mChild);
if (NS_WARN_IF(!initedChild)) {
MOZ_CRASH("Failed to create a PBackgroundChild actor!");
}
}
void GamepadServiceTest::DestroyPBackgroundActor() {
MOZ_ASSERT(mChild);
PGamepadTestChannelChild::Send__delete__(mChild);
mChild->SendShutdownChannel();
mChild = nullptr;
}

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

@ -70,7 +70,7 @@ class GamepadServiceTest final : public DOMEventTargetHelper {
// IPDL Channel for us to send test events to GamepadPlatformService, it
// will only be used in this singleton class and deleted during the IPDL
// shutdown chain
RefPtr<GamepadTestChannelChild> mChild;
GamepadTestChannelChild* MOZ_NON_OWNING_REF mChild;
explicit GamepadServiceTest(nsPIDOMWindowInner* aWindow);
~GamepadServiceTest();

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

@ -9,11 +9,6 @@
namespace mozilla {
namespace dom {
already_AddRefed<GamepadTestChannelChild> GamepadTestChannelChild::Create() {
return RefPtr<GamepadTestChannelChild>(new GamepadTestChannelChild())
.forget();
}
void GamepadTestChannelChild::AddPromise(const uint32_t& aID,
Promise* aPromise) {
MOZ_ASSERT(!mPromiseList.Get(aID, nullptr));

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

@ -14,28 +14,18 @@ namespace mozilla {
namespace dom {
class GamepadTestChannelChild final : public PGamepadTestChannelChild {
friend class PGamepadTestChannelChild;
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GamepadTestChannelChild)
static already_AddRefed<GamepadTestChannelChild> Create();
void AddPromise(const uint32_t& aID, Promise* aPromise);
GamepadTestChannelChild(const GamepadTestChannelChild&) = delete;
GamepadTestChannelChild(GamepadTestChannelChild&&) = delete;
GamepadTestChannelChild& operator=(const GamepadTestChannelChild&) = delete;
GamepadTestChannelChild& operator=(GamepadTestChannelChild&&) = delete;
private:
GamepadTestChannelChild() = default;
~GamepadTestChannelChild() = default;
void AddPromise(const uint32_t& aID, Promise* aPromise);
private:
mozilla::ipc::IPCResult RecvReplyGamepadIndex(const uint32_t& aID,
const uint32_t& aIndex);
nsRefPtrHashtable<nsUint32HashKey, dom::Promise> mPromiseList;
friend class PGamepadTestChannelChild;
};
} // namespace dom

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

@ -12,21 +12,18 @@
namespace mozilla {
namespace dom {
already_AddRefed<GamepadTestChannelParent> GamepadTestChannelParent::Create() {
return RefPtr<GamepadTestChannelParent>(new GamepadTestChannelParent())
.forget();
}
GamepadTestChannelParent::GamepadTestChannelParent() {
bool GamepadTestChannelParent::Init() {
AssertIsOnBackgroundThread();
RefPtr<GamepadPlatformService> service =
GamepadPlatformService::GetParentService();
MOZ_ASSERT(service);
service->GetMonitoringState().AddObserver(this);
return true;
}
GamepadTestChannelParent::~GamepadTestChannelParent() {
void GamepadTestChannelParent::ActorDestroy(ActorDestroyReason aWhy) {
AssertIsOnBackgroundThread();
RefPtr<GamepadPlatformService> service =
GamepadPlatformService::GetParentService();
@ -50,8 +47,9 @@ void GamepadTestChannelParent::AddGamepadToPlatformService(
gamepadID.get(), static_cast<GamepadMappingType>(a.mapping()), a.hand(),
a.num_buttons(), a.num_axes(), a.num_haptics(), a.num_lights(),
a.num_touches());
Unused << SendReplyGamepadIndex(aPromiseId, index);
if (!mShuttingdown) {
Unused << SendReplyGamepadIndex(aPromiseId, index);
}
}
void GamepadTestChannelParent::OnMonitoringStateChanged(bool aNewState) {
@ -125,5 +123,11 @@ mozilla::ipc::IPCResult GamepadTestChannelParent::RecvGamepadTestEvent(
return IPC_FAIL_NO_REASON(this);
}
mozilla::ipc::IPCResult GamepadTestChannelParent::RecvShutdownChannel() {
mShuttingdown = true;
Unused << Send__delete__(this);
return IPC_OK();
}
} // namespace dom
} // namespace mozilla

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

@ -17,31 +17,24 @@ class GamepadTestChannelParent final : public PGamepadTestChannelParent,
public SupportsWeakPtr {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GamepadTestChannelParent)
static already_AddRefed<GamepadTestChannelParent> Create();
GamepadTestChannelParent() : mShuttingdown(false) {}
bool Init();
void ActorDestroy(ActorDestroyReason aWhy) override;
mozilla::ipc::IPCResult RecvGamepadTestEvent(
const uint32_t& aID, const GamepadChangeEvent& aGamepadEvent);
mozilla::ipc::IPCResult RecvShutdownChannel();
void OnMonitoringStateChanged(bool aNewState);
GamepadTestChannelParent(const GamepadTestChannelParent&) = delete;
GamepadTestChannelParent(GamepadTestChannelParent&&) = delete;
GamepadTestChannelParent& operator=(const GamepadTestChannelParent&) = delete;
GamepadTestChannelParent& operator=(GamepadTestChannelParent&&) = delete;
private:
struct DeferredGamepadAdded {
uint32_t promiseId;
GamepadAdded gamepadAdded;
};
GamepadTestChannelParent();
~GamepadTestChannelParent();
void AddGamepadToPlatformService(uint32_t aPromiseId,
const GamepadAdded& aGamepadAdded);
~GamepadTestChannelParent() = default;
bool mShuttingdown;
nsTArray<DeferredGamepadAdded> mDeferredGamepadAdded;
};

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

@ -7,12 +7,13 @@ include GamepadEventTypes;
namespace mozilla {
namespace dom {
refcounted protocol PGamepadTestChannel {
async protocol PGamepadTestChannel {
manager PBackground;
parent:
async GamepadTestEvent(uint32_t aID, GamepadChangeEvent aGamepadEvent);
async __delete__();
async ShutdownChannel();
child:
async __delete__();
async ReplyGamepadIndex(uint32_t aID, uint32_t aIndex);
};

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

@ -619,6 +619,19 @@ bool BackgroundChildImpl::DeallocPGamepadEventChannelChild(
return true;
}
dom::PGamepadTestChannelChild*
BackgroundChildImpl::AllocPGamepadTestChannelChild() {
MOZ_CRASH("PGamepadTestChannelChild actor should be manually constructed!");
return nullptr;
}
bool BackgroundChildImpl::DeallocPGamepadTestChannelChild(
PGamepadTestChannelChild* aActor) {
MOZ_ASSERT(aActor);
delete static_cast<dom::GamepadTestChannelChild*>(aActor);
return true;
}
mozilla::dom::PClientManagerChild*
BackgroundChildImpl::AllocPClientManagerChild() {
return mozilla::dom::AllocClientManagerChild();

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

@ -229,6 +229,11 @@ class BackgroundChildImpl : public PBackgroundChild,
virtual bool DeallocPGamepadEventChannelChild(
PGamepadEventChannelChild* aActor) override;
virtual PGamepadTestChannelChild* AllocPGamepadTestChannelChild() override;
virtual bool DeallocPGamepadTestChannelChild(
PGamepadTestChannelChild* aActor) override;
virtual PClientManagerChild* AllocPClientManagerChild() override;
virtual bool DeallocPClientManagerChild(PClientManagerChild* aActor) override;

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

@ -1120,9 +1120,30 @@ BackgroundParentImpl::RecvPGamepadEventChannelConstructor(
return IPC_OK();
}
already_AddRefed<dom::PGamepadTestChannelParent>
dom::PGamepadTestChannelParent*
BackgroundParentImpl::AllocPGamepadTestChannelParent() {
return dom::GamepadTestChannelParent::Create();
RefPtr<dom::GamepadTestChannelParent> parent =
new dom::GamepadTestChannelParent();
return parent.forget().take();
}
mozilla::ipc::IPCResult
BackgroundParentImpl::RecvPGamepadTestChannelConstructor(
PGamepadTestChannelParent* aActor) {
MOZ_ASSERT(aActor);
if (!static_cast<dom::GamepadTestChannelParent*>(aActor)->Init()) {
return IPC_FAIL_NO_REASON(this);
}
return IPC_OK();
}
bool BackgroundParentImpl::DeallocPGamepadTestChannelParent(
dom::PGamepadTestChannelParent* aActor) {
MOZ_ASSERT(aActor);
RefPtr<dom::GamepadTestChannelParent> parent =
dont_AddRef(static_cast<dom::GamepadTestChannelParent*>(aActor));
return true;
}
dom::PWebAuthnTransactionParent*

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

@ -332,8 +332,13 @@ class BackgroundParentImpl : public PBackgroundParent,
virtual mozilla::ipc::IPCResult RecvPGamepadEventChannelConstructor(
PGamepadEventChannelParent* aActor) override;
virtual already_AddRefed<PGamepadTestChannelParent>
AllocPGamepadTestChannelParent() override;
virtual PGamepadTestChannelParent* AllocPGamepadTestChannelParent() override;
virtual mozilla::ipc::IPCResult RecvPGamepadTestChannelConstructor(
PGamepadTestChannelParent* aActor) override;
virtual bool DeallocPGamepadTestChannelParent(
PGamepadTestChannelParent* aActor) override;
virtual PWebAuthnTransactionParent* AllocPWebAuthnTransactionParent()
override;