Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / v8 / MIDIAccessResolver.cpp
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 #include "config.h"
6 #include "bindings/v8/MIDIAccessResolver.h"
7
8 #include "bindings/v8/ScriptPromiseResolver.h"
9 #include "bindings/v8/V8Binding.h"
10 #include <v8.h>
11
12 namespace WebCore {
13
14 MIDIAccessResolver::MIDIAccessResolver(PassRefPtr<ScriptPromiseResolver> resolver, v8::Isolate* isolate)
15     : m_resolver(resolver)
16     , m_world(DOMWrapperWorld::current(isolate))
17 {
18 }
19
20 MIDIAccessResolver::~MIDIAccessResolver()
21 {
22 }
23
24 void MIDIAccessResolver::resolve(MIDIAccess* access, ExecutionContext* executionContext)
25 {
26     v8::HandleScope handleScope(toIsolate(executionContext));
27     v8::Context::Scope contextScope(toV8Context(executionContext, m_world.get()));
28
29     m_resolver->resolve(access, executionContext);
30 }
31
32 void MIDIAccessResolver::reject(DOMError* error, ExecutionContext* executionContext)
33 {
34     v8::HandleScope handleScope(toIsolate(executionContext));
35     v8::Context::Scope contextScope(toV8Context(executionContext, m_world.get()));
36
37     m_resolver->reject(error, executionContext);
38 }
39
40 } // namespace WebCore