mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1741568 - Fix all clang-tidy warnings in dom/midi r=padenot
Depends on D131222 Differential Revision: https://phabricator.services.mozilla.com/D131328
This commit is contained in:
parent
2a94618550
commit
41d3d5a176
@ -54,15 +54,15 @@ NS_IMPL_ADDREF_INHERITED(MIDIAccess, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(MIDIAccess, DOMEventTargetHelper)
|
||||
|
||||
MIDIAccess::MIDIAccess(nsPIDOMWindowInner* aWindow, bool aSysexEnabled,
|
||||
Promise* aPromise)
|
||||
Promise* aAccessPromise)
|
||||
: DOMEventTargetHelper(aWindow),
|
||||
mInputMap(new MIDIInputMap(aWindow)),
|
||||
mOutputMap(new MIDIOutputMap(aWindow)),
|
||||
mSysexEnabled(aSysexEnabled),
|
||||
mAccessPromise(aPromise),
|
||||
mAccessPromise(aAccessPromise),
|
||||
mHasShutdown(false) {
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(aPromise);
|
||||
MOZ_ASSERT(aAccessPromise);
|
||||
}
|
||||
|
||||
MIDIAccess::~MIDIAccess() { Shutdown(); }
|
||||
@ -190,7 +190,7 @@ void MIDIAccess::MaybeCreateMIDIPort(const MIDIPortInfo& aInfo,
|
||||
// received, that will be handled by the MIDIPort object itself, and it will
|
||||
// request removal from MIDIAccess's maps.
|
||||
void MIDIAccess::Notify(const MIDIPortList& aEvent) {
|
||||
for (auto& port : aEvent.ports()) {
|
||||
for (const auto& port : aEvent.ports()) {
|
||||
// Something went very wrong. Warn and return.
|
||||
ErrorResult rv;
|
||||
MaybeCreateMIDIPort(port, rv);
|
||||
|
@ -35,7 +35,7 @@ class MIDIPortInfo;
|
||||
class MIDIPortList;
|
||||
class Promise;
|
||||
|
||||
typedef Observer<void_t> MIDIAccessDestructionObserver;
|
||||
using MIDIAccessDestructionObserver = Observer<void_t>;
|
||||
|
||||
/**
|
||||
* MIDIAccess is the DOM object that is handed to the user upon MIDI permissions
|
||||
@ -76,7 +76,7 @@ class MIDIAccess final : public DOMEventTargetHelper,
|
||||
// created them, as the port object receives disconnection events which then
|
||||
// must be passed up to the MIDIAccess object. If the Port object dies before
|
||||
// the MIDIAccess object, it needs to be removed from the observer list.
|
||||
void RemovePortListener(MIDIAccessDestructionObserver* aPort);
|
||||
void RemovePortListener(MIDIAccessDestructionObserver* aObs);
|
||||
|
||||
// Fires DOM event on port connection/disconnection
|
||||
void FireConnectionEvent(MIDIPort* aPort);
|
||||
|
@ -11,8 +11,7 @@
|
||||
#include "mozilla/dom/MIDITypes.h"
|
||||
#include "mozilla/Observer.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
class MIDIAccess;
|
||||
class MIDIManagerChild;
|
||||
@ -46,7 +45,7 @@ class MIDIAccessManager final {
|
||||
// True if manager singleton has been created
|
||||
static bool IsRunning();
|
||||
// Send device connection updates to all known MIDIAccess objects.
|
||||
void Update(const MIDIPortList& aEvent);
|
||||
void Update(const MIDIPortList& aPortList);
|
||||
// Adds a device update observer (usually a MIDIAccess object)
|
||||
bool AddObserver(Observer<MIDIPortList>* aObserver);
|
||||
// Removes a device update observer (usually a MIDIAccess object)
|
||||
@ -69,7 +68,6 @@ class MIDIAccessManager final {
|
||||
RefPtr<MIDIManagerChild> mChild;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIAccessManager_h
|
||||
|
@ -24,7 +24,7 @@ MIDIInput* MIDIInput::Create(nsPIDOMWindowInner* aWindow,
|
||||
const bool aSysexEnabled) {
|
||||
MOZ_ASSERT(static_cast<MIDIPortType>(aPortInfo.type()) ==
|
||||
MIDIPortType::Input);
|
||||
auto port = new MIDIInput(aWindow, aMIDIAccessParent);
|
||||
auto* port = new MIDIInput(aWindow, aMIDIAccessParent);
|
||||
if (!port->Initialize(aPortInfo, aSysexEnabled)) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -42,7 +42,7 @@ void MIDIInput::Receive(const nsTArray<MIDIMessage>& aMsgs) {
|
||||
NS_WARNING("No document available to send MIDIMessageEvent to!");
|
||||
return;
|
||||
}
|
||||
for (auto& msg : aMsgs) {
|
||||
for (const auto& msg : aMsgs) {
|
||||
RefPtr<MIDIMessageEvent> event(
|
||||
MIDIMessageEvent::Constructor(this, msg.timestamp(), msg.data()));
|
||||
DispatchTrustedEvent(event);
|
||||
|
@ -11,8 +11,7 @@
|
||||
|
||||
struct JSContext;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
class MIDIPortInfo;
|
||||
|
||||
@ -47,7 +46,6 @@ class MIDIInput final : public MIDIPort {
|
||||
void Receive(const nsTArray<MIDIMessage>& aMsgs) override;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIInput_h
|
||||
|
@ -12,8 +12,7 @@
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
/**
|
||||
* Maplike DOM object that holds a list of all MIDI input ports available for
|
||||
@ -34,7 +33,6 @@ class MIDIInputMap final : public nsISupports, public nsWrapperCache {
|
||||
nsCOMPtr<nsPIDOMWindowInner> mParent;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIInputMap_h
|
||||
|
@ -9,8 +9,7 @@
|
||||
|
||||
#include "mozilla/dom/PMIDIManagerChild.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
/**
|
||||
* Actor implementation for the Child side of MIDIManager (represented in DOM by
|
||||
@ -33,7 +32,6 @@ class MIDIManagerChild final : public PMIDIManagerChild {
|
||||
bool mShutdown;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIManagerChild_h
|
||||
|
@ -9,8 +9,7 @@
|
||||
|
||||
#include "mozilla/dom/PMIDIManagerParent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
/**
|
||||
* Actor implementation for the Parent (PBackground thread) side of MIDIManager
|
||||
@ -30,7 +29,6 @@ class MIDIManagerParent final : public PMIDIManagerParent {
|
||||
~MIDIManagerParent() = default;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIManagerParent_h
|
||||
|
@ -19,8 +19,7 @@
|
||||
#include "nsTArray.h"
|
||||
|
||||
struct JSContext;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
struct MIDIMessageEventInit;
|
||||
|
||||
/**
|
||||
@ -58,7 +57,6 @@ class MIDIMessageEvent final : public Event {
|
||||
nsTArray<uint8_t> mRawData;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIMessageEvent_h
|
||||
|
@ -35,9 +35,9 @@ class MIDIMessageQueue {
|
||||
void Add(nsTArray<MIDIMessage>& aMsg);
|
||||
// Retrieve all pending messages before the time specified.
|
||||
void GetMessagesBefore(TimeStamp aTimestamp,
|
||||
nsTArray<MIDIMessage>& aMsgArray);
|
||||
nsTArray<MIDIMessage>& aMsgQueue);
|
||||
// Get all pending messages.
|
||||
void GetMessages(nsTArray<MIDIMessage>& aMsgArray);
|
||||
void GetMessages(nsTArray<MIDIMessage>& aMsgQueue);
|
||||
// Erase all pending messages.
|
||||
void Clear();
|
||||
// Erase all pending messages that would be sent in the future. Useful for
|
||||
|
@ -29,7 +29,7 @@ MIDIOutput* MIDIOutput::Create(nsPIDOMWindowInner* aWindow,
|
||||
const bool aSysexEnabled) {
|
||||
MOZ_ASSERT(static_cast<MIDIPortType>(aPortInfo.type()) ==
|
||||
MIDIPortType::Output);
|
||||
auto port = new MIDIOutput(aWindow, aMIDIAccessParent);
|
||||
auto* port = new MIDIOutput(aWindow, aMIDIAccessParent);
|
||||
if (NS_WARN_IF(!port->Initialize(aPortInfo, aSysexEnabled))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -12,8 +12,7 @@
|
||||
|
||||
class nsPIDOMWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
/**
|
||||
* Maplike DOM object that holds a list of all MIDI output ports available for
|
||||
@ -37,7 +36,6 @@ class MIDIOutputMap final : public nsISupports, public nsWrapperCache {
|
||||
nsCOMPtr<nsPIDOMWindowInner> mParent;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIOutputMap_h
|
||||
|
@ -10,8 +10,7 @@
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
struct MIDIOptions;
|
||||
|
||||
@ -42,7 +41,6 @@ class MIDIPermissionRequest final : public ContentPermissionRequestBase,
|
||||
bool mNeedsSysex;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIPermissionRequest_h
|
||||
|
@ -9,8 +9,7 @@
|
||||
|
||||
#include "mozilla/dom/MIDITypes.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
enum class MIDIPortConnectionState : uint8_t;
|
||||
enum class MIDIPortDeviceState : uint8_t;
|
||||
@ -121,7 +120,6 @@ class SetStatusRunnable final : public MIDIBackgroundRunnable {
|
||||
MIDIPortConnectionState mConnection;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIPlatformRunnables_h
|
||||
|
@ -39,7 +39,7 @@ void MIDIPlatformService::CheckAndReceive(const nsAString& aPortId,
|
||||
}
|
||||
if (!port->SysexEnabled()) {
|
||||
nsTArray<MIDIMessage> msgs;
|
||||
for (auto& msg : aMsgs) {
|
||||
for (const auto& msg : aMsgs) {
|
||||
if (!MIDIUtils::IsSysexMessage(msg)) {
|
||||
msgs.AppendElement(msg);
|
||||
}
|
||||
@ -224,7 +224,7 @@ void MIDIPlatformService::UpdateStatus(
|
||||
const nsAString& aPortId, const MIDIPortDeviceState& aDeviceState,
|
||||
const MIDIPortConnectionState& aConnectionState) {
|
||||
::mozilla::ipc::AssertIsOnBackgroundThread();
|
||||
for (auto port : mPorts) {
|
||||
for (const auto& port : mPorts) {
|
||||
if (port->MIDIPortInterface::Id() == aPortId) {
|
||||
port->SendUpdateStatus(aDeviceState, aConnectionState);
|
||||
}
|
||||
|
@ -16,8 +16,7 @@
|
||||
// file.
|
||||
#include "mozilla/dom/MIDIMessageQueue.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
class MIDIManagerParent;
|
||||
class MIDIPortParent;
|
||||
@ -41,10 +40,10 @@ class MIDIPlatformService {
|
||||
void RemovePortInfo(MIDIPortInfo& aPortInfo);
|
||||
|
||||
// Adds a newly created manager protocol object to manager array.
|
||||
void AddManager(MIDIManagerParent* aParent);
|
||||
void AddManager(MIDIManagerParent* aManager);
|
||||
|
||||
// Removes a deleted manager protocol object from manager array.
|
||||
void RemoveManager(MIDIManagerParent* aParent);
|
||||
void RemoveManager(MIDIManagerParent* aManager);
|
||||
|
||||
// Adds a newly created port protocol object to port array.
|
||||
void AddPort(MIDIPortParent* aPort);
|
||||
@ -156,7 +155,6 @@ class MIDIPlatformService {
|
||||
Mutex mMessageQueueMutex;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIPlatformService_h
|
||||
|
@ -16,8 +16,7 @@
|
||||
|
||||
struct JSContext;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
class Promise;
|
||||
class MIDIPortInfo;
|
||||
@ -91,7 +90,6 @@ class MIDIPort : public DOMEventTargetHelper,
|
||||
RefPtr<Promise> mClosingPromise;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIPort_h
|
||||
|
@ -10,8 +10,7 @@
|
||||
#include "mozilla/dom/PMIDIPortChild.h"
|
||||
#include "mozilla/dom/MIDIPortInterface.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
class MIDIPort;
|
||||
class MIDIPortInfo;
|
||||
@ -46,7 +45,6 @@ class MIDIPortChild final : public PMIDIPortChild, public MIDIPortInterface {
|
||||
MIDIPort* mDOMPort;
|
||||
bool mActorWasAlive;
|
||||
};
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif
|
||||
|
@ -9,8 +9,7 @@
|
||||
|
||||
#include "mozilla/dom/MIDIPortBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
class MIDIPortInfo;
|
||||
/**
|
||||
* Base class for MIDIPort Parent/Child Actors. Makes sure both sides of the
|
||||
@ -44,7 +43,6 @@ class MIDIPortInterface {
|
||||
bool mShuttingDown;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_MIDIPortInterface_h
|
||||
|
@ -12,8 +12,7 @@
|
||||
#include "mozilla/dom/MIDIPortInterface.h"
|
||||
|
||||
// Header file contents
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
/**
|
||||
* Actor representing the parent (PBackground thread) side of a MIDIPort object.
|
||||
@ -32,8 +31,8 @@ class MIDIPortParent final : public PMIDIPortParent, public MIDIPortInterface {
|
||||
const bool aSysexEnabled);
|
||||
// Sends the current port status to the child actor. May also send message
|
||||
// buffer if required.
|
||||
bool SendUpdateStatus(const MIDIPortDeviceState& aState,
|
||||
const MIDIPortConnectionState& aConnection);
|
||||
bool SendUpdateStatus(const MIDIPortDeviceState& aDeviceState,
|
||||
const MIDIPortConnectionState& aConnectionState);
|
||||
uint32_t GetInternalId() const { return mInternalId; }
|
||||
void Teardown();
|
||||
|
||||
@ -45,7 +44,7 @@ class MIDIPortParent final : public PMIDIPortParent, public MIDIPortInterface {
|
||||
nsTArray<MIDIMessage> mMessageQueue;
|
||||
const uint32_t mInternalId;
|
||||
};
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif
|
||||
|
@ -78,7 +78,7 @@ uint32_t ParseMessages(const nsTArray<uint8_t>& aByteBuffer,
|
||||
uint32_t bytesRead = 0;
|
||||
bool inSysexMessage = false;
|
||||
UniquePtr<MIDIMessage> currentMsg;
|
||||
for (auto& byte : aByteBuffer) {
|
||||
for (const auto& byte : aByteBuffer) {
|
||||
bytesRead++;
|
||||
if ((byte & kSystemRealtimeMessage) == kSystemRealtimeMessage) {
|
||||
MIDIMessage rt_msg;
|
||||
@ -116,9 +116,6 @@ bool IsSysexMessage(const MIDIMessage& aMsg) {
|
||||
if (aMsg.data().Length() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (aMsg.data()[0] == kSysexMessageStart) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return aMsg.data()[0] == kSysexMessageStart;
|
||||
}
|
||||
} // namespace mozilla::dom::MIDIUtils
|
||||
|
@ -7,8 +7,7 @@
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
class MIDIMessage;
|
||||
|
||||
/**
|
||||
@ -25,5 +24,4 @@ uint32_t ParseMessages(const nsTArray<uint8_t>& aByteBuffer,
|
||||
// Returns true if a message is a sysex message.
|
||||
bool IsSysexMessage(const MIDIMessage& a);
|
||||
} // namespace MIDIUtils
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
@ -224,7 +224,7 @@ void TestMIDIPlatformService::ProcessMessages(const nsAString& aPortId) {
|
||||
0x04, 0xF9, 0x05, 0xF7};
|
||||
// Can't use AppendElements on an array here, so just do range
|
||||
// based loading.
|
||||
for (auto& s : msg) {
|
||||
for (const auto& s : msg) {
|
||||
msgs.AppendElement(s);
|
||||
}
|
||||
nsTArray<MIDIMessage> newMsgs;
|
||||
|
@ -12,8 +12,7 @@
|
||||
|
||||
class nsIThread;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mozilla::dom {
|
||||
|
||||
class MIDIPortInterface;
|
||||
|
||||
@ -58,7 +57,6 @@ class TestMIDIPlatformService : public MIDIPlatformService {
|
||||
bool mIsInitialized;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif // mozilla_dom_TestMIDIPlatformService_h
|
||||
|
Loading…
Reference in New Issue
Block a user