Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1234)

Unified Diff: Source/modules/webmidi/MIDIAccess.cpp

Issue 513203002: Introduce MIDIInputMap and MIDIOutputMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@iterator-adhoc
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/webmidi/MIDIAccess.h ('k') | Source/modules/webmidi/MIDIAccess.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webmidi/MIDIAccess.cpp
diff --git a/Source/modules/webmidi/MIDIAccess.cpp b/Source/modules/webmidi/MIDIAccess.cpp
index d0a733c1b36de4dade5bba329e1ed5ec20b4167d..5f89be9a40a798c8ce169443dfd1ccb01aff397e 100644
--- a/Source/modules/webmidi/MIDIAccess.cpp
+++ b/Source/modules/webmidi/MIDIAccess.cpp
@@ -37,7 +37,11 @@
#include "modules/webmidi/MIDIAccessInitializer.h"
#include "modules/webmidi/MIDIConnectionEvent.h"
#include "modules/webmidi/MIDIController.h"
+#include "modules/webmidi/MIDIInput.h"
+#include "modules/webmidi/MIDIInputMap.h"
#include "modules/webmidi/MIDIOptions.h"
+#include "modules/webmidi/MIDIOutput.h"
+#include "modules/webmidi/MIDIOutputMap.h"
#include "modules/webmidi/MIDIPort.h"
#include "platform/AsyncMethodRunner.h"
#include <v8.h>
@@ -65,6 +69,34 @@ MIDIAccess::~MIDIAccess()
{
}
+MIDIInputMap* MIDIAccess::inputs() const
+{
+ HeapHashMap<String, Member<MIDIInput> > inputs;
+ for (size_t i = 0; i < m_inputs.size(); ++i) {
+ MIDIInput* input = m_inputs[i];
+ inputs.add(input->id(), input);
+ }
+ if (inputs.size() != m_inputs.size()) {
+ // There is id duplication that violates the spec.
+ inputs.clear();
+ }
+ return new MIDIInputMap(inputs);
+}
+
+MIDIOutputMap* MIDIAccess::outputs() const
+{
+ HeapHashMap<String, Member<MIDIOutput> > outputs;
+ for (size_t i = 0; i < m_outputs.size(); ++i) {
+ MIDIOutput* output = m_outputs[i];
+ outputs.add(output->id(), output);
+ }
+ if (outputs.size() != m_outputs.size()) {
+ // There is id duplication that violates the spec.
+ outputs.clear();
+ }
+ return new MIDIOutputMap(outputs);
+}
+
void MIDIAccess::didAddInputPort(const String& id, const String& manufacturer, const String& name, const String& version)
{
ASSERT(isMainThread());
« no previous file with comments | « Source/modules/webmidi/MIDIAccess.h ('k') | Source/modules/webmidi/MIDIAccess.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698