Chromium Code Reviews| Index: Source/modules/webmidi/NavigatorWebMIDI.cpp |
| diff --git a/Source/modules/webmidi/NavigatorWebMIDI.cpp b/Source/modules/webmidi/NavigatorWebMIDI.cpp |
| index 6ba4c9a92d9e9f07ef70dd480a1b21acc1e37336..45bd47a0ff608e9956df2acfeb2886854e531805 100644 |
| --- a/Source/modules/webmidi/NavigatorWebMIDI.cpp |
| +++ b/Source/modules/webmidi/NavigatorWebMIDI.cpp |
| @@ -31,11 +31,16 @@ |
| #include "config.h" |
| #include "modules/webmidi/NavigatorWebMIDI.h" |
| +#include "bindings/v8/DOMRequestState.h" |
|
haraken
2014/03/13 02:22:33
Nit: This won't be necessary. Please clean up #inc
yhirano
2014/03/13 05:43:22
Done.
|
| +#include "bindings/v8/ScriptPromise.h" |
| +#include "bindings/v8/ScriptPromiseResolver.h" |
| +#include "core/dom/DOMError.h" |
| #include "core/dom/Document.h" |
| #include "core/dom/ExecutionContext.h" |
| #include "core/frame/LocalFrame.h" |
| #include "core/frame/Navigator.h" |
| -#include "modules/webmidi/MIDIAccessPromise.h" |
| +#include "modules/webmidi/MIDIAccess.h" |
| +#include "modules/webmidi/MIDIOptions.h" |
| namespace WebCore { |
| @@ -63,20 +68,22 @@ NavigatorWebMIDI& NavigatorWebMIDI::from(Navigator& navigator) |
| return *supplement; |
| } |
| -PassRefPtrWillBeRawPtr<MIDIAccessPromise> NavigatorWebMIDI::requestMIDIAccess(Navigator& navigator, const Dictionary& options) |
| +ScriptPromise NavigatorWebMIDI::requestMIDIAccess(Navigator& navigator, const Dictionary& options) |
| { |
| return NavigatorWebMIDI::from(navigator).requestMIDIAccess(options); |
| } |
| -PassRefPtrWillBeRawPtr<MIDIAccessPromise> NavigatorWebMIDI::requestMIDIAccess(const Dictionary& options) |
| +ScriptPromise NavigatorWebMIDI::requestMIDIAccess(const Dictionary& options) |
| { |
| - if (!frame()) |
| - return nullptr; |
| - |
| - ExecutionContext* context = frame()->document(); |
| - ASSERT(context); |
| + if (!frame()) { |
| + ScriptPromise promise = ScriptPromise::createPending(); |
|
haraken
2014/03/13 02:22:33
At this point, Frame is dead. On which context is
yhirano
2014/03/13 05:43:22
It's the calling context.
requestmidiaccess-in-det
|
| + RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(promise); |
| + // FIXME: Currently this rejection does not work because the context is stopped. |
| + resolver->reject(DOMError::create("AbortError")); |
| + return promise; |
| + } |
| - return MIDIAccessPromise::create(context, options); |
| + return MIDIAccess::request(MIDIOptions(options), frame()->document()); |
| } |
| } // namespace WebCore |