| Index: third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp
|
| diff --git a/third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp b/third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp
|
| index f8f23bc6320c42579794fc092e8dc11f6d53862f..44f8a2dffe919011e88c546111a96e0c8fd856f1 100644
|
| --- a/third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp
|
| +++ b/third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp
|
| @@ -209,23 +209,26 @@ void RemotePlayback::notifyInitialAvailability(int callbackId) {
|
| }
|
|
|
| void RemotePlayback::stateChanged(WebRemotePlaybackState state) {
|
| - // We may get a "disconnected" state change while in the "disconnected"
|
| - // state if initiated connection fails. So cleanup the promise resolvers
|
| - // before checking if anything changed.
|
| - // TODO(avayvod): cleanup this logic when we implementing the "connecting"
|
| - // state.
|
| + if (m_state == state)
|
| + return;
|
| +
|
| if (m_promptPromiseResolver) {
|
| - if (state != WebRemotePlaybackState::Disconnected)
|
| - m_promptPromiseResolver->resolve();
|
| - else
|
| + // If we're trying to connect and failed, reject the promise.
|
| + // Otherwise, resolve it.
|
| + if (m_state == WebRemotePlaybackState::Connecting &&
|
| + state == WebRemotePlaybackState::Disconnected) {
|
| m_promptPromiseResolver->reject(DOMException::create(
|
| AbortError, "Failed to connect to the remote device."));
|
| + } else {
|
| + DCHECK((m_state == WebRemotePlaybackState::Disconnected &&
|
| + state == WebRemotePlaybackState::Connecting) ||
|
| + (m_state == WebRemotePlaybackState::Connected &&
|
| + state == WebRemotePlaybackState::Disconnected));
|
| + m_promptPromiseResolver->resolve();
|
| + }
|
| m_promptPromiseResolver = nullptr;
|
| }
|
|
|
| - if (m_state == state)
|
| - return;
|
| -
|
| m_state = state;
|
| switch (m_state) {
|
| case WebRemotePlaybackState::Connecting:
|
|
|