1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_dom_MIDIPortChild_h
8 #define mozilla_dom_MIDIPortChild_h
9 
10 #include "mozilla/dom/PMIDIPortChild.h"
11 #include "mozilla/dom/MIDIPortInterface.h"
12 
13 namespace mozilla::dom {
14 
15 class MIDIPort;
16 class MIDIPortInfo;
17 
18 /**
19  * Child actor for a MIDIPort object. Each MIDIPort DOM object in JS has a its
20  * own child actor. The lifetime of the actor object is dependent on the
21  * lifetime of the JS object.
22  *
23  */
24 class MIDIPortChild final : public PMIDIPortChild, public MIDIPortInterface {
25  public:
26   NS_INLINE_DECL_REFCOUNTING(MIDIPortChild);
27   mozilla::ipc::IPCResult RecvReceive(nsTArray<MIDIMessage>&& aMsgs);
28 
29   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
30 
31   mozilla::ipc::IPCResult RecvUpdateStatus(const uint32_t& aDeviceState,
32                                            const uint32_t& aConnectionState);
33 
34   MIDIPortChild(const MIDIPortInfo& aPortInfo, bool aSysexEnabled,
35                 MIDIPort* aPort);
36   // virtual void Shutdown() override;
37   void SetActorAlive();
38 
39   void Teardown();
40 
41  private:
42   ~MIDIPortChild() = default;
43   // Pointer to the DOM object this actor represents. The actor cannot outlive
44   // the DOM object.
45   MIDIPort* mDOMPort;
46   bool mActorWasAlive;
47 };
48 }  // namespace mozilla::dom
49 
50 #endif
51