Commit 491305e0 authored by Thomas Guilbert's avatar Thomas Guilbert Committed by Commit Bot

Cleanup on RemotePlayback stop

Currently, successfully starting/stopping/starting RemotePlayback runs
into a DCHECK, because we never properly clean up on RemotePlayback
stop. This CL fixes the issue and gets rid of a TODO.

Bug: 790766
Change-Id: Ieca32cd175741e5c1ae7e55879ae4a224d67b76c
Reviewed-on: https://chromium-review.googlesource.com/c/1260282Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: Thomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596435}
parent 8e5892fb
...@@ -227,8 +227,7 @@ bool RemotePlayback::HasPendingActivity() const { ...@@ -227,8 +227,7 @@ bool RemotePlayback::HasPendingActivity() const {
} }
void RemotePlayback::ContextDestroyed(ExecutionContext*) { void RemotePlayback::ContextDestroyed(ExecutionContext*) {
target_presentation_connection_.reset(); CleanupConnections();
presentation_connection_binding_.Close();
} }
void RemotePlayback::PromptInternal() { void RemotePlayback::PromptInternal() {
...@@ -369,7 +368,9 @@ void RemotePlayback::StateChanged(WebRemotePlaybackState state) { ...@@ -369,7 +368,9 @@ void RemotePlayback::StateChanged(WebRemotePlaybackState state) {
->MediaRemotingStopped( ->MediaRemotingStopped(
WebLocalizedString::kMediaRemotingStopNoText); WebLocalizedString::kMediaRemotingStopNoText);
} }
CleanupConnections();
presentation_id_ = ""; presentation_id_ = "";
presentation_url_ = KURL();
media_element_->FlingingStopped(); media_element_->FlingingStopped();
} }
break; break;
...@@ -465,6 +466,11 @@ void RemotePlayback::RemotePlaybackDisabled() { ...@@ -465,6 +466,11 @@ void RemotePlayback::RemotePlaybackDisabled() {
} }
} }
void RemotePlayback::CleanupConnections() {
target_presentation_connection_.reset();
presentation_connection_binding_.Close();
}
void RemotePlayback::AvailabilityChanged( void RemotePlayback::AvailabilityChanged(
mojom::blink::ScreenAvailability availability) { mojom::blink::ScreenAvailability availability) {
DCHECK(RuntimeEnabledFeatures::NewRemotePlaybackPipelineEnabled()); DCHECK(RuntimeEnabledFeatures::NewRemotePlaybackPipelineEnabled());
...@@ -511,7 +517,6 @@ void RemotePlayback::OnConnectionSuccess( ...@@ -511,7 +517,6 @@ void RemotePlayback::OnConnectionSuccess(
StateChanged(WebRemotePlaybackState::kConnecting); StateChanged(WebRemotePlaybackState::kConnecting);
// TODO(imcheng): Reset binding when remote playback stops.
DCHECK(!presentation_connection_binding_.is_bound()); DCHECK(!presentation_connection_binding_.is_bound());
auto* presentation_controller = auto* presentation_controller =
PresentationController::FromContext(GetExecutionContext()); PresentationController::FromContext(GetExecutionContext());
......
...@@ -150,6 +150,9 @@ class MODULES_EXPORT RemotePlayback final ...@@ -150,6 +150,9 @@ class MODULES_EXPORT RemotePlayback final
// May be called more than once in a row. // May be called more than once in a row.
void StopListeningForAvailability(); void StopListeningForAvailability();
// Clears bindings after remote playback stops.
void CleanupConnections();
WebRemotePlaybackState state_; WebRemotePlaybackState state_;
WebRemotePlaybackAvailability availability_; WebRemotePlaybackAvailability availability_;
HeapHashMap<int, TraceWrapperMember<AvailabilityCallbackWrapper>> HeapHashMap<int, TraceWrapperMember<AvailabilityCallbackWrapper>>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment