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