| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "modules/webmidi/MIDIInput.h" | 38 #include "modules/webmidi/MIDIInput.h" |
| 39 #include "modules/webmidi/MIDIInputMap.h" | 39 #include "modules/webmidi/MIDIInputMap.h" |
| 40 #include "modules/webmidi/MIDIOutput.h" | 40 #include "modules/webmidi/MIDIOutput.h" |
| 41 #include "modules/webmidi/MIDIOutputMap.h" | 41 #include "modules/webmidi/MIDIOutputMap.h" |
| 42 #include "modules/webmidi/MIDIPort.h" | 42 #include "modules/webmidi/MIDIPort.h" |
| 43 #include "platform/AsyncMethodRunner.h" | 43 #include "platform/AsyncMethodRunner.h" |
| 44 #include <memory> | 44 #include <memory> |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 using PortState = MIDIAccessor::MIDIPortState; | 48 using midi::mojom::PortState; |
| 49 | 49 |
| 50 MIDIAccess::MIDIAccess( | 50 MIDIAccess::MIDIAccess( |
| 51 std::unique_ptr<MIDIAccessor> accessor, | 51 std::unique_ptr<MIDIAccessor> accessor, |
| 52 bool sysexEnabled, | 52 bool sysexEnabled, |
| 53 const Vector<MIDIAccessInitializer::PortDescriptor>& ports, | 53 const Vector<MIDIAccessInitializer::PortDescriptor>& ports, |
| 54 ExecutionContext* executionContext) | 54 ExecutionContext* executionContext) |
| 55 : ActiveScriptWrappable(this), | 55 : ActiveScriptWrappable(this), |
| 56 ActiveDOMObject(executionContext), | 56 ActiveDOMObject(executionContext), |
| 57 m_accessor(std::move(accessor)), | 57 m_accessor(std::move(accessor)), |
| 58 m_sysexEnabled(sysexEnabled), | 58 m_sysexEnabled(sysexEnabled), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 bool MIDIAccess::hasPendingActivity() const { | 90 bool MIDIAccess::hasPendingActivity() const { |
| 91 return m_hasPendingActivity && getExecutionContext() && | 91 return m_hasPendingActivity && getExecutionContext() && |
| 92 !getExecutionContext()->activeDOMObjectsAreStopped(); | 92 !getExecutionContext()->activeDOMObjectsAreStopped(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 MIDIInputMap* MIDIAccess::inputs() const { | 95 MIDIInputMap* MIDIAccess::inputs() const { |
| 96 HeapVector<Member<MIDIInput>> inputs; | 96 HeapVector<Member<MIDIInput>> inputs; |
| 97 HashSet<String> ids; | 97 HashSet<String> ids; |
| 98 for (size_t i = 0; i < m_inputs.size(); ++i) { | 98 for (size_t i = 0; i < m_inputs.size(); ++i) { |
| 99 MIDIInput* input = m_inputs[i]; | 99 MIDIInput* input = m_inputs[i]; |
| 100 if (input->getState() != PortState::MIDIPortStateDisconnected) { | 100 if (input->getState() != PortState::DISCONNECTED) { |
| 101 inputs.append(input); | 101 inputs.append(input); |
| 102 ids.add(input->id()); | 102 ids.add(input->id()); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 if (inputs.size() != ids.size()) { | 105 if (inputs.size() != ids.size()) { |
| 106 // There is id duplication that violates the spec. | 106 // There is id duplication that violates the spec. |
| 107 inputs.clear(); | 107 inputs.clear(); |
| 108 } | 108 } |
| 109 return new MIDIInputMap(inputs); | 109 return new MIDIInputMap(inputs); |
| 110 } | 110 } |
| 111 | 111 |
| 112 MIDIOutputMap* MIDIAccess::outputs() const { | 112 MIDIOutputMap* MIDIAccess::outputs() const { |
| 113 HeapVector<Member<MIDIOutput>> outputs; | 113 HeapVector<Member<MIDIOutput>> outputs; |
| 114 HashSet<String> ids; | 114 HashSet<String> ids; |
| 115 for (size_t i = 0; i < m_outputs.size(); ++i) { | 115 for (size_t i = 0; i < m_outputs.size(); ++i) { |
| 116 MIDIOutput* output = m_outputs[i]; | 116 MIDIOutput* output = m_outputs[i]; |
| 117 if (output->getState() != PortState::MIDIPortStateDisconnected) { | 117 if (output->getState() != PortState::DISCONNECTED) { |
| 118 outputs.append(output); | 118 outputs.append(output); |
| 119 ids.add(output->id()); | 119 ids.add(output->id()); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 if (outputs.size() != ids.size()) { | 122 if (outputs.size() != ids.size()) { |
| 123 // There is id duplication that violates the spec. | 123 // There is id duplication that violates the spec. |
| 124 outputs.clear(); | 124 outputs.clear(); |
| 125 } | 125 } |
| 126 return new MIDIOutputMap(outputs); | 126 return new MIDIOutputMap(outputs); |
| 127 } | 127 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 224 } |
| 225 | 225 |
| 226 DEFINE_TRACE(MIDIAccess) { | 226 DEFINE_TRACE(MIDIAccess) { |
| 227 visitor->trace(m_inputs); | 227 visitor->trace(m_inputs); |
| 228 visitor->trace(m_outputs); | 228 visitor->trace(m_outputs); |
| 229 EventTargetWithInlineData::trace(visitor); | 229 EventTargetWithInlineData::trace(visitor); |
| 230 ActiveDOMObject::trace(visitor); | 230 ActiveDOMObject::trace(visitor); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace blink | 233 } // namespace blink |
| OLD | NEW |