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