| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/webmidi/NavigatorWebMIDI.h" | 32 #include "modules/webmidi/NavigatorWebMIDI.h" |
| 33 | 33 |
| 34 #include "bindings/v8/ScriptPromise.h" | 34 #include "bindings/v8/ScriptPromise.h" |
| 35 #include "bindings/v8/ScriptPromiseResolver.h" | 35 #include "bindings/v8/ScriptPromiseResolver.h" |
| 36 #include "core/dom/AsyncInitializerResolver.h" |
| 36 #include "core/dom/DOMError.h" | 37 #include "core/dom/DOMError.h" |
| 37 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
| 38 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 39 #include "core/frame/Navigator.h" | 40 #include "core/frame/Navigator.h" |
| 40 #include "modules/webmidi/MIDIAccess.h" | 41 #include "modules/webmidi/MIDIAccess.h" |
| 42 #include "modules/webmidi/MIDIAccessInitializer.h" |
| 41 #include "modules/webmidi/MIDIOptions.h" | 43 #include "modules/webmidi/MIDIOptions.h" |
| 42 | 44 |
| 43 namespace WebCore { | 45 namespace WebCore { |
| 44 | 46 |
| 45 NavigatorWebMIDI::NavigatorWebMIDI(LocalFrame* frame) | 47 NavigatorWebMIDI::NavigatorWebMIDI(LocalFrame* frame) |
| 46 : DOMWindowProperty(frame) | 48 : DOMWindowProperty(frame) |
| 47 { | 49 { |
| 48 } | 50 } |
| 49 | 51 |
| 50 NavigatorWebMIDI::~NavigatorWebMIDI() | 52 NavigatorWebMIDI::~NavigatorWebMIDI() |
| (...skipping 23 matching lines...) Expand all Loading... |
| 74 ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, cons
t Dictionary& options) | 76 ScriptPromise NavigatorWebMIDI::requestMIDIAccess(ScriptState* scriptState, cons
t Dictionary& options) |
| 75 { | 77 { |
| 76 if (!frame() || frame()->document()->activeDOMObjectsAreStopped()) { | 78 if (!frame() || frame()->document()->activeDOMObjectsAreStopped()) { |
| 77 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(s
criptState); | 79 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(s
criptState); |
| 78 ScriptPromise promise = resolver->promise(); | 80 ScriptPromise promise = resolver->promise(); |
| 79 // FIXME: Currently this rejection does not work because the context is
stopped. | 81 // FIXME: Currently this rejection does not work because the context is
stopped. |
| 80 resolver->reject(DOMError::create("AbortError")); | 82 resolver->reject(DOMError::create("AbortError")); |
| 81 return promise; | 83 return promise; |
| 82 } | 84 } |
| 83 | 85 |
| 84 return MIDIAccess::request(MIDIOptions(options), scriptState); | 86 return AsyncInitializerResolver<MIDIAccessInitializer>::createAndStart(scrip
tState, MIDIAccessInitializer::create(MIDIOptions(options))); |
| 85 } | 87 } |
| 86 | 88 |
| 87 } // namespace WebCore | 89 } // namespace WebCore |
| OLD | NEW |