| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MIDIAccessInitializer_h | 5 #ifndef MIDIAccessInitializer_h |
| 6 #define MIDIAccessInitializer_h | 6 #define MIDIAccessInitializer_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "modules/ModulesExport.h" | 10 #include "modules/ModulesExport.h" |
| 11 #include "modules/webmidi/MIDIAccessor.h" | 11 #include "modules/webmidi/MIDIAccessor.h" |
| 12 #include "modules/webmidi/MIDIAccessorClient.h" | 12 #include "modules/webmidi/MIDIAccessorClient.h" |
| 13 #include "modules/webmidi/MIDIOptions.h" | 13 #include "modules/webmidi/MIDIOptions.h" |
| 14 #include "modules/webmidi/MIDIPort.h" | 14 #include "modules/webmidi/MIDIPort.h" |
| 15 #include "third_party/WebKit/public/platform/modules/permissions/permission.mojo
m-blink.h" | |
| 16 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat
us.mojom-blink.h" | |
| 17 #include "wtf/Vector.h" | 15 #include "wtf/Vector.h" |
| 18 #include <memory> | 16 #include <memory> |
| 19 | 17 |
| 20 namespace blink { | 18 namespace blink { |
| 21 | 19 |
| 22 class ScriptState; | 20 class ScriptState; |
| 23 | 21 |
| 24 class MODULES_EXPORT MIDIAccessInitializer : public ScriptPromiseResolver, publi
c MIDIAccessorClient { | 22 class MODULES_EXPORT MIDIAccessInitializer : public ScriptPromiseResolver, publi
c MIDIAccessorClient { |
| 25 public: | 23 public: |
| 26 struct PortDescriptor { | 24 struct PortDescriptor { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 }; | 40 }; |
| 43 | 41 |
| 44 static ScriptPromise start(ScriptState* scriptState, const MIDIOptions& opti
ons) | 42 static ScriptPromise start(ScriptState* scriptState, const MIDIOptions& opti
ons) |
| 45 { | 43 { |
| 46 MIDIAccessInitializer* resolver = new MIDIAccessInitializer(scriptState,
options); | 44 MIDIAccessInitializer* resolver = new MIDIAccessInitializer(scriptState,
options); |
| 47 resolver->keepAliveWhilePending(); | 45 resolver->keepAliveWhilePending(); |
| 48 resolver->suspendIfNeeded(); | 46 resolver->suspendIfNeeded(); |
| 49 return resolver->start(); | 47 return resolver->start(); |
| 50 } | 48 } |
| 51 | 49 |
| 52 ~MIDIAccessInitializer() override = default; | 50 ~MIDIAccessInitializer() override; |
| 53 | 51 |
| 54 // Eager finalization to allow dispose() operation access | 52 // Eager finalization to allow dispose() operation access |
| 55 // other (non eager) heap objects. | 53 // other (non eager) heap objects. |
| 56 EAGERLY_FINALIZE(); | 54 EAGERLY_FINALIZE(); |
| 57 | 55 |
| 58 // MIDIAccessorClient | 56 // MIDIAccessorClient |
| 59 void didAddInputPort(const String& id, const String& manufacturer, const Str
ing& name, const String& version, MIDIAccessor::MIDIPortState) override; | 57 void didAddInputPort(const String& id, const String& manufacturer, const Str
ing& name, const String& version, MIDIAccessor::MIDIPortState) override; |
| 60 void didAddOutputPort(const String& id, const String& manufacturer, const St
ring& name, const String& version, MIDIAccessor::MIDIPortState) override; | 58 void didAddOutputPort(const String& id, const String& manufacturer, const St
ring& name, const String& version, MIDIAccessor::MIDIPortState) override; |
| 61 void didSetInputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState) o
verride; | 59 void didSetInputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState) o
verride; |
| 62 void didSetOutputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState)
override; | 60 void didSetOutputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState)
override; |
| 63 void didStartSession(bool success, const String& error, const String& messag
e) override; | 61 void didStartSession(bool success, const String& error, const String& messag
e) override; |
| 64 void didReceiveMIDIData(unsigned portIndex, const unsigned char* data, size_
t length, double timeStamp) override { } | 62 void didReceiveMIDIData(unsigned portIndex, const unsigned char* data, size_
t length, double timeStamp) override { } |
| 65 | 63 |
| 64 void resolvePermission(bool allowed); |
| 65 SecurityOrigin* getSecurityOrigin() const; |
| 66 |
| 66 private: | 67 private: |
| 67 MIDIAccessInitializer(ScriptState*, const MIDIOptions&); | 68 MIDIAccessInitializer(ScriptState*, const MIDIOptions&); |
| 68 | 69 |
| 69 ExecutionContext* getExecutionContext() const; | 70 ExecutionContext* getExecutionContext() const; |
| 70 ScriptPromise start(); | 71 ScriptPromise start(); |
| 72 void dispose(); |
| 71 | 73 |
| 72 void contextDestroyed() override; | 74 void contextDestroyed() override; |
| 73 | 75 |
| 74 void onPermissionsUpdated(mojo::WTFArray<mojom::blink::PermissionStatus>); | |
| 75 void onPermissionUpdated(mojom::blink::PermissionStatus); | |
| 76 | |
| 77 std::unique_ptr<MIDIAccessor> m_accessor; | 76 std::unique_ptr<MIDIAccessor> m_accessor; |
| 78 Vector<PortDescriptor> m_portDescriptors; | 77 Vector<PortDescriptor> m_portDescriptors; |
| 79 MIDIOptions m_options; | 78 MIDIOptions m_options; |
| 80 | 79 bool m_hasBeenDisposed; |
| 81 mojom::blink::PermissionServicePtr m_permissionService; | 80 bool m_permissionResolved; |
| 82 }; | 81 }; |
| 83 | 82 |
| 84 } // namespace blink | 83 } // namespace blink |
| 85 | 84 |
| 86 #endif // MIDIAccessInitializer_h | 85 #endif // MIDIAccessInitializer_h |
| OLD | NEW |