Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #include "GamepadTestChannelChild.h"
6 :
7 : namespace mozilla {
8 : namespace dom {
9 :
10 : void
11 0 : GamepadTestChannelChild::AddPromise(const uint32_t& aID, Promise* aPromise)
12 : {
13 0 : MOZ_ASSERT(!mPromiseList.Get(aID, nullptr));
14 0 : mPromiseList.Put(aID, aPromise);
15 0 : }
16 :
17 : mozilla::ipc::IPCResult
18 0 : GamepadTestChannelChild::RecvReplyGamepadIndex(const uint32_t& aID,
19 : const uint32_t& aIndex)
20 : {
21 0 : RefPtr<Promise> p;
22 0 : if (!mPromiseList.Get(aID, getter_AddRefs(p))) {
23 0 : MOZ_CRASH("We should always have a promise.");
24 : }
25 :
26 0 : p->MaybeResolve(aIndex);
27 0 : mPromiseList.Remove(aID);
28 0 : return IPC_OK();
29 : }
30 :
31 : } // namespace dom
32 : } // namespace mozilla
|