Commit 44010e12 authored by Hongchan Choi's avatar Hongchan Choi Committed by Commit Bot

Remove CrossThreadUnretained wrapper when passing AudioWorkletHandler

Because AudioWorkletHandler is ThreadSafeRefCounted, wrapping with
CrossThreadUnretained() when the handler is passed via CrossThreadBind()
is unnecessary. Use scoped_refptr<> instead.

Bug: 853520
Test: All existing layout/WPT tests pass.
Change-Id: I83409b89e80a9bbb60ea98649b16efb59facbbd4
Reviewed-on: https://chromium-review.googlesource.com/1140744
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575874}
parent e1166217
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/workers/worker_clients.h" #include "third_party/blink/renderer/core/workers/worker_clients.h"
#include "third_party/blink/renderer/modules/webaudio/audio_worklet_messaging_proxy.h" #include "third_party/blink/renderer/modules/webaudio/audio_worklet_messaging_proxy.h"
#include "third_party/blink/renderer/modules/webaudio/base_audio_context.h" #include "third_party/blink/renderer/modules/webaudio/base_audio_context.h"
#include "third_party/blink/renderer/modules/webaudio/audio_worklet_node.h"
#include "third_party/blink/renderer/modules/webaudio/cross_thread_audio_worklet_processor_info.h" #include "third_party/blink/renderer/modules/webaudio/cross_thread_audio_worklet_processor_info.h"
namespace blink { namespace blink {
...@@ -23,12 +24,12 @@ AudioWorklet::AudioWorklet(BaseAudioContext* context) ...@@ -23,12 +24,12 @@ AudioWorklet::AudioWorklet(BaseAudioContext* context)
: Worklet(ToDocument(context->GetExecutionContext())), context_(context) {} : Worklet(ToDocument(context->GetExecutionContext())), context_(context) {}
void AudioWorklet::CreateProcessor( void AudioWorklet::CreateProcessor(
AudioWorkletHandler* handler, scoped_refptr<AudioWorkletHandler> handler,
MessagePortChannel message_port_channel, MessagePortChannel message_port_channel,
scoped_refptr<SerializedScriptValue> node_options) { scoped_refptr<SerializedScriptValue> node_options) {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
DCHECK(GetMessagingProxy()); DCHECK(GetMessagingProxy());
GetMessagingProxy()->CreateProcessor(handler, GetMessagingProxy()->CreateProcessor(std::move(handler),
std::move(message_port_channel), std::move(message_port_channel),
std::move(node_options)); std::move(node_options));
} }
......
...@@ -30,7 +30,7 @@ class MODULES_EXPORT AudioWorklet final : public Worklet { ...@@ -30,7 +30,7 @@ class MODULES_EXPORT AudioWorklet final : public Worklet {
~AudioWorklet() override = default; ~AudioWorklet() override = default;
void CreateProcessor(AudioWorkletHandler*, void CreateProcessor(scoped_refptr<AudioWorkletHandler>,
MessagePortChannel, MessagePortChannel,
scoped_refptr<SerializedScriptValue> node_options); scoped_refptr<SerializedScriptValue> node_options);
......
...@@ -23,7 +23,7 @@ AudioWorkletMessagingProxy::AudioWorkletMessagingProxy( ...@@ -23,7 +23,7 @@ AudioWorkletMessagingProxy::AudioWorkletMessagingProxy(
: ThreadedWorkletMessagingProxy(execution_context), worklet_(worklet) {} : ThreadedWorkletMessagingProxy(execution_context), worklet_(worklet) {}
void AudioWorkletMessagingProxy::CreateProcessor( void AudioWorkletMessagingProxy::CreateProcessor(
AudioWorkletHandler* handler, scoped_refptr<AudioWorkletHandler> handler,
MessagePortChannel message_port_channel, MessagePortChannel message_port_channel,
scoped_refptr<SerializedScriptValue> node_options) { scoped_refptr<SerializedScriptValue> node_options) {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
...@@ -33,7 +33,7 @@ void AudioWorkletMessagingProxy::CreateProcessor( ...@@ -33,7 +33,7 @@ void AudioWorkletMessagingProxy::CreateProcessor(
&AudioWorkletMessagingProxy::CreateProcessorOnRenderingThread, &AudioWorkletMessagingProxy::CreateProcessorOnRenderingThread,
WrapCrossThreadPersistent(this), WrapCrossThreadPersistent(this),
CrossThreadUnretained(GetWorkerThread()), CrossThreadUnretained(GetWorkerThread()),
CrossThreadUnretained(handler), handler,
handler->Name(), handler->Name(),
std::move(message_port_channel), std::move(message_port_channel),
std::move(node_options))); std::move(node_options)));
...@@ -41,7 +41,7 @@ void AudioWorkletMessagingProxy::CreateProcessor( ...@@ -41,7 +41,7 @@ void AudioWorkletMessagingProxy::CreateProcessor(
void AudioWorkletMessagingProxy::CreateProcessorOnRenderingThread( void AudioWorkletMessagingProxy::CreateProcessorOnRenderingThread(
WorkerThread* worker_thread, WorkerThread* worker_thread,
AudioWorkletHandler* handler, scoped_refptr<AudioWorkletHandler> handler,
const String& name, const String& name,
MessagePortChannel message_port_channel, MessagePortChannel message_port_channel,
scoped_refptr<SerializedScriptValue> node_options) { scoped_refptr<SerializedScriptValue> node_options) {
......
...@@ -28,7 +28,7 @@ class AudioWorkletMessagingProxy final : public ThreadedWorkletMessagingProxy { ...@@ -28,7 +28,7 @@ class AudioWorkletMessagingProxy final : public ThreadedWorkletMessagingProxy {
// Since the creation of AudioWorkletProcessor needs to be done in the // Since the creation of AudioWorkletProcessor needs to be done in the
// different thread, this method is a wrapper for cross-thread task posting. // different thread, this method is a wrapper for cross-thread task posting.
void CreateProcessor(AudioWorkletHandler*, void CreateProcessor(scoped_refptr<AudioWorkletHandler>,
MessagePortChannel, MessagePortChannel,
scoped_refptr<SerializedScriptValue> node_options); scoped_refptr<SerializedScriptValue> node_options);
...@@ -36,7 +36,7 @@ class AudioWorkletMessagingProxy final : public ThreadedWorkletMessagingProxy { ...@@ -36,7 +36,7 @@ class AudioWorkletMessagingProxy final : public ThreadedWorkletMessagingProxy {
// AudioWorkletProcessor. // AudioWorkletProcessor.
void CreateProcessorOnRenderingThread( void CreateProcessorOnRenderingThread(
WorkerThread*, WorkerThread*,
AudioWorkletHandler*, scoped_refptr<AudioWorkletHandler>,
const String& name, const String& name,
MessagePortChannel, MessagePortChannel,
scoped_refptr<SerializedScriptValue> node_options); scoped_refptr<SerializedScriptValue> node_options);
......
...@@ -359,7 +359,7 @@ AudioWorkletNode* AudioWorkletNode::Create( ...@@ -359,7 +359,7 @@ AudioWorkletNode* AudioWorkletNode::Create(
// This is non-blocking async call. |node| still can be returned to user // This is non-blocking async call. |node| still can be returned to user
// before the scheduled async task is completed. // before the scheduled async task is completed.
context->audioWorklet()->CreateProcessor(&node->GetWorkletHandler(), context->audioWorklet()->CreateProcessor(node->GetWorkletHandler(),
std::move(processor_port_channel), std::move(processor_port_channel),
std::move(serialized_node_options)); std::move(serialized_node_options));
...@@ -382,8 +382,8 @@ void AudioWorkletNode::FireProcessorError() { ...@@ -382,8 +382,8 @@ void AudioWorkletNode::FireProcessorError() {
DispatchEvent(Event::Create(EventTypeNames::processorerror)); DispatchEvent(Event::Create(EventTypeNames::processorerror));
} }
AudioWorkletHandler& AudioWorkletNode::GetWorkletHandler() const { scoped_refptr<AudioWorkletHandler> AudioWorkletNode::GetWorkletHandler() const {
return static_cast<AudioWorkletHandler&>(Handler()); return WrapRefCounted(&static_cast<AudioWorkletHandler&>(Handler()));
} }
void AudioWorkletNode::Trace(blink::Visitor* visitor) { void AudioWorkletNode::Trace(blink::Visitor* visitor) {
......
...@@ -99,8 +99,6 @@ class AudioWorkletNode final : public AudioNode, ...@@ -99,8 +99,6 @@ class AudioWorkletNode final : public AudioNode,
const AudioWorkletNodeOptions&, const AudioWorkletNodeOptions&,
ExceptionState&); ExceptionState&);
AudioWorkletHandler& GetWorkletHandler() const;
// ActiveScriptWrappable // ActiveScriptWrappable
bool HasPendingActivity() const final; bool HasPendingActivity() const final;
...@@ -120,6 +118,8 @@ class AudioWorkletNode final : public AudioNode, ...@@ -120,6 +118,8 @@ class AudioWorkletNode final : public AudioNode,
const Vector<CrossThreadAudioParamInfo>, const Vector<CrossThreadAudioParamInfo>,
MessagePort* node_port); MessagePort* node_port);
scoped_refptr<AudioWorkletHandler> GetWorkletHandler() const;
Member<AudioParamMap> parameter_map_; Member<AudioParamMap> parameter_map_;
Member<MessagePort> node_port_; Member<MessagePort> node_port_;
}; };
......
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