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 @@
#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/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"
namespace blink {
......@@ -23,12 +24,12 @@ AudioWorklet::AudioWorklet(BaseAudioContext* context)
: Worklet(ToDocument(context->GetExecutionContext())), context_(context) {}
void AudioWorklet::CreateProcessor(
AudioWorkletHandler* handler,
scoped_refptr<AudioWorkletHandler> handler,
MessagePortChannel message_port_channel,
scoped_refptr<SerializedScriptValue> node_options) {
DCHECK(IsMainThread());
DCHECK(GetMessagingProxy());
GetMessagingProxy()->CreateProcessor(handler,
GetMessagingProxy()->CreateProcessor(std::move(handler),
std::move(message_port_channel),
std::move(node_options));
}
......
......@@ -30,7 +30,7 @@ class MODULES_EXPORT AudioWorklet final : public Worklet {
~AudioWorklet() override = default;
void CreateProcessor(AudioWorkletHandler*,
void CreateProcessor(scoped_refptr<AudioWorkletHandler>,
MessagePortChannel,
scoped_refptr<SerializedScriptValue> node_options);
......
......@@ -23,7 +23,7 @@ AudioWorkletMessagingProxy::AudioWorkletMessagingProxy(
: ThreadedWorkletMessagingProxy(execution_context), worklet_(worklet) {}
void AudioWorkletMessagingProxy::CreateProcessor(
AudioWorkletHandler* handler,
scoped_refptr<AudioWorkletHandler> handler,
MessagePortChannel message_port_channel,
scoped_refptr<SerializedScriptValue> node_options) {
DCHECK(IsMainThread());
......@@ -33,7 +33,7 @@ void AudioWorkletMessagingProxy::CreateProcessor(
&AudioWorkletMessagingProxy::CreateProcessorOnRenderingThread,
WrapCrossThreadPersistent(this),
CrossThreadUnretained(GetWorkerThread()),
CrossThreadUnretained(handler),
handler,
handler->Name(),
std::move(message_port_channel),
std::move(node_options)));
......@@ -41,7 +41,7 @@ void AudioWorkletMessagingProxy::CreateProcessor(
void AudioWorkletMessagingProxy::CreateProcessorOnRenderingThread(
WorkerThread* worker_thread,
AudioWorkletHandler* handler,
scoped_refptr<AudioWorkletHandler> handler,
const String& name,
MessagePortChannel message_port_channel,
scoped_refptr<SerializedScriptValue> node_options) {
......
......@@ -28,7 +28,7 @@ class AudioWorkletMessagingProxy final : public ThreadedWorkletMessagingProxy {
// Since the creation of AudioWorkletProcessor needs to be done in the
// different thread, this method is a wrapper for cross-thread task posting.
void CreateProcessor(AudioWorkletHandler*,
void CreateProcessor(scoped_refptr<AudioWorkletHandler>,
MessagePortChannel,
scoped_refptr<SerializedScriptValue> node_options);
......@@ -36,7 +36,7 @@ class AudioWorkletMessagingProxy final : public ThreadedWorkletMessagingProxy {
// AudioWorkletProcessor.
void CreateProcessorOnRenderingThread(
WorkerThread*,
AudioWorkletHandler*,
scoped_refptr<AudioWorkletHandler>,
const String& name,
MessagePortChannel,
scoped_refptr<SerializedScriptValue> node_options);
......
......@@ -359,7 +359,7 @@ AudioWorkletNode* AudioWorkletNode::Create(
// This is non-blocking async call. |node| still can be returned to user
// before the scheduled async task is completed.
context->audioWorklet()->CreateProcessor(&node->GetWorkletHandler(),
context->audioWorklet()->CreateProcessor(node->GetWorkletHandler(),
std::move(processor_port_channel),
std::move(serialized_node_options));
......@@ -382,8 +382,8 @@ void AudioWorkletNode::FireProcessorError() {
DispatchEvent(Event::Create(EventTypeNames::processorerror));
}
AudioWorkletHandler& AudioWorkletNode::GetWorkletHandler() const {
return static_cast<AudioWorkletHandler&>(Handler());
scoped_refptr<AudioWorkletHandler> AudioWorkletNode::GetWorkletHandler() const {
return WrapRefCounted(&static_cast<AudioWorkletHandler&>(Handler()));
}
void AudioWorkletNode::Trace(blink::Visitor* visitor) {
......
......@@ -99,8 +99,6 @@ class AudioWorkletNode final : public AudioNode,
const AudioWorkletNodeOptions&,
ExceptionState&);
AudioWorkletHandler& GetWorkletHandler() const;
// ActiveScriptWrappable
bool HasPendingActivity() const final;
......@@ -120,6 +118,8 @@ class AudioWorkletNode final : public AudioNode,
const Vector<CrossThreadAudioParamInfo>,
MessagePort* node_port);
scoped_refptr<AudioWorkletHandler> GetWorkletHandler() const;
Member<AudioParamMap> parameter_map_;
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