Commit 56694070 authored by Minoru Chikamune's avatar Minoru Chikamune Committed by Commit Bot

Migrate RemotePlayback to use GC mojo wrappers.

No behavior change. This CL reduces potential risks of use-after-free bugs.

Bug: 1049056
Change-Id: Ib5730a2d4ef21520c2032c7a010c00e84812e387
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2169433
Commit-Queue: Minoru Chikamune <chikamune@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#766287}
parent 207cebd2
...@@ -96,7 +96,9 @@ RemotePlayback::RemotePlayback(HTMLMediaElement& element) ...@@ -96,7 +96,9 @@ RemotePlayback::RemotePlayback(HTMLMediaElement& element)
state_(mojom::blink::PresentationConnectionState::CLOSED), state_(mojom::blink::PresentationConnectionState::CLOSED),
availability_(mojom::ScreenAvailability::UNKNOWN), availability_(mojom::ScreenAvailability::UNKNOWN),
media_element_(&element), media_element_(&element),
is_listening_(false) {} is_listening_(false),
presentation_connection_receiver_(this, element.GetExecutionContext()),
target_presentation_connection_(element.GetExecutionContext()) {}
const AtomicString& RemotePlayback::InterfaceName() const { const AtomicString& RemotePlayback::InterfaceName() const {
return event_target_names::kRemotePlayback; return event_target_names::kRemotePlayback;
...@@ -244,10 +246,6 @@ bool RemotePlayback::HasPendingActivity() const { ...@@ -244,10 +246,6 @@ bool RemotePlayback::HasPendingActivity() const {
prompt_promise_resolver_; prompt_promise_resolver_;
} }
void RemotePlayback::ContextDestroyed() {
CleanupConnections();
}
void RemotePlayback::PromptInternal() { void RemotePlayback::PromptInternal() {
if (!GetExecutionContext()) if (!GetExecutionContext())
return; return;
...@@ -528,9 +526,12 @@ void RemotePlayback::OnConnectionSuccess( ...@@ -528,9 +526,12 @@ void RemotePlayback::OnConnectionSuccess(
return; return;
// Note: Messages on |connection_receiver| are ignored. // Note: Messages on |connection_receiver| are ignored.
target_presentation_connection_.Bind(std::move(result->connection_remote)); target_presentation_connection_.Bind(
std::move(result->connection_remote),
GetExecutionContext()->GetTaskRunner(TaskType::kMediaElementEvent));
presentation_connection_receiver_.Bind( presentation_connection_receiver_.Bind(
std::move(result->connection_receiver)); std::move(result->connection_receiver),
GetExecutionContext()->GetTaskRunner(TaskType::kMediaElementEvent));
} }
void RemotePlayback::OnConnectionError( void RemotePlayback::OnConnectionError(
...@@ -608,6 +609,8 @@ void RemotePlayback::Trace(Visitor* visitor) { ...@@ -608,6 +609,8 @@ void RemotePlayback::Trace(Visitor* visitor) {
visitor->Trace(availability_callbacks_); visitor->Trace(availability_callbacks_);
visitor->Trace(prompt_promise_resolver_); visitor->Trace(prompt_promise_resolver_);
visitor->Trace(media_element_); visitor->Trace(media_element_);
visitor->Trace(presentation_connection_receiver_);
visitor->Trace(target_presentation_connection_);
visitor->Trace(observers_); visitor->Trace(observers_);
EventTargetWithInlineData::Trace(visitor); EventTargetWithInlineData::Trace(visitor);
ExecutionContextLifecycleObserver::Trace(visitor); ExecutionContextLifecycleObserver::Trace(visitor);
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#define THIRD_PARTY_BLINK_RENDERER_MODULES_REMOTEPLAYBACK_REMOTE_PLAYBACK_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_REMOTEPLAYBACK_REMOTE_PLAYBACK_H_
#include "base/macros.h" #include "base/macros.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/mojom/presentation/presentation.mojom-blink.h" #include "third_party/blink/public/mojom/presentation/presentation.mojom-blink.h"
#include "third_party/blink/public/platform/modules/remoteplayback/web_remote_playback_client.h" #include "third_party/blink/public/platform/modules/remoteplayback/web_remote_playback_client.h"
#include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/platform/web_url.h"
...@@ -20,6 +18,9 @@ ...@@ -20,6 +18,9 @@
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
#include "third_party/blink/renderer/modules/presentation/presentation_availability_observer.h" #include "third_party/blink/renderer/modules/presentation/presentation_availability_observer.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_receiver.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_wrapper_mode.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" #include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
...@@ -126,7 +127,7 @@ class MODULES_EXPORT RemotePlayback final ...@@ -126,7 +127,7 @@ class MODULES_EXPORT RemotePlayback final
bool HasPendingActivity() const final; bool HasPendingActivity() const final;
// ExecutionContextLifecycleObserver implementation. // ExecutionContextLifecycleObserver implementation.
void ContextDestroyed() override; void ContextDestroyed() override {}
// Adjusts the internal state of |this| after a playback state change. // Adjusts the internal state of |this| after a playback state change.
void StateChanged(mojom::blink::PresentationConnectionState); void StateChanged(mojom::blink::PresentationConnectionState);
...@@ -171,9 +172,9 @@ class MODULES_EXPORT RemotePlayback final ...@@ -171,9 +172,9 @@ class MODULES_EXPORT RemotePlayback final
String presentation_id_; String presentation_id_;
KURL presentation_url_; KURL presentation_url_;
mojo::Receiver<mojom::blink::PresentationConnection> HeapMojoReceiver<mojom::blink::PresentationConnection, RemotePlayback>
presentation_connection_receiver_{this}; presentation_connection_receiver_;
mojo::Remote<mojom::blink::PresentationConnection> HeapMojoRemote<mojom::blink::PresentationConnection>
target_presentation_connection_; target_presentation_connection_;
HeapHashSet<Member<RemotePlaybackObserver>> observers_; HeapHashSet<Member<RemotePlaybackObserver>> observers_;
......
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