Bug 1885489 - Part 5: Add SnapshotIterator::readInt32(). r=iain
[gecko.git] / dom / midi / MIDIInput.h
blob72458457a0d88ab01ffd84fed6a63b5872ca475e
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/. */
7 #ifndef mozilla_dom_MIDIInput_h
8 #define mozilla_dom_MIDIInput_h
10 #include "mozilla/dom/MIDIPort.h"
12 struct JSContext;
14 namespace mozilla::dom {
16 class MIDIPortInfo;
18 /**
19 * Represents a MIDI Input Port, handles generating incoming message events.
22 class MIDIInput final : public MIDIPort {
23 public:
24 static RefPtr<MIDIInput> Create(nsPIDOMWindowInner* aWindow,
25 MIDIAccess* aMIDIAccessParent,
26 const MIDIPortInfo& aPortInfo,
27 const bool aSysexEnabled);
28 ~MIDIInput() = default;
30 JSObject* WrapObject(JSContext* aCx,
31 JS::Handle<JSObject*> aGivenProto) override;
33 IMPL_EVENT_HANDLER(midimessage);
35 void StateChange() override;
36 void EventListenerAdded(nsAtom* aType) override;
37 void DisconnectFromOwner() override;
39 private:
40 explicit MIDIInput(nsPIDOMWindowInner* aWindow);
41 // Takes an array of IPC MIDIMessage objects and turns them into
42 // MIDIMessageEvents, which it then fires.
43 void Receive(const nsTArray<MIDIMessage>& aMsgs) override;
45 void KeepAliveOnMidimessage();
46 void DontKeepAliveOnMidimessage();
48 // If true this object will be kept alive even without direct JS references
49 bool mKeepAlive;
52 } // namespace mozilla::dom
54 #endif // mozilla_dom_MIDIInput_h