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 25 matching lines...) Expand all Loading... |
36 #include "core/dom/EventTarget.h" | 36 #include "core/dom/EventTarget.h" |
37 #include "modules/webmidi/MIDIInput.h" | 37 #include "modules/webmidi/MIDIInput.h" |
38 #include "modules/webmidi/MIDIOutput.h" | 38 #include "modules/webmidi/MIDIOutput.h" |
39 #include "wtf/RefCounted.h" | 39 #include "wtf/RefCounted.h" |
40 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
41 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
42 | 42 |
43 namespace WebCore { | 43 namespace WebCore { |
44 | 44 |
45 class ScriptExecutionContext; | 45 class ScriptExecutionContext; |
| 46 class MIDIAccessPromise; |
46 | 47 |
47 class MIDIAccess : public RefCounted<MIDIAccess>, public ScriptWrappable, public
ActiveDOMObject, public EventTarget { | 48 class MIDIAccess : public RefCounted<MIDIAccess>, public ScriptWrappable, public
ActiveDOMObject, public EventTarget { |
48 public: | 49 public: |
49 virtual ~MIDIAccess(); | 50 virtual ~MIDIAccess(); |
50 static PassRefPtr<MIDIAccess> create(ScriptExecutionContext*); | 51 static PassRefPtr<MIDIAccess> create(ScriptExecutionContext*, MIDIAccessProm
ise*); |
51 | 52 |
52 MIDIInputVector inputs() const { return m_inputs; } | 53 MIDIInputVector inputs() const { return m_inputs; } |
53 MIDIOutputVector outputs() const { return m_outputs; } | 54 MIDIOutputVector outputs() const { return m_outputs; } |
54 | 55 |
55 using RefCounted<MIDIAccess>::ref; | 56 using RefCounted<MIDIAccess>::ref; |
56 using RefCounted<MIDIAccess>::deref; | 57 using RefCounted<MIDIAccess>::deref; |
57 | 58 |
58 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 59 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
59 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); | 60 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
60 | 61 |
61 // EventTarget | 62 // EventTarget |
62 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam
es().interfaceForMIDIAccess; } | 63 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam
es().interfaceForMIDIAccess; } |
63 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { re
turn ActiveDOMObject::scriptExecutionContext(); } | 64 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { re
turn ActiveDOMObject::scriptExecutionContext(); } |
64 | 65 |
65 // ActiveDOMObject | 66 // ActiveDOMObject |
66 virtual bool canSuspend() const OVERRIDE { return true; } | 67 virtual bool canSuspend() const OVERRIDE { return true; } |
67 | 68 |
68 private: | 69 private: |
69 explicit MIDIAccess(ScriptExecutionContext*); | 70 explicit MIDIAccess(ScriptExecutionContext*, MIDIAccessPromise*); |
70 | 71 |
71 // EventTarget | 72 // EventTarget |
72 virtual void refEventTarget() OVERRIDE { ref(); } | 73 virtual void refEventTarget() OVERRIDE { ref(); } |
73 virtual void derefEventTarget() OVERRIDE { deref(); } | 74 virtual void derefEventTarget() OVERRIDE { deref(); } |
74 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD
ata; } | 75 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD
ata; } |
75 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT
argetData; } | 76 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT
argetData; } |
76 | 77 |
77 MIDIInputVector m_inputs; | 78 MIDIInputVector m_inputs; |
78 MIDIOutputVector m_outputs; | 79 MIDIOutputVector m_outputs; |
79 EventTargetData m_eventTargetData; | 80 EventTargetData m_eventTargetData; |
| 81 MIDIAccessPromise* m_promise; |
80 }; | 82 }; |
81 | 83 |
82 } // namespace WebCore | 84 } // namespace WebCore |
83 | 85 |
84 #endif // MIDIAccess_h | 86 #endif // MIDIAccess_h |
OLD | NEW |