| 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" |
| 15 #include "wtf/Vector.h" | 17 #include "wtf/Vector.h" |
| 16 #include <memory> | 18 #include <memory> |
| 17 | 19 |
| 18 namespace blink { | 20 namespace blink { |
| 19 | 21 |
| 20 class ScriptState; | 22 class ScriptState; |
| 21 | 23 |
| 22 class MODULES_EXPORT MIDIAccessInitializer : public ScriptPromiseResolver, publi
c MIDIAccessorClient { | 24 class MODULES_EXPORT MIDIAccessInitializer : public ScriptPromiseResolver, publi
c MIDIAccessorClient { |
| 23 public: | 25 public: |
| 24 struct PortDescriptor { | 26 struct PortDescriptor { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 static ScriptPromise start(ScriptState* scriptState, const MIDIOptions& opti
ons) | 44 static ScriptPromise start(ScriptState* scriptState, const MIDIOptions& opti
ons) |
| 43 { | 45 { |
| 44 MIDIAccessInitializer* resolver = new MIDIAccessInitializer(scriptState,
options); | 46 MIDIAccessInitializer* resolver = new MIDIAccessInitializer(scriptState,
options); |
| 45 resolver->keepAliveWhilePending(); | 47 resolver->keepAliveWhilePending(); |
| 46 resolver->suspendIfNeeded(); | 48 resolver->suspendIfNeeded(); |
| 47 return resolver->start(); | 49 return resolver->start(); |
| 48 } | 50 } |
| 49 | 51 |
| 50 ~MIDIAccessInitializer() override; | 52 ~MIDIAccessInitializer() override = default; |
| 51 | 53 |
| 52 // Eager finalization to allow dispose() operation access | 54 // Eager finalization to allow dispose() operation access |
| 53 // other (non eager) heap objects. | 55 // other (non eager) heap objects. |
| 54 EAGERLY_FINALIZE(); | 56 EAGERLY_FINALIZE(); |
| 55 | 57 |
| 56 // MIDIAccessorClient | 58 // MIDIAccessorClient |
| 57 void didAddInputPort(const String& id, const String& manufacturer, const Str
ing& name, const String& version, MIDIAccessor::MIDIPortState) override; | 59 void didAddInputPort(const String& id, const String& manufacturer, const Str
ing& 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; | 60 void didAddOutputPort(const String& id, const String& manufacturer, const St
ring& name, const String& version, MIDIAccessor::MIDIPortState) override; |
| 59 void didSetInputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState) o
verride; | 61 void didSetInputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState) o
verride; |
| 60 void didSetOutputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState)
override; | 62 void didSetOutputPortState(unsigned portIndex, MIDIAccessor::MIDIPortState)
override; |
| 61 void didStartSession(bool success, const String& error, const String& messag
e) override; | 63 void didStartSession(bool success, const String& error, const String& messag
e) override; |
| 62 void didReceiveMIDIData(unsigned portIndex, const unsigned char* data, size_
t length, double timeStamp) override { } | 64 void didReceiveMIDIData(unsigned portIndex, const unsigned char* data, size_
t length, double timeStamp) override { } |
| 63 | 65 |
| 64 void resolvePermission(bool allowed); | |
| 65 SecurityOrigin* getSecurityOrigin() const; | |
| 66 | |
| 67 private: | 66 private: |
| 68 MIDIAccessInitializer(ScriptState*, const MIDIOptions&); | 67 MIDIAccessInitializer(ScriptState*, const MIDIOptions&); |
| 69 | 68 |
| 70 ExecutionContext* getExecutionContext() const; | 69 ExecutionContext* getExecutionContext() const; |
| 71 ScriptPromise start(); | 70 ScriptPromise start(); |
| 72 void dispose(); | |
| 73 | 71 |
| 74 void contextDestroyed() override; | 72 void contextDestroyed() override; |
| 75 | 73 |
| 74 void onPermissionsUpdated(mojo::WTFArray<mojom::blink::PermissionStatus>); |
| 75 void onPermissionUpdated(mojom::blink::PermissionStatus); |
| 76 |
| 76 std::unique_ptr<MIDIAccessor> m_accessor; | 77 std::unique_ptr<MIDIAccessor> m_accessor; |
| 77 Vector<PortDescriptor> m_portDescriptors; | 78 Vector<PortDescriptor> m_portDescriptors; |
| 78 MIDIOptions m_options; | 79 MIDIOptions m_options; |
| 79 bool m_hasBeenDisposed; | 80 |
| 80 bool m_permissionResolved; | 81 mojom::blink::PermissionServicePtr m_permissionService; |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 } // namespace blink | 84 } // namespace blink |
| 84 | 85 |
| 85 #endif // MIDIAccessInitializer_h | 86 #endif // MIDIAccessInitializer_h |
| OLD | NEW |