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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 #include "bindings/core/v8/ActiveScriptWrappable.h" | 34 #include "bindings/core/v8/ActiveScriptWrappable.h" |
35 #include "bindings/core/v8/ScriptPromise.h" | 35 #include "bindings/core/v8/ScriptPromise.h" |
36 #include "core/dom/ActiveDOMObject.h" | 36 #include "core/dom/ActiveDOMObject.h" |
37 #include "modules/EventTargetModules.h" | 37 #include "modules/EventTargetModules.h" |
38 #include "modules/webmidi/MIDIAccessInitializer.h" | 38 #include "modules/webmidi/MIDIAccessInitializer.h" |
39 #include "modules/webmidi/MIDIAccessor.h" | 39 #include "modules/webmidi/MIDIAccessor.h" |
40 #include "modules/webmidi/MIDIAccessorClient.h" | 40 #include "modules/webmidi/MIDIAccessorClient.h" |
41 #include "platform/heap/Handle.h" | 41 #include "platform/heap/Handle.h" |
42 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
43 #include <memory> | |
44 | 43 |
45 namespace blink { | 44 namespace blink { |
46 | 45 |
47 class ExecutionContext; | 46 class ExecutionContext; |
48 class MIDIInput; | 47 class MIDIInput; |
49 class MIDIInputMap; | 48 class MIDIInputMap; |
50 class MIDIOutput; | 49 class MIDIOutput; |
51 class MIDIOutputMap; | 50 class MIDIOutputMap; |
52 | 51 |
53 class MIDIAccess final : public EventTargetWithInlineData, public ActiveScriptWr
appable, public ActiveDOMObject, public MIDIAccessorClient { | 52 class MIDIAccess final : public EventTargetWithInlineData, public ActiveScriptWr
appable, public ActiveDOMObject, public MIDIAccessorClient { |
54 DEFINE_WRAPPERTYPEINFO(); | 53 DEFINE_WRAPPERTYPEINFO(); |
55 USING_GARBAGE_COLLECTED_MIXIN(MIDIAccess); | 54 USING_GARBAGE_COLLECTED_MIXIN(MIDIAccess); |
56 USING_PRE_FINALIZER(MIDIAccess, dispose); | 55 USING_PRE_FINALIZER(MIDIAccess, dispose); |
57 public: | 56 public: |
58 static MIDIAccess* create(std::unique_ptr<MIDIAccessor> accessor, bool sysex
Enabled, const Vector<MIDIAccessInitializer::PortDescriptor>& ports, ExecutionCo
ntext* executionContext) | 57 static MIDIAccess* create(PassOwnPtr<MIDIAccessor> accessor, bool sysexEnabl
ed, const Vector<MIDIAccessInitializer::PortDescriptor>& ports, ExecutionContext
* executionContext) |
59 { | 58 { |
60 MIDIAccess* access = new MIDIAccess(std::move(accessor), sysexEnabled, p
orts, executionContext); | 59 MIDIAccess* access = new MIDIAccess(std::move(accessor), sysexEnabled, p
orts, executionContext); |
61 access->suspendIfNeeded(); | 60 access->suspendIfNeeded(); |
62 return access; | 61 return access; |
63 } | 62 } |
64 ~MIDIAccess() override; | 63 ~MIDIAccess() override; |
65 | 64 |
66 MIDIInputMap* inputs() const; | 65 MIDIInputMap* inputs() const; |
67 MIDIOutputMap* outputs() const; | 66 MIDIOutputMap* outputs() const; |
68 | 67 |
(...skipping 27 matching lines...) Expand all Loading... |
96 | 95 |
97 // |timeStampInMilliseconds| is in the same time coordinate system as perfor
mance.now(). | 96 // |timeStampInMilliseconds| is in the same time coordinate system as perfor
mance.now(). |
98 void sendMIDIData(unsigned portIndex, const unsigned char* data, size_t leng
th, double timeStampInMilliseconds); | 97 void sendMIDIData(unsigned portIndex, const unsigned char* data, size_t leng
th, double timeStampInMilliseconds); |
99 | 98 |
100 // Eager finalization needed to promptly release m_accessor. Otherwise | 99 // Eager finalization needed to promptly release m_accessor. Otherwise |
101 // its client back reference could end up being unsafely used during | 100 // its client back reference could end up being unsafely used during |
102 // the lazy sweeping phase. | 101 // the lazy sweeping phase. |
103 DECLARE_VIRTUAL_TRACE(); | 102 DECLARE_VIRTUAL_TRACE(); |
104 | 103 |
105 private: | 104 private: |
106 MIDIAccess(std::unique_ptr<MIDIAccessor>, bool sysexEnabled, const Vector<MI
DIAccessInitializer::PortDescriptor>&, ExecutionContext*); | 105 MIDIAccess(PassOwnPtr<MIDIAccessor>, bool sysexEnabled, const Vector<MIDIAcc
essInitializer::PortDescriptor>&, ExecutionContext*); |
107 void dispose(); | 106 void dispose(); |
108 | 107 |
109 std::unique_ptr<MIDIAccessor> m_accessor; | 108 OwnPtr<MIDIAccessor> m_accessor; |
110 bool m_sysexEnabled; | 109 bool m_sysexEnabled; |
111 bool m_hasPendingActivity; | 110 bool m_hasPendingActivity; |
112 HeapVector<Member<MIDIInput>> m_inputs; | 111 HeapVector<Member<MIDIInput>> m_inputs; |
113 HeapVector<Member<MIDIOutput>> m_outputs; | 112 HeapVector<Member<MIDIOutput>> m_outputs; |
114 }; | 113 }; |
115 | 114 |
116 } // namespace blink | 115 } // namespace blink |
117 | 116 |
118 #endif // MIDIAccess_h | 117 #endif // MIDIAccess_h |
OLD | NEW |