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!"); MOZ_CRASH("Failed to create a PBackgroundChild actor!");
} }
mChild = GamepadTestChannelChild::Create(); mChild = new GamepadTestChannelChild();
PGamepadTestChannelChild* initedChild = PGamepadTestChannelChild* initedChild =
actor->SendPGamepadTestChannelConstructor(mChild.get()); actor->SendPGamepadTestChannelConstructor(mChild);
if (NS_WARN_IF(!initedChild)) { if (NS_WARN_IF(!initedChild)) {
MOZ_CRASH("Failed to create a PBackgroundChild actor!"); MOZ_CRASH("Failed to create a PBackgroundChild actor!");
} }
} }
void GamepadServiceTest::DestroyPBackgroundActor() { void GamepadServiceTest::DestroyPBackgroundActor() {
MOZ_ASSERT(mChild); mChild->SendShutdownChannel();
PGamepadTestChannelChild::Send__delete__(mChild);
mChild = nullptr; mChild = nullptr;
} }

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -619,6 +619,19 @@ bool BackgroundChildImpl::DeallocPGamepadEventChannelChild(
return true; 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* mozilla::dom::PClientManagerChild*
BackgroundChildImpl::AllocPClientManagerChild() { BackgroundChildImpl::AllocPClientManagerChild() {
return mozilla::dom::AllocClientManagerChild(); return mozilla::dom::AllocClientManagerChild();

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

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

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

@ -1120,9 +1120,30 @@ BackgroundParentImpl::RecvPGamepadEventChannelConstructor(
return IPC_OK(); return IPC_OK();
} }
already_AddRefed<dom::PGamepadTestChannelParent> dom::PGamepadTestChannelParent*
BackgroundParentImpl::AllocPGamepadTestChannelParent() { 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* dom::PWebAuthnTransactionParent*

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

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