| Index: Source/modules/webmidi/MIDIAccess.h
|
| diff --git a/Source/modules/webmidi/MIDIAccess.h b/Source/modules/webmidi/MIDIAccess.h
|
| index a683b042b0839a19bd7010bf426a8e1455fe88f7..df3f7c1021e7a73d683a778a9196a1a926435270 100644
|
| --- a/Source/modules/webmidi/MIDIAccess.h
|
| +++ b/Source/modules/webmidi/MIDIAccess.h
|
| @@ -31,6 +31,8 @@
|
| #ifndef MIDIAccess_h
|
| #define MIDIAccess_h
|
|
|
| +#include "bindings/v8/MIDIAccessResolver.h"
|
| +#include "bindings/v8/ScriptPromise.h"
|
| #include "bindings/v8/ScriptWrappable.h"
|
| #include "core/dom/ActiveDOMObject.h"
|
| #include "core/events/EventTarget.h"
|
| @@ -38,21 +40,23 @@
|
| #include "modules/webmidi/MIDIAccessor.h"
|
| #include "modules/webmidi/MIDIAccessorClient.h"
|
| #include "modules/webmidi/MIDIInput.h"
|
| +#include "modules/webmidi/MIDIOptions.h"
|
| #include "modules/webmidi/MIDIOutput.h"
|
| +#include "platform/AsyncMethodRunner.h"
|
| #include "wtf/RefCounted.h"
|
| #include "wtf/RefPtr.h"
|
| -#include "wtf/Vector.h"
|
| +#include "wtf/WeakPtr.h"
|
|
|
| namespace WebCore {
|
|
|
| class ExecutionContext;
|
| -class MIDIAccessPromise;
|
|
|
| class MIDIAccess FINAL : public RefCountedWillBeRefCountedGarbageCollected<MIDIAccess>, public ScriptWrappable, public ActiveDOMObject, public EventTargetWithInlineData, public MIDIAccessorClient {
|
| DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<MIDIAccess>);
|
| public:
|
| virtual ~MIDIAccess();
|
| - static PassRefPtrWillBeRawPtr<MIDIAccess> create(ExecutionContext*, MIDIAccessPromise*);
|
| + // Returns a promise object that will be resolved with this MIDIAccess.
|
| + static ScriptPromise request(const MIDIOptions&, ExecutionContext*);
|
|
|
| MIDIInputVector inputs() const { return m_inputs; }
|
| MIDIOutputVector outputs() const { return m_outputs; }
|
| @@ -68,7 +72,10 @@ public:
|
| virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveDOMObject::executionContext(); }
|
|
|
| // ActiveDOMObject
|
| + virtual void suspend() OVERRIDE;
|
| + virtual void resume() OVERRIDE;
|
| virtual void stop() OVERRIDE;
|
| + virtual bool hasPendingActivity() const OVERRIDE;
|
|
|
| // MIDIAccessorClient
|
| virtual void didAddInputPort(const String& id, const String& manufacturer, const String& name, const String& version) OVERRIDE;
|
| @@ -82,19 +89,36 @@ public:
|
| void trace(Visitor*);
|
|
|
| private:
|
| - MIDIAccess(ExecutionContext*, MIDIAccessPromise*);
|
| + class PostAction;
|
| + enum State {
|
| + Requesting,
|
| + Resolved,
|
| + Stopped,
|
| + };
|
| +
|
| + MIDIAccess(const MIDIOptions&, ExecutionContext*);
|
| + ScriptPromise startRequest();
|
|
|
| - void startRequest();
|
| void permissionDenied();
|
|
|
| + void resolve();
|
| + void reject(PassRefPtr<DOMError>);
|
| + void resolveNow();
|
| + void rejectNow();
|
| + // Called when the promise is resolved or rejected.
|
| + void doPostAction(State);
|
| +
|
| + State m_state;
|
| + WeakPtrFactory<MIDIAccess> m_weakPtrFactory;
|
| MIDIInputVector m_inputs;
|
| MIDIOutputVector m_outputs;
|
| - RawPtrWillBeMember<MIDIAccessPromise> m_promise;
|
| -
|
| OwnPtr<MIDIAccessor> m_accessor;
|
| - bool m_hasAccess;
|
| + OwnPtr<MIDIAccessResolver> m_resolver;
|
| + MIDIOptions m_options;
|
| bool m_sysExEnabled;
|
| - bool m_requesting;
|
| + AsyncMethodRunner<MIDIAccess> m_asyncResolveRunner;
|
| + AsyncMethodRunner<MIDIAccess> m_asyncRejectRunner;
|
| + RefPtr<DOMError> m_error;
|
| };
|
|
|
| } // namespace WebCore
|
|
|