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/webmidi/MIDIAccessor.h" | 10 #include "modules/webmidi/MIDIAccessor.h" |
11 #include "modules/webmidi/MIDIAccessorClient.h" | 11 #include "modules/webmidi/MIDIAccessorClient.h" |
12 #include "modules/webmidi/MIDIPort.h" | 12 #include "modules/webmidi/MIDIPort.h" |
13 #include "wtf/OwnPtr.h" | 13 #include "wtf/OwnPtr.h" |
14 #include "wtf/Vector.h" | 14 #include "wtf/Vector.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 class MIDIAccess; | 18 class MIDIAccess; |
Takashi Toyoshima
2014/10/20 05:39:50
Changes in this file isn't mine.
Sorry, I work on
| |
19 class MIDIOptions; | 19 class MIDIOptions; |
20 class Navigator; | 20 class Navigator; |
21 class ScriptState; | 21 class ScriptState; |
22 | 22 |
23 class MIDIAccessInitializer : public ScriptPromiseResolver, public MIDIAccessorC lient { | 23 class MIDIAccessInitializer : public ScriptPromiseResolver, public MIDIAccessorC lient { |
24 public: | 24 public: |
25 struct PortDescriptor { | 25 struct PortDescriptor { |
26 String id; | 26 String id; |
27 String manufacturer; | 27 String manufacturer; |
28 String name; | 28 String name; |
29 MIDIPort::MIDIPortTypeCode type; | 29 MIDIPort::MIDIPortTypeCode type; |
30 String version; | 30 String version; |
31 bool active; | |
31 | 32 |
32 PortDescriptor(const String& id, const String& manufacturer, const Strin g& name, MIDIPort::MIDIPortTypeCode type, const String& version) | 33 PortDescriptor(const String& id, const String& manufacturer, const Strin g& name, MIDIPort::MIDIPortTypeCode type, const String& version, bool active) |
33 : id(id) | 34 : id(id) |
34 , manufacturer(manufacturer) | 35 , manufacturer(manufacturer) |
35 , name(name) | 36 , name(name) |
36 , type(type) | 37 , type(type) |
37 , version(version) { } | 38 , version(version) |
39 , active(active) { } | |
38 }; | 40 }; |
39 | 41 |
40 static ScriptPromise start(ScriptState* scriptState, const MIDIOptions& opti ons) | 42 static ScriptPromise start(ScriptState* scriptState, const MIDIOptions& opti ons) |
41 { | 43 { |
42 RefPtr<MIDIAccessInitializer> p = adoptRef(new MIDIAccessInitializer(scr iptState, options)); | 44 RefPtr<MIDIAccessInitializer> p = adoptRef(new MIDIAccessInitializer(scr iptState, options)); |
43 p->keepAliveWhilePending(); | 45 p->keepAliveWhilePending(); |
44 p->suspendIfNeeded(); | 46 p->suspendIfNeeded(); |
45 return p->start(); | 47 return p->start(); |
46 } | 48 } |
47 | 49 |
48 virtual ~MIDIAccessInitializer(); | 50 virtual ~MIDIAccessInitializer(); |
49 | 51 |
50 // MIDIAccessorClient | 52 // MIDIAccessorClient |
51 virtual void didAddInputPort(const String& id, const String& manufacturer, c onst String& name, const String& version) override; | 53 virtual void didAddInputPort(const String& id, const String& manufacturer, c onst String& name, const String& version, bool active) override; |
52 virtual void didAddOutputPort(const String& id, const String& manufacturer, const String& name, const String& version) override; | 54 virtual void didAddOutputPort(const String& id, const String& manufacturer, const String& name, const String& version, bool active) override; |
55 virtual void didSetInputPortState(unsigned portIndex, bool active) override; | |
56 virtual void didSetOutputPortState(unsigned portIndex, bool active) override ; | |
53 virtual void didStartSession(bool success, const String& error, const String & message) override; | 57 virtual void didStartSession(bool success, const String& error, const String & message) override; |
54 virtual void didReceiveMIDIData(unsigned portIndex, const unsigned char* dat a, size_t length, double timeStamp) override { } | 58 virtual void didReceiveMIDIData(unsigned portIndex, const unsigned char* dat a, size_t length, double timeStamp) override { } |
55 | 59 |
56 void resolveSysexPermission(bool allowed); | 60 void resolveSysexPermission(bool allowed); |
57 SecurityOrigin* securityOrigin() const; | 61 SecurityOrigin* securityOrigin() const; |
58 | 62 |
59 private: | 63 private: |
60 ScriptPromise start(); | 64 ScriptPromise start(); |
61 | 65 |
62 MIDIAccessInitializer(ScriptState*, const MIDIOptions&); | 66 MIDIAccessInitializer(ScriptState*, const MIDIOptions&); |
63 | 67 |
64 ExecutionContext* executionContext() const; | 68 ExecutionContext* executionContext() const; |
65 | 69 |
66 OwnPtr<MIDIAccessor> m_accessor; | 70 OwnPtr<MIDIAccessor> m_accessor; |
67 bool m_requestSysex; | 71 bool m_requestSysex; |
68 Vector<PortDescriptor> m_portDescriptors; | 72 Vector<PortDescriptor> m_portDescriptors; |
69 }; | 73 }; |
70 | 74 |
71 } // namespace blink | 75 } // namespace blink |
72 | 76 |
73 | 77 |
74 #endif // MIDIAccessInitializer_h | 78 #endif // MIDIAccessInitializer_h |
OLD | NEW |