| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 , m_access(access) | 51 , m_access(access) |
| 52 , m_portIndex(portIndex) | 52 , m_portIndex(portIndex) |
| 53 { | 53 { |
| 54 ScriptWrappable::init(this); | 54 ScriptWrappable::init(this); |
| 55 } | 55 } |
| 56 | 56 |
| 57 MIDIOutput::~MIDIOutput() | 57 MIDIOutput::~MIDIOutput() |
| 58 { | 58 { |
| 59 } | 59 } |
| 60 | 60 |
| 61 void MIDIOutput::send(Uint8Array* array, double timestamp, ExceptionState& es) | 61 void MIDIOutput::send(Uint8Array* array, double timestamp, ExceptionState& excep
tionState) |
| 62 { | 62 { |
| 63 if (!array) | 63 if (!array) |
| 64 return; | 64 return; |
| 65 | 65 |
| 66 const unsigned char* data = array->data(); | 66 const unsigned char* data = array->data(); |
| 67 size_t length = array->length(); | 67 size_t length = array->length(); |
| 68 | 68 |
| 69 // Filter out System Exclusive messages if we're not allowed. | 69 // Filter out System Exclusive messages if we're not allowed. |
| 70 // FIXME: implement more extensive filtering. | 70 // FIXME: implement more extensive filtering. |
| 71 if (length > 0 && data[0] >= 0xf0 && !m_access->sysExEnabled()) { | 71 if (length > 0 && data[0] >= 0xf0 && !m_access->sysExEnabled()) { |
| 72 es.throwSecurityError(ExceptionMessages::failedToExecute("send", "MIDIOu
tput", "permission to send system exclusive messages is denied.")); | 72 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("se
nd", "MIDIOutput", "permission to send system exclusive messages is denied.")); |
| 73 return; | 73 return; |
| 74 } | 74 } |
| 75 | 75 |
| 76 m_access->sendMIDIData(m_portIndex, data, length, timestamp); | 76 m_access->sendMIDIData(m_portIndex, data, length, timestamp); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void MIDIOutput::send(Vector<unsigned> unsignedData, double timestamp, Exception
State& es) | 79 void MIDIOutput::send(Vector<unsigned> unsignedData, double timestamp, Exception
State& exceptionState) |
| 80 { | 80 { |
| 81 RefPtr<Uint8Array> array = Uint8Array::create(unsignedData.size()); | 81 RefPtr<Uint8Array> array = Uint8Array::create(unsignedData.size()); |
| 82 | 82 |
| 83 for (size_t i = 0; i < unsignedData.size(); ++i) { | 83 for (size_t i = 0; i < unsignedData.size(); ++i) { |
| 84 if (unsignedData[i] > 0xff) { | 84 if (unsignedData[i] > 0xff) { |
| 85 es.throwUninformativeAndGenericDOMException(InvalidStateError); | 85 exceptionState.throwUninformativeAndGenericDOMException(InvalidState
Error); |
| 86 return; | 86 return; |
| 87 } | 87 } |
| 88 unsigned char value = unsignedData[i] & 0xff; | 88 unsigned char value = unsignedData[i] & 0xff; |
| 89 array->set(i, value); | 89 array->set(i, value); |
| 90 } | 90 } |
| 91 | 91 |
| 92 send(array.get(), timestamp, es); | 92 send(array.get(), timestamp, exceptionState); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void MIDIOutput::send(Uint8Array* data, ExceptionState& es) | 95 void MIDIOutput::send(Uint8Array* data, ExceptionState& exceptionState) |
| 96 { | 96 { |
| 97 send(data, 0, es); | 97 send(data, 0, exceptionState); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void MIDIOutput::send(Vector<unsigned> unsignedData, ExceptionState& es) | 100 void MIDIOutput::send(Vector<unsigned> unsignedData, ExceptionState& exceptionSt
ate) |
| 101 { | 101 { |
| 102 send(unsignedData, 0, es); | 102 send(unsignedData, 0, exceptionState); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace WebCore | 105 } // namespace WebCore |
| OLD | NEW |