Bug 1657404 - Refactor gamepad monitoring - Part 1 r=daoshengmu

The starting/stopping of gamepad monitoring is probably a decision that
should be made at the level of the GamepadPlatformService, not in the IPC
actor. This is step 1, later I will expand some of these functions because
it makes the code easier to understand.

Differential Revision: https://phabricator.services.mozilla.com/D86266
This commit is contained in:
Chris Martin 2020-08-07 13:32:17 +00:00
parent 492ec9ba2f
commit 1e641f2551
2 changed files with 8 additions and 6 deletions

View File

@ -221,6 +221,8 @@ void GamepadPlatformService::AddChannelParent(
}
FlushPendingEvents();
StartGamepadMonitoring();
}
void GamepadPlatformService::FlushPendingEvents() {
@ -250,8 +252,12 @@ void GamepadPlatformService::RemoveChannelParent(
MOZ_ASSERT(mChannelParents.Contains(aParent));
// We use mutex here to prevent race condition with monitor thread
MutexAutoLock autoLock(mMutex);
mChannelParents.RemoveElement(aParent);
{
MutexAutoLock autoLock(mMutex);
mChannelParents.RemoveElement(aParent);
}
MaybeStopGamepadMonitoring();
}
bool GamepadPlatformService::HasGamepadListeners() {

View File

@ -49,8 +49,6 @@ bool GamepadEventChannelParent::Init() {
service->AddChannelParent(this);
StartGamepadMonitoring();
return true;
}
@ -61,8 +59,6 @@ void GamepadEventChannelParent::ActorDestroy(ActorDestroyReason aWhy) {
GamepadPlatformService::GetParentService();
MOZ_ASSERT(service);
service->RemoveChannelParent(this);
MaybeStopGamepadMonitoring();
}
mozilla::ipc::IPCResult GamepadEventChannelParent::RecvVibrateHaptic(