| 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 "core/platform/midi/MIDIAccessorClient.h" | 38 #include "core/platform/midi/MIDIAccessorClient.h" |
| 39 #include "modules/webmidi/MIDIInput.h" | 39 #include "modules/webmidi/MIDIInput.h" |
| 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 ScriptExecutionContext; | 47 class ScriptExecutionContext; |
| 48 class SecurityOrigin; |
| 48 class MIDIAccessPromise; | 49 class MIDIAccessPromise; |
| 49 | 50 |
| 50 class MIDIAccess : public RefCounted<MIDIAccess>, public ScriptWrappable, public
ActiveDOMObject, public EventTarget, public MIDIAccessorClient { | 51 class MIDIAccess : public RefCounted<MIDIAccess>, public ScriptWrappable, public
ActiveDOMObject, public EventTarget, public MIDIAccessorClient { |
| 51 public: | 52 public: |
| 52 virtual ~MIDIAccess(); | 53 virtual ~MIDIAccess(); |
| 53 static PassRefPtr<MIDIAccess> create(ScriptExecutionContext*, MIDIAccessProm
ise*); | 54 static PassRefPtr<MIDIAccess> create(ScriptExecutionContext*, MIDIAccessProm
ise*); |
| 54 | 55 |
| 55 MIDIInputVector inputs() const { return m_inputs; } | 56 MIDIInputVector inputs() const { return m_inputs; } |
| 56 MIDIOutputVector outputs() const { return m_outputs; } | 57 MIDIOutputVector outputs() const { return m_outputs; } |
| 57 | 58 |
| 58 using RefCounted<MIDIAccess>::ref; | 59 using RefCounted<MIDIAccess>::ref; |
| 59 using RefCounted<MIDIAccess>::deref; | 60 using RefCounted<MIDIAccess>::deref; |
| 60 | 61 |
| 61 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 62 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
| 62 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); | 63 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
| 63 | 64 |
| 64 // EventTarget | 65 // EventTarget |
| 65 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam
es().interfaceForMIDIAccess; } | 66 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam
es().interfaceForMIDIAccess; } |
| 66 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { re
turn ActiveDOMObject::scriptExecutionContext(); } | 67 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { re
turn ActiveDOMObject::scriptExecutionContext(); } |
| 67 | 68 |
| 68 // ActiveDOMObject | 69 // ActiveDOMObject |
| 69 virtual bool canSuspend() const OVERRIDE { return true; } | 70 virtual bool canSuspend() const OVERRIDE { return true; } |
| 70 virtual void stop(); | 71 virtual void stop(); |
| 71 | 72 |
| 72 // MIDIAccessorClient | 73 // MIDIAccessorClient |
| 74 SecurityOrigin* securityOrigin() const OVERRIDE; |
| 75 |
| 73 virtual void didAddInputPort(const String& id, const String& manufacturer, c
onst String& name, const String& version) OVERRIDE; | 76 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; | 77 virtual void didAddOutputPort(const String& id, const String& manufacturer,
const String& name, const String& version) OVERRIDE; |
| 75 virtual void didAllowAccess() OVERRIDE; | 78 virtual void didAllowAccess() OVERRIDE; |
| 76 virtual void didBlockAccess() OVERRIDE; | 79 virtual void didBlockAccess() OVERRIDE; |
| 77 virtual void didReceiveMIDIData(unsigned portIndex, const unsigned char* dat
a, size_t length, double timeStamp) OVERRIDE; | 80 virtual void didReceiveMIDIData(unsigned portIndex, const unsigned char* dat
a, size_t length, double timeStamp) OVERRIDE; |
| 78 | 81 |
| 79 private: | 82 private: |
| 80 explicit MIDIAccess(ScriptExecutionContext*, MIDIAccessPromise*); | 83 explicit MIDIAccess(ScriptExecutionContext*, MIDIAccessPromise*); |
| 81 | 84 |
| 82 // EventTarget | 85 // EventTarget |
| 83 virtual void refEventTarget() OVERRIDE { ref(); } | 86 virtual void refEventTarget() OVERRIDE { ref(); } |
| 84 virtual void derefEventTarget() OVERRIDE { deref(); } | 87 virtual void derefEventTarget() OVERRIDE { deref(); } |
| 85 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD
ata; } | 88 virtual EventTargetData* eventTargetData() OVERRIDE { return &m_eventTargetD
ata; } |
| 86 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT
argetData; } | 89 virtual EventTargetData* ensureEventTargetData() OVERRIDE { return &m_eventT
argetData; } |
| 87 | 90 |
| 88 MIDIInputVector m_inputs; | 91 MIDIInputVector m_inputs; |
| 89 MIDIOutputVector m_outputs; | 92 MIDIOutputVector m_outputs; |
| 90 EventTargetData m_eventTargetData; | 93 EventTargetData m_eventTargetData; |
| 91 MIDIAccessPromise* m_promise; | 94 MIDIAccessPromise* m_promise; |
| 92 | 95 |
| 93 OwnPtr<MIDIAccessor> m_accessor; | 96 OwnPtr<MIDIAccessor> m_accessor; |
| 94 bool m_hasAccess; | 97 bool m_hasAccess; |
| 95 }; | 98 }; |
| 96 | 99 |
| 97 } // namespace WebCore | 100 } // namespace WebCore |
| 98 | 101 |
| 99 #endif // MIDIAccess_h | 102 #endif // MIDIAccess_h |
| OLD | NEW |