Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(707)

Unified Diff: third_party/WebKit/Source/modules/remoteplayback/RemotePlayback.cpp

Issue 2464163004: [RemotePlayback] Implement 'connecting' state (Closed)
Patch Set: Fixed mocks Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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:

Powered by Google App Engine
This is Rietveld 408576698