Commit ee7bbf59 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Switch AudioRendererSinkCache away from base::Bind

AudioRendererSinkCache::DeleteLaterIfUnused signature was
changed to take a scoped_refptr<> instead of raw pointer, which
is needed by WTF::UnretainedRef().

The TODO in WebAudioDeviceFactory::GetOutputDeviceInfo()
was also removed, given that other part of Blink use
base::ThreadPool::CreateSequencedTaskRunner(). The relevant aspect
is that the SequencedTaskRunner instance created operates iver
WTF::CrossThreadBind variants.

BUG=787252
R=guido@chromium.org

Change-Id: If8d7453874d13599280fbe9d3c6c2cb8fc5623c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419373
Commit-Queue: Antonio Gomes (GMT-4) <tonikitoo@igalia.com>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813249}
parent af1b2e9c
......@@ -8,13 +8,11 @@
#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/synchronization/lock.h"
#include "base/task/post_task.h"
#include "base/trace_event/trace_event.h"
#include "media/audio/audio_device_description.h"
#include "media/base/audio_renderer_sink.h"
......@@ -23,7 +21,9 @@
#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/supplementable.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
namespace blink {
......@@ -245,14 +245,15 @@ void AudioRendererSinkCache::ReleaseSink(
}
void AudioRendererSinkCache::DeleteLaterIfUnused(
const media::AudioRendererSink* sink_ptr) {
cleanup_task_runner_->PostDelayedTask(
FROM_HERE,
base::BindOnce(&AudioRendererSinkCache::DeleteSink,
// Unretained is safe here since this is a process-wide
// singleton and tests will ensure lifetime.
base::Unretained(this), base::RetainedRef(sink_ptr),
false /*do not delete if used*/),
scoped_refptr<media::AudioRendererSink> sink) {
PostDelayedCrossThreadTask(
*cleanup_task_runner_, FROM_HERE,
CrossThreadBindOnce(
&AudioRendererSinkCache::DeleteSink,
// Unretained is safe here since this is a process-wide
// singleton and tests will ensure lifetime.
CrossThreadUnretained(this), WTF::RetainedRef(std::move(sink)),
false /*do not delete if used*/),
delete_timeout_);
}
......@@ -343,7 +344,7 @@ void AudioRendererSinkCache::CacheOrStopUnusedSink(
cache_.push_back(cache_entry);
}
DeleteLaterIfUnused(cache_entry.sink.get());
DeleteLaterIfUnused(cache_entry.sink);
}
void AudioRendererSinkCache::DropSinksForFrame(
......
......@@ -74,7 +74,7 @@ class MODULES_EXPORT AudioRendererSinkCache {
// Schedules a sink for deletion. Deletion will be performed on the same
// thread the cache is created on.
void DeleteLaterIfUnused(const media::AudioRendererSink* sink_ptr);
void DeleteLaterIfUnused(scoped_refptr<media::AudioRendererSink> sink);
// Deletes a sink from the cache. If |force_delete_used| is set, a sink being
// deleted can (and should) be in use at the moment of deletion; otherwise the
......
......@@ -193,9 +193,6 @@ media::OutputDeviceInfo WebAudioDeviceFactory::GetOutputDeviceInfo(
base::TimeDelta::FromMilliseconds(5000);
// There's one process wide instance that lives on the render thread.
//
// TODO(crbug.com/787252): Replace the use of base::ThreadPool below by
// worker_pool::PostTask().
static base::NoDestructor<AudioRendererSinkCache> cache(
base::ThreadPool::CreateSequencedTaskRunner(
{base::TaskPriority::BEST_EFFORT,
......
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