MIDIPlatformRunnables.cpp (1416B)
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/MIDIPlatformRunnables.h" 8 9 #include "mozilla/dom/MIDIPlatformService.h" 10 #include "mozilla/dom/MIDIPortParent.h" 11 #include "mozilla/ipc/BackgroundParent.h" 12 13 namespace mozilla::dom { 14 15 NS_IMETHODIMP 16 MIDIBackgroundRunnable::Run() { 17 MIDIPlatformService::AssertThread(); 18 if (!MIDIPlatformService::IsRunning()) { 19 return NS_OK; 20 } 21 RunInternal(); 22 return NS_OK; 23 } 24 25 void ReceiveRunnable::RunInternal() { 26 MIDIPlatformService::Get()->CheckAndReceive(mPortId, mMsgs); 27 } 28 29 void AddPortRunnable::RunInternal() { 30 MIDIPlatformService::Get()->AddPortInfo(mPortInfo); 31 } 32 33 void RemovePortRunnable::RunInternal() { 34 MIDIPlatformService::Get()->RemovePortInfo(mPortInfo); 35 } 36 37 void SetStatusRunnable::RunInternal() { 38 MIDIPlatformService::Get()->UpdateStatus(mPort, mState, mConnection); 39 } 40 41 void SendPortListRunnable::RunInternal() { 42 // Unlike other runnables, SendPortListRunnable should just exit quietly if 43 // the service has died. 44 if (!MIDIPlatformService::IsRunning()) { 45 return; 46 } 47 MIDIPlatformService::Get()->SendPortList(); 48 } 49 50 } // namespace mozilla::dom