| Index: third_party/WebKit/Source/modules/webmidi/MIDIAccessInitializer.cpp
|
| diff --git a/third_party/WebKit/Source/modules/webmidi/MIDIAccessInitializer.cpp b/third_party/WebKit/Source/modules/webmidi/MIDIAccessInitializer.cpp
|
| index d4aa75d1e12d86e454743c73ef45d92dedae9bed..4e89d8c998a131346906ab9f8c581ce9311b34b9 100644
|
| --- a/third_party/WebKit/Source/modules/webmidi/MIDIAccessInitializer.cpp
|
| +++ b/third_party/WebKit/Source/modules/webmidi/MIDIAccessInitializer.cpp
|
| @@ -85,34 +85,26 @@ void MIDIAccessInitializer::didSetOutputPortState(unsigned portIndex,
|
| NOTREACHED();
|
| }
|
|
|
| -void MIDIAccessInitializer::didStartSession(bool success,
|
| - const String& error,
|
| - const String& message) {
|
| +void MIDIAccessInitializer::didStartSession(media::midi::Result result) {
|
| DCHECK(m_accessor);
|
| - if (success) {
|
| - resolve(MIDIAccess::create(std::move(m_accessor),
|
| - m_options.hasSysex() && m_options.sysex(),
|
| - m_portDescriptors, getExecutionContext()));
|
| - } else {
|
| - // The spec says the name is one of
|
| - // - SecurityError
|
| - // - AbortError
|
| - // - InvalidStateError
|
| - // - NotSupportedError
|
| - // TODO(toyoshim): Do not rely on |error| string. Instead an enum
|
| - // representing an ExceptionCode should be defined and deliverred.
|
| - ExceptionCode ec = InvalidStateError;
|
| - if (error == DOMException::getErrorName(SecurityError)) {
|
| - ec = SecurityError;
|
| - } else if (error == DOMException::getErrorName(AbortError)) {
|
| - ec = AbortError;
|
| - } else if (error == DOMException::getErrorName(InvalidStateError)) {
|
| - ec = InvalidStateError;
|
| - } else if (error == DOMException::getErrorName(NotSupportedError)) {
|
| - ec = NotSupportedError;
|
| - }
|
| - reject(DOMException::create(ec, message));
|
| + // We would also have AbortError and SecurityError according to the spec.
|
| + // SecurityError is handled in onPermission(s)Updated().
|
| + switch (result) {
|
| + case media::midi::Result::NOT_INITIALIZED:
|
| + break;
|
| + case media::midi::Result::OK:
|
| + return resolve(MIDIAccess::create(
|
| + std::move(m_accessor), m_options.hasSysex() && m_options.sysex(),
|
| + m_portDescriptors, getExecutionContext()));
|
| + case media::midi::Result::NOT_SUPPORTED:
|
| + return reject(DOMException::create(NotSupportedError));
|
| + case media::midi::Result::INITIALIZATION_ERROR:
|
| + return reject(DOMException::create(
|
| + InvalidStateError, "Platform dependent initialization failed."));
|
| }
|
| + NOTREACHED();
|
| + reject(DOMException::create(InvalidStateError,
|
| + "Unknown internal error occurred."));
|
| }
|
|
|
| ExecutionContext* MIDIAccessInitializer::getExecutionContext() const {
|
|
|