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 29 matching lines...) Expand all Loading... |
40 #include "modules/webmidi/MIDIOutput.h" | 40 #include "modules/webmidi/MIDIOutput.h" |
41 #include "wtf/RefCounted.h" | 41 #include "wtf/RefCounted.h" |
42 #include "wtf/RefPtr.h" | 42 #include "wtf/RefPtr.h" |
43 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
44 | 44 |
45 namespace WebCore { | 45 namespace WebCore { |
46 | 46 |
47 class ExecutionContext; | 47 class ExecutionContext; |
48 class MIDIAccessPromise; | 48 class MIDIAccessPromise; |
49 | 49 |
50 class MIDIAccess : public RefCounted<MIDIAccess>, public ScriptWrappable, public
ActiveDOMObject, public EventTargetWithInlineData, public MIDIAccessorClient { | 50 class MIDIAccess FINAL : public RefCounted<MIDIAccess>, public ScriptWrappable,
public ActiveDOMObject, public EventTargetWithInlineData, public MIDIAccessorCli
ent { |
51 REFCOUNTED_EVENT_TARGET(MIDIAccess); | 51 REFCOUNTED_EVENT_TARGET(MIDIAccess); |
52 public: | 52 public: |
53 virtual ~MIDIAccess(); | 53 virtual ~MIDIAccess(); |
54 static PassRefPtr<MIDIAccess> create(ExecutionContext*, MIDIAccessPromise*); | 54 static PassRefPtr<MIDIAccess> create(ExecutionContext*, MIDIAccessPromise*); |
55 | 55 |
56 MIDIInputVector inputs() const { return m_inputs; } | 56 MIDIInputVector inputs() const { return m_inputs; } |
57 MIDIOutputVector outputs() const { return m_outputs; } | 57 MIDIOutputVector outputs() const { return m_outputs; } |
58 | 58 |
59 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 59 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
60 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); | 60 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
61 | 61 |
62 void setSysExEnabled(bool); | 62 void setSysExEnabled(bool); |
63 bool sysExEnabled() const { return m_sysExEnabled; } | 63 bool sysExEnabled() const { return m_sysExEnabled; } |
64 | 64 |
65 // EventTarget | 65 // EventTarget |
66 virtual const AtomicString& interfaceName() const OVERRIDE { return EventTar
getNames::MIDIAccess; } | 66 virtual const AtomicString& interfaceName() const OVERRIDE { return EventTar
getNames::MIDIAccess; } |
67 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } | 67 virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveD
OMObject::executionContext(); } |
68 | 68 |
69 // ActiveDOMObject | 69 // ActiveDOMObject |
70 virtual void stop(); | 70 virtual void stop() OVERRIDE; |
71 | 71 |
72 // MIDIAccessorClient | 72 // MIDIAccessorClient |
73 virtual void didAddInputPort(const String& id, const String& manufacturer, c
onst String& name, const String& version) OVERRIDE; | 73 virtual void didAddInputPort(const String& id, const String& manufacturer, c
onst String& name, const String& version) OVERRIDE; |
74 virtual void didAddOutputPort(const String& id, const String& manufacturer,
const String& name, const String& version) OVERRIDE; | 74 virtual void didAddOutputPort(const String& id, const String& manufacturer,
const String& name, const String& version) OVERRIDE; |
75 virtual void didStartSession(bool success) OVERRIDE; | 75 virtual void didStartSession(bool success) OVERRIDE; |
76 virtual void didReceiveMIDIData(unsigned portIndex, const unsigned char* dat
a, size_t length, double timeStamp) OVERRIDE; | 76 virtual void didReceiveMIDIData(unsigned portIndex, const unsigned char* dat
a, size_t length, double timeStamp) OVERRIDE; |
77 | 77 |
78 // |timeStampInMilliseconds| is in the same time coordinate system as perfor
mance.now(). | 78 // |timeStampInMilliseconds| is in the same time coordinate system as perfor
mance.now(). |
79 void sendMIDIData(unsigned portIndex, const unsigned char* data, size_t leng
th, double timeStampInMilliseconds); | 79 void sendMIDIData(unsigned portIndex, const unsigned char* data, size_t leng
th, double timeStampInMilliseconds); |
80 | 80 |
81 private: | 81 private: |
82 MIDIAccess(ExecutionContext*, MIDIAccessPromise*); | 82 MIDIAccess(ExecutionContext*, MIDIAccessPromise*); |
83 | 83 |
84 void startRequest(); | 84 void startRequest(); |
85 virtual void permissionDenied(); | 85 void permissionDenied(); |
86 | 86 |
87 MIDIInputVector m_inputs; | 87 MIDIInputVector m_inputs; |
88 MIDIOutputVector m_outputs; | 88 MIDIOutputVector m_outputs; |
89 MIDIAccessPromise* m_promise; | 89 MIDIAccessPromise* m_promise; |
90 | 90 |
91 OwnPtr<MIDIAccessor> m_accessor; | 91 OwnPtr<MIDIAccessor> m_accessor; |
92 bool m_hasAccess; | 92 bool m_hasAccess; |
93 bool m_sysExEnabled; | 93 bool m_sysExEnabled; |
94 bool m_requesting; | 94 bool m_requesting; |
95 }; | 95 }; |
96 | 96 |
97 } // namespace WebCore | 97 } // namespace WebCore |
98 | 98 |
99 #endif // MIDIAccess_h | 99 #endif // MIDIAccess_h |
OLD | NEW |