/src/mozilla-central/dom/midi/MIDIPortChild.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | #include "mozilla/dom/MIDIPortChild.h" |
8 | | #include "mozilla/dom/MIDIPort.h" |
9 | | #include "mozilla/dom/MIDIPortInterface.h" |
10 | | |
11 | | using namespace mozilla; |
12 | | using namespace mozilla::dom; |
13 | | |
14 | | MIDIPortChild::MIDIPortChild(const MIDIPortInfo& aPortInfo, bool aSysexEnabled, MIDIPort* aPort) : |
15 | | MIDIPortInterface(aPortInfo, aSysexEnabled), |
16 | | mDOMPort(aPort), |
17 | | mActorWasAlive(false) |
18 | 0 | { |
19 | 0 | } |
20 | | |
21 | | void |
22 | | MIDIPortChild::Teardown() |
23 | 0 | { |
24 | 0 | if (mDOMPort) { |
25 | 0 | mDOMPort->UnsetIPCPort(); |
26 | 0 | mDOMPort = nullptr; |
27 | 0 | } |
28 | 0 | MIDIPortInterface::Shutdown(); |
29 | 0 | } |
30 | | |
31 | | void |
32 | | MIDIPortChild::ActorDestroy(ActorDestroyReason aWhy) |
33 | 0 | { |
34 | 0 | } |
35 | | |
36 | | mozilla::ipc::IPCResult |
37 | | MIDIPortChild::RecvReceive(nsTArray<MIDIMessage>&& aMsgs) |
38 | 0 | { |
39 | 0 | if (mDOMPort) { |
40 | 0 | mDOMPort->Receive(aMsgs); |
41 | 0 | } |
42 | 0 | return IPC_OK(); |
43 | 0 | } |
44 | | |
45 | | mozilla::ipc::IPCResult |
46 | | MIDIPortChild::RecvUpdateStatus(const uint32_t& aDeviceState, const uint32_t& aConnectionState) |
47 | 0 | { |
48 | 0 | // Either a device is connected, and can have any connection state, or a |
49 | 0 | // device is disconnected, and can only be closed or pending. |
50 | 0 | MOZ_ASSERT(mDeviceState == MIDIPortDeviceState::Connected || |
51 | 0 | (mConnectionState == MIDIPortConnectionState::Closed || |
52 | 0 | mConnectionState == MIDIPortConnectionState::Pending)); |
53 | 0 | mDeviceState = static_cast<MIDIPortDeviceState>(aDeviceState); |
54 | 0 | mConnectionState = static_cast<MIDIPortConnectionState>(aConnectionState); |
55 | 0 | if (mDOMPort) { |
56 | 0 | mDOMPort->FireStateChangeEvent(); |
57 | 0 | } |
58 | 0 | return IPC_OK(); |
59 | 0 | } |
60 | | |
61 | | void |
62 | | MIDIPortChild::SetActorAlive() |
63 | 0 | { |
64 | 0 | MOZ_ASSERT(!mActorWasAlive); |
65 | 0 | mActorWasAlive = true; |
66 | 0 | AddRef(); |
67 | 0 | } |