Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / v8 / MIDIAccessResolver.h
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
3 // found in the LICENSE file.
4
5 #ifndef MIDIAccessResolver_h
6 #define MIDIAccessResolver_h
7
8 #include "bindings/v8/ScriptPromiseResolver.h"
9 #include "wtf/OwnPtr.h"
10 #include "wtf/RefCounted.h"
11
12 namespace WebCore {
13
14 class DOMError;
15 class DOMWrapperWorld;
16 class ExecutionContext;
17 class MIDIAccess;
18
19 class MIDIAccessResolver {
20     WTF_MAKE_NONCOPYABLE(MIDIAccessResolver);
21 public:
22     static PassOwnPtr<MIDIAccessResolver> create(PassRefPtr<ScriptPromiseResolver> resolver, v8::Isolate* isolate)
23     {
24         return adoptPtr(new MIDIAccessResolver(resolver, isolate));
25     }
26     ~MIDIAccessResolver();
27
28     ScriptPromise promise() { return m_resolver->promise(); }
29
30     void resolve(MIDIAccess*, ExecutionContext*);
31     void reject(DOMError*, ExecutionContext*);
32
33 private:
34     MIDIAccessResolver(PassRefPtr<ScriptPromiseResolver>, v8::Isolate*);
35
36     RefPtr<ScriptPromiseResolver> m_resolver;
37     RefPtr<DOMWrapperWorld> m_world;
38 };
39
40 } // namespace WebCore
41
42 #endif // #ifndef MIDIAccessResolver_h