| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 !getExecutionContext()->isContextDestroyed(); | 103 !getExecutionContext()->isContextDestroyed(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 MIDIInputMap* MIDIAccess::inputs() const { | 106 MIDIInputMap* MIDIAccess::inputs() const { |
| 107 HeapVector<Member<MIDIInput>> inputs; | 107 HeapVector<Member<MIDIInput>> inputs; |
| 108 HashSet<String> ids; | 108 HashSet<String> ids; |
| 109 for (size_t i = 0; i < m_inputs.size(); ++i) { | 109 for (size_t i = 0; i < m_inputs.size(); ++i) { |
| 110 MIDIInput* input = m_inputs[i]; | 110 MIDIInput* input = m_inputs[i]; |
| 111 if (input->getState() != PortState::DISCONNECTED) { | 111 if (input->getState() != PortState::DISCONNECTED) { |
| 112 inputs.push_back(input); | 112 inputs.push_back(input); |
| 113 ids.add(input->id()); | 113 ids.insert(input->id()); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 if (inputs.size() != ids.size()) { | 116 if (inputs.size() != ids.size()) { |
| 117 // There is id duplication that violates the spec. | 117 // There is id duplication that violates the spec. |
| 118 inputs.clear(); | 118 inputs.clear(); |
| 119 } | 119 } |
| 120 return new MIDIInputMap(inputs); | 120 return new MIDIInputMap(inputs); |
| 121 } | 121 } |
| 122 | 122 |
| 123 MIDIOutputMap* MIDIAccess::outputs() const { | 123 MIDIOutputMap* MIDIAccess::outputs() const { |
| 124 HeapVector<Member<MIDIOutput>> outputs; | 124 HeapVector<Member<MIDIOutput>> outputs; |
| 125 HashSet<String> ids; | 125 HashSet<String> ids; |
| 126 for (size_t i = 0; i < m_outputs.size(); ++i) { | 126 for (size_t i = 0; i < m_outputs.size(); ++i) { |
| 127 MIDIOutput* output = m_outputs[i]; | 127 MIDIOutput* output = m_outputs[i]; |
| 128 if (output->getState() != PortState::DISCONNECTED) { | 128 if (output->getState() != PortState::DISCONNECTED) { |
| 129 outputs.push_back(output); | 129 outputs.push_back(output); |
| 130 ids.add(output->id()); | 130 ids.insert(output->id()); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 if (outputs.size() != ids.size()) { | 133 if (outputs.size() != ids.size()) { |
| 134 // There is id duplication that violates the spec. | 134 // There is id duplication that violates the spec. |
| 135 outputs.clear(); | 135 outputs.clear(); |
| 136 } | 136 } |
| 137 return new MIDIOutputMap(outputs); | 137 return new MIDIOutputMap(outputs); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void MIDIAccess::didAddInputPort(const String& id, | 140 void MIDIAccess::didAddInputPort(const String& id, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 230 } |
| 231 | 231 |
| 232 DEFINE_TRACE(MIDIAccess) { | 232 DEFINE_TRACE(MIDIAccess) { |
| 233 visitor->trace(m_inputs); | 233 visitor->trace(m_inputs); |
| 234 visitor->trace(m_outputs); | 234 visitor->trace(m_outputs); |
| 235 EventTargetWithInlineData::trace(visitor); | 235 EventTargetWithInlineData::trace(visitor); |
| 236 ContextLifecycleObserver::trace(visitor); | 236 ContextLifecycleObserver::trace(visitor); |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace blink | 239 } // namespace blink |
| OLD | NEW |