Commit ecb28473 authored by tzik's avatar tzik Committed by Commit Bot

Avoid storing rtc::RefCountInterface to base::scoped_refptr

Some WebRTC's ref-counted objects are implicitly stored into
base::scoped_refptr instead of rtc::scoped_refptr through base::Bind.
And an upcoming base::Bind update disables this case of auto wrapping.

This CL replaces it to rtc::scoped_refptr by wrapping the pointer with
rtc::scoped_refptr explicitly.

Bug: 866456
Change-Id: Id8a9dd622f5aa5b9c843ec7ec43e0d390a0777db
Reviewed-on: https://chromium-review.googlesource.com/1145147Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578498}
parent 7af2637c
...@@ -777,7 +777,8 @@ int MediaStreamAudioProcessor::ProcessData(const float* const* process_ptrs, ...@@ -777,7 +777,8 @@ int MediaStreamAudioProcessor::ProcessData(const float* const* process_ptrs,
main_thread_runner_->PostTask( main_thread_runner_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&MediaStreamAudioProcessor::UpdateAecStats, this)); base::BindOnce(&MediaStreamAudioProcessor::UpdateAecStats,
rtc::scoped_refptr<MediaStreamAudioProcessor>(this)));
// Return 0 if the volume hasn't been changed, and otherwise the new volume. // Return 0 if the volume hasn't been changed, and otherwise the new volume.
return (agc->stream_analog_level() == volume) ? return (agc->stream_analog_level() == volume) ?
......
...@@ -344,8 +344,10 @@ class CreateSessionDescriptionRequest ...@@ -344,8 +344,10 @@ class CreateSessionDescriptionRequest
void OnSuccess(webrtc::SessionDescriptionInterface* desc) override { void OnSuccess(webrtc::SessionDescriptionInterface* desc) override {
if (!main_thread_->BelongsToCurrentThread()) { if (!main_thread_->BelongsToCurrentThread()) {
main_thread_->PostTask( main_thread_->PostTask(
FROM_HERE, base::BindOnce(&CreateSessionDescriptionRequest::OnSuccess, FROM_HERE,
this, desc)); base::BindOnce(
&CreateSessionDescriptionRequest::OnSuccess,
rtc::scoped_refptr<CreateSessionDescriptionRequest>(this), desc));
return; return;
} }
...@@ -365,8 +367,11 @@ class CreateSessionDescriptionRequest ...@@ -365,8 +367,11 @@ class CreateSessionDescriptionRequest
void OnFailure(webrtc::RTCError error) override { void OnFailure(webrtc::RTCError error) override {
if (!main_thread_->BelongsToCurrentThread()) { if (!main_thread_->BelongsToCurrentThread()) {
main_thread_->PostTask( main_thread_->PostTask(
FROM_HERE, base::BindOnce(&CreateSessionDescriptionRequest::OnFailure, FROM_HERE,
this, std::move(error))); base::BindOnce(
&CreateSessionDescriptionRequest::OnFailure,
rtc::scoped_refptr<CreateSessionDescriptionRequest>(this),
std::move(error)));
return; return;
} }
...@@ -443,7 +448,8 @@ class StatsResponse : public webrtc::StatsObserver { ...@@ -443,7 +448,8 @@ class StatsResponse : public webrtc::StatsObserver {
main_thread_->PostTaskAndReply( main_thread_->PostTaskAndReply(
FROM_HERE, FROM_HERE,
base::BindOnce(&StatsResponse::DeliverCallback, this, base::BindOnce(&StatsResponse::DeliverCallback,
rtc::scoped_refptr<StatsResponse>(this),
base::Unretained(report_copies)), base::Unretained(report_copies)),
base::BindOnce(&StatsResponse::DeleteReports, base::BindOnce(&StatsResponse::DeleteReports,
base::Unretained(report_copies))); base::Unretained(report_copies)));
......
...@@ -322,8 +322,8 @@ void RTCStatsCollectorCallbackImpl::OnStatsDelivered( ...@@ -322,8 +322,8 @@ void RTCStatsCollectorCallbackImpl::OnStatsDelivered(
main_thread_->PostTask( main_thread_->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
&RTCStatsCollectorCallbackImpl::OnStatsDeliveredOnMainThread, this, &RTCStatsCollectorCallbackImpl::OnStatsDeliveredOnMainThread,
report)); rtc::scoped_refptr<RTCStatsCollectorCallbackImpl>(this), report));
} }
void RTCStatsCollectorCallbackImpl::OnStatsDeliveredOnMainThread( void RTCStatsCollectorCallbackImpl::OnStatsDeliveredOnMainThread(
......
...@@ -534,8 +534,10 @@ void WebRtcAudioRenderer::UpdateSourceVolume( ...@@ -534,8 +534,10 @@ void WebRtcAudioRenderer::UpdateSourceVolume(
// object is an exception (bug?). So, to work around that, we need to make // object is an exception (bug?). So, to work around that, we need to make
// sure we call SetVolume on the signaling thread. // sure we call SetVolume on the signaling thread.
signaling_thread_->PostTask( signaling_thread_->PostTask(
FROM_HERE, base::BindOnce(&webrtc::AudioSourceInterface::SetVolume, FROM_HERE,
source, volume)); base::BindOnce(&webrtc::AudioSourceInterface::SetVolume,
rtc::scoped_refptr<webrtc::AudioSourceInterface>(source),
volume));
} else { } else {
source->SetVolume(volume); source->SetVolume(volume);
} }
......
...@@ -440,7 +440,8 @@ HRESULT RdpClientWindow::OnLoginComplete() { ...@@ -440,7 +440,8 @@ HRESULT RdpClientWindow::OnLoginComplete() {
apply_resolution_attempts_ = 0; apply_resolution_attempts_ = 0;
apply_resolution_timer_.Start( apply_resolution_timer_.Start(
FROM_HERE, kReapplyResolutionPeriod, FROM_HERE, kReapplyResolutionPeriod,
base::Bind(&RdpClientWindow::ReapplyDesktopResolution, this)); base::BindRepeating(&RdpClientWindow::ReapplyDesktopResolution,
Microsoft::WRL::ComPtr<RdpClientWindow>(this)));
} }
return S_OK; return S_OK;
......
...@@ -144,8 +144,8 @@ int32_t WebrtcAudioModule::StartPlayout() { ...@@ -144,8 +144,8 @@ int32_t WebrtcAudioModule::StartPlayout() {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
if (!playing_ && audio_task_runner_) { if (!playing_ && audio_task_runner_) {
audio_task_runner_->PostTask( audio_task_runner_->PostTask(
FROM_HERE, FROM_HERE, base::BindOnce(&WebrtcAudioModule::StartPlayoutOnAudioThread,
base::Bind(&WebrtcAudioModule::StartPlayoutOnAudioThread, this)); rtc::scoped_refptr<WebrtcAudioModule>(this)));
playing_ = true; playing_ = true;
} }
return 0; return 0;
...@@ -155,8 +155,8 @@ int32_t WebrtcAudioModule::StopPlayout() { ...@@ -155,8 +155,8 @@ int32_t WebrtcAudioModule::StopPlayout() {
base::AutoLock auto_lock(lock_); base::AutoLock auto_lock(lock_);
if (playing_) { if (playing_) {
audio_task_runner_->PostTask( audio_task_runner_->PostTask(
FROM_HERE, FROM_HERE, base::BindOnce(&WebrtcAudioModule::StopPlayoutOnAudioThread,
base::Bind(&WebrtcAudioModule::StopPlayoutOnAudioThread, this)); rtc::scoped_refptr<WebrtcAudioModule>(this)));
playing_ = false; playing_ = false;
} }
return 0; return 0;
...@@ -353,9 +353,9 @@ int WebrtcAudioModule::GetRecordAudioParameters( ...@@ -353,9 +353,9 @@ int WebrtcAudioModule::GetRecordAudioParameters(
void WebrtcAudioModule::StartPlayoutOnAudioThread() { void WebrtcAudioModule::StartPlayoutOnAudioThread() {
DCHECK(audio_task_runner_->BelongsToCurrentThread()); DCHECK(audio_task_runner_->BelongsToCurrentThread());
poll_timer_ = std::make_unique<base::RepeatingTimer>(); poll_timer_ = std::make_unique<base::RepeatingTimer>();
poll_timer_->Start( poll_timer_->Start(FROM_HERE, kPollInterval,
FROM_HERE, kPollInterval, base::BindRepeating(&WebrtcAudioModule::PollFromSource,
base::Bind(&WebrtcAudioModule::PollFromSource, base::Unretained(this))); base::Unretained(this)));
} }
void WebrtcAudioModule::StopPlayoutOnAudioThread() { void WebrtcAudioModule::StopPlayoutOnAudioThread() {
......
...@@ -139,20 +139,24 @@ void TaskQueue::Impl::Stop() { ...@@ -139,20 +139,24 @@ void TaskQueue::Impl::Stop() {
WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL, WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL,
WaitableEvent::InitialState::NOT_SIGNALED); WaitableEvent::InitialState::NOT_SIGNALED);
task_runner_->PostTask( task_runner_->PostTask(
FROM_HERE, base::BindOnce(&TaskQueue::Impl::Deactivate, this, &event)); FROM_HERE, base::BindOnce(&TaskQueue::Impl::Deactivate,
rtc::scoped_refptr<Impl>(this), &event));
event.Wait(); event.Wait();
} }
void TaskQueue::Impl::PostTask(std::unique_ptr<QueuedTask> task) { void TaskQueue::Impl::PostTask(std::unique_ptr<QueuedTask> task) {
task_runner_->PostTask(FROM_HERE, base::BindOnce(&TaskQueue::Impl::RunTask, task_runner_->PostTask(
this, base::Passed(&task))); FROM_HERE,
base::BindOnce(&TaskQueue::Impl::RunTask, rtc::scoped_refptr<Impl>(this),
std::move(task)));
} }
void TaskQueue::Impl::PostDelayedTask(std::unique_ptr<QueuedTask> task, void TaskQueue::Impl::PostDelayedTask(std::unique_ptr<QueuedTask> task,
uint32_t milliseconds) { uint32_t milliseconds) {
task_runner_->PostDelayedTask( task_runner_->PostDelayedTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&TaskQueue::Impl::RunTask, this, base::Passed(&task)), base::BindOnce(&TaskQueue::Impl::RunTask, rtc::scoped_refptr<Impl>(this),
std::move(task)),
base::TimeDelta::FromMilliseconds(milliseconds)); base::TimeDelta::FromMilliseconds(milliseconds));
} }
......
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