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