File tree 5 files changed +25
-8
lines changed
5 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -71,9 +71,10 @@ void GamepadServiceTest::InitPBackgroundActor() {
71
71
MOZ_CRASH (" Failed to create a PBackgroundChild actor!" );
72
72
}
73
73
74
- mChild = new GamepadTestChannelChild ();
74
+ mChild = GamepadTestChannelChild::Create ();
75
75
PGamepadTestChannelChild* initedChild =
76
- actor->SendPGamepadTestChannelConstructor (mChild );
76
+ actor->SendPGamepadTestChannelConstructor (
77
+ RefPtr<GamepadTestChannelChild>(mChild ).forget ().take ());
77
78
if (NS_WARN_IF(!initedChild)) {
78
79
MOZ_CRASH (" Failed to create a PBackgroundChild actor!" );
79
80
}
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ class GamepadServiceTest final : public DOMEventTargetHelper {
70
70
// IPDL Channel for us to send test events to GamepadPlatformService, it
71
71
// will only be used in this singleton class and deleted during the IPDL
72
72
// shutdown chain
73
- GamepadTestChannelChild* MOZ_NON_OWNING_REF mChild ;
73
+ RefPtr< GamepadTestChannelChild> mChild ;
74
74
75
75
explicit GamepadServiceTest (nsPIDOMWindowInner* aWindow);
76
76
~GamepadServiceTest ();
Original file line number Diff line number Diff line change 9
9
namespace mozilla {
10
10
namespace dom {
11
11
12
+ already_AddRefed<GamepadTestChannelChild> GamepadTestChannelChild::Create () {
13
+ return RefPtr<GamepadTestChannelChild>(new GamepadTestChannelChild ())
14
+ .forget ();
15
+ }
16
+
12
17
void GamepadTestChannelChild::AddPromise (const uint32_t & aID,
13
18
Promise* aPromise) {
14
19
MOZ_ASSERT (!mPromiseList .Get (aID, nullptr ));
Original file line number Diff line number Diff line change @@ -14,18 +14,28 @@ namespace mozilla {
14
14
namespace dom {
15
15
16
16
class GamepadTestChannelChild final : public PGamepadTestChannelChild {
17
- friend class PGamepadTestChannelChild ;
18
-
19
17
public:
20
- GamepadTestChannelChild () = default ;
21
- ~GamepadTestChannelChild () = default ;
18
+ NS_INLINE_DECL_THREADSAFE_REFCOUNTING (GamepadTestChannelChild)
19
+
20
+ static already_AddRefed<GamepadTestChannelChild> Create ();
21
+
22
22
void AddPromise (const uint32_t & aID, Promise* aPromise);
23
23
24
+ GamepadTestChannelChild (const GamepadTestChannelChild&) = delete ;
25
+ GamepadTestChannelChild (GamepadTestChannelChild&&) = delete ;
26
+ GamepadTestChannelChild& operator =(const GamepadTestChannelChild&) = delete ;
27
+ GamepadTestChannelChild& operator =(GamepadTestChannelChild&&) = delete ;
28
+
24
29
private:
30
+ GamepadTestChannelChild () = default ;
31
+ ~GamepadTestChannelChild () = default ;
32
+
25
33
mozilla::ipc::IPCResult RecvReplyGamepadIndex (const uint32_t & aID,
26
34
const uint32_t & aIndex);
27
35
28
36
nsRefPtrHashtable<nsUint32HashKey, dom::Promise> mPromiseList ;
37
+
38
+ friend class PGamepadTestChannelChild ;
29
39
};
30
40
31
41
} // namespace dom
Original file line number Diff line number Diff line change @@ -628,7 +628,8 @@ BackgroundChildImpl::AllocPGamepadTestChannelChild() {
628
628
bool BackgroundChildImpl::DeallocPGamepadTestChannelChild (
629
629
PGamepadTestChannelChild* aActor) {
630
630
MOZ_ASSERT (aActor);
631
- delete static_cast <dom::GamepadTestChannelChild*>(aActor);
631
+ RefPtr<dom::GamepadTestChannelChild> child (
632
+ dont_AddRef (static_cast <dom::GamepadTestChannelChild*>(aActor)));
632
633
return true ;
633
634
}
634
635
You can’t perform that action at this time.
0 commit comments