| 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 "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
| 39 | 39 |
| 40 namespace blink { | 40 namespace blink { |
| 41 | 41 |
| 42 class MIDIAccess; | 42 class MIDIAccess; |
| 43 | 43 |
| 44 class MIDIPort : public RefCountedGarbageCollectedEventTargetWithInlineData<MIDI
Port> { | 44 class MIDIPort : public RefCountedGarbageCollectedEventTargetWithInlineData<MIDI
Port> { |
| 45 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<M
IDIPort>); | 45 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<M
IDIPort>); |
| 46 DEFINE_WRAPPERTYPEINFO(); | 46 DEFINE_WRAPPERTYPEINFO(); |
| 47 public: | 47 public: |
| 48 enum MIDIPortTypeCode { | 48 enum TypeCode { |
| 49 MIDIPortTypeInput, | 49 TypeInput, |
| 50 MIDIPortTypeOutput | 50 TypeOutput |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 virtual ~MIDIPort() { } | 53 virtual ~MIDIPort() { } |
| 54 | 54 |
| 55 String connection() const; |
| 55 String id() const { return m_id; } | 56 String id() const { return m_id; } |
| 56 String manufacturer() const { return m_manufacturer; } | 57 String manufacturer() const { return m_manufacturer; } |
| 57 String name() const { return m_name; } | 58 String name() const { return m_name; } |
| 58 String state() const; | 59 String state() const; |
| 59 String type() const; | 60 String type() const; |
| 60 String version() const { return m_version; } | 61 String version() const { return m_version; } |
| 61 | 62 |
| 62 ScriptPromise open(ScriptState*); | 63 ScriptPromise open(ScriptState*); |
| 63 ScriptPromise close(ScriptState*); | 64 ScriptPromise close(ScriptState*); |
| 64 | 65 |
| 65 MIDIAccess* midiAccess() const { return m_access; } | 66 MIDIAccess* midiAccess() const { return m_access; } |
| 66 MIDIAccessor::MIDIPortState getState() const { return m_state; } | 67 MIDIAccessor::MIDIPortState getState() const { return m_state; } |
| 67 void setState(MIDIAccessor::MIDIPortState); | 68 void setState(MIDIAccessor::MIDIPortState); |
| 68 | 69 |
| 69 DECLARE_VIRTUAL_TRACE(); | 70 DECLARE_VIRTUAL_TRACE(); |
| 70 | 71 |
| 71 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 72 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
| 72 | 73 |
| 73 // EventTarget | 74 // EventTarget |
| 74 virtual const AtomicString& interfaceName() const override { return EventTar
getNames::MIDIPort; } | 75 virtual const AtomicString& interfaceName() const override { return EventTar
getNames::MIDIPort; } |
| 75 virtual ExecutionContext* executionContext() const override final; | 76 virtual ExecutionContext* executionContext() const override final; |
| 76 | 77 |
| 77 protected: | 78 protected: |
| 78 MIDIPort(MIDIAccess*, const String& id, const String& manufacturer, const St
ring& name, MIDIPortTypeCode, const String& version, MIDIAccessor::MIDIPortState
); | 79 MIDIPort(MIDIAccess*, const String& id, const String& manufacturer, const St
ring& name, TypeCode, const String& version, MIDIAccessor::MIDIPortState); |
| 79 | 80 |
| 80 private: | 81 private: |
| 82 enum ConnectionState { |
| 83 ConnectionStateOpen, |
| 84 ConnectionStateClosed, |
| 85 ConnectionStatePending |
| 86 }; |
| 87 |
| 81 ScriptPromise accept(ScriptState*); | 88 ScriptPromise accept(ScriptState*); |
| 82 ScriptPromise reject(ScriptState*, ExceptionCode, const String& message); | 89 ScriptPromise reject(ScriptState*, ExceptionCode, const String& message); |
| 83 | 90 |
| 91 void setStates(MIDIAccessor::MIDIPortState, ConnectionState); |
| 92 |
| 84 String m_id; | 93 String m_id; |
| 85 String m_manufacturer; | 94 String m_manufacturer; |
| 86 String m_name; | 95 String m_name; |
| 87 MIDIPortTypeCode m_type; | 96 TypeCode m_type; |
| 88 String m_version; | 97 String m_version; |
| 89 Member<MIDIAccess> m_access; | 98 Member<MIDIAccess> m_access; |
| 90 MIDIAccessor::MIDIPortState m_state; | 99 MIDIAccessor::MIDIPortState m_state; |
| 100 ConnectionState m_connection; |
| 91 }; | 101 }; |
| 92 | 102 |
| 93 } // namespace blink | 103 } // namespace blink |
| 94 | 104 |
| 95 #endif // MIDIPort_h | 105 #endif // MIDIPort_h |
| OLD | NEW |