Commit 187b7adc authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

media: Remove SequencedTaskRunnerHandle::Get() usages in UserMediaClientImpl

This is part of efforts to replace base::ThreadTaskRunnerHandle::Get()
and SequencedTaskRunnerHandle::Get() with other appropriate task runners
in the renderer.

Bug: 827065
Change-Id: I07e9d3d051c0d4b01aeeafd86e06716ed8473af7
Reviewed-on: https://chromium-review.googlesource.com/987594
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548719}
parent 9c40479a
......@@ -40,8 +40,10 @@ void RequestSucceeded(blink::WebApplyConstraintsRequest request) {
} // namespace
ApplyConstraintsProcessor::ApplyConstraintsProcessor(
MediaDevicesDispatcherCallback media_devices_dispatcher_cb)
MediaDevicesDispatcherCallback media_devices_dispatcher_cb,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: media_devices_dispatcher_cb_(std::move(media_devices_dispatcher_cb)),
task_runner_(std::move(task_runner)),
weak_factory_(this) {}
ApplyConstraintsProcessor::~ApplyConstraintsProcessor() {
......@@ -308,7 +310,7 @@ bool ApplyConstraintsProcessor::AbortIfVideoRequestStateInvalid() {
}
void ApplyConstraintsProcessor::ApplyConstraintsSucceeded() {
base::SequencedTaskRunnerHandle::Get()->PostTask(
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&ApplyConstraintsProcessor::CleanupRequest,
weak_factory_.GetWeakPtr(),
......@@ -318,7 +320,7 @@ void ApplyConstraintsProcessor::ApplyConstraintsSucceeded() {
void ApplyConstraintsProcessor::ApplyConstraintsFailed(
const char* failed_constraint_name) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::SequencedTaskRunnerHandle::Get()->PostTask(
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&ApplyConstraintsProcessor::CleanupRequest,
......@@ -332,7 +334,7 @@ void ApplyConstraintsProcessor::ApplyConstraintsFailed(
void ApplyConstraintsProcessor::CannotApplyConstraints(
const blink::WebString& message) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::SequencedTaskRunnerHandle::Get()->PostTask(
task_runner_->PostTask(
FROM_HERE, base::BindOnce(&ApplyConstraintsProcessor::CleanupRequest,
weak_factory_.GetWeakPtr(),
base::BindOnce(&RequestFailed, current_request_,
......
......@@ -34,7 +34,8 @@ class CONTENT_EXPORT ApplyConstraintsProcessor {
using MediaDevicesDispatcherCallback = base::RepeatingCallback<
const blink::mojom::MediaDevicesDispatcherHostPtr&()>;
ApplyConstraintsProcessor(
MediaDevicesDispatcherCallback media_devices_dispatcher_cb);
MediaDevicesDispatcherCallback media_devices_dispatcher_cb,
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
~ApplyConstraintsProcessor();
// Starts processing of |request|. When processing of |request| is complete,
......@@ -84,6 +85,8 @@ class CONTENT_EXPORT ApplyConstraintsProcessor {
MediaDevicesDispatcherCallback media_devices_dispatcher_cb_;
SEQUENCE_CHECKER(sequence_checker_);
const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
base::WeakPtrFactory<ApplyConstraintsProcessor> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ApplyConstraintsProcessor);
......
......@@ -87,12 +87,14 @@ UserMediaClientImpl::Request::MoveUserMediaRequest() {
UserMediaClientImpl::UserMediaClientImpl(
RenderFrameImpl* render_frame,
std::unique_ptr<UserMediaProcessor> user_media_processor)
std::unique_ptr<UserMediaProcessor> user_media_processor,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: RenderFrameObserver(render_frame),
user_media_processor_(std::move(user_media_processor)),
apply_constraints_processor_(new ApplyConstraintsProcessor(
base::BindRepeating(&UserMediaClientImpl::GetMediaDevicesDispatcher,
base::Unretained(this)))),
base::Unretained(this)),
std::move(task_runner))),
weak_factory_(this) {}
// base::Unretained(this) is safe here because |this| owns
......@@ -100,7 +102,8 @@ UserMediaClientImpl::UserMediaClientImpl(
UserMediaClientImpl::UserMediaClientImpl(
RenderFrameImpl* render_frame,
PeerConnectionDependencyFactory* dependency_factory,
std::unique_ptr<MediaStreamDeviceObserver> media_stream_device_observer)
std::unique_ptr<MediaStreamDeviceObserver> media_stream_device_observer,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: UserMediaClientImpl(
render_frame,
std::make_unique<UserMediaProcessor>(
......@@ -109,7 +112,8 @@ UserMediaClientImpl::UserMediaClientImpl(
std::move(media_stream_device_observer),
base::BindRepeating(
&UserMediaClientImpl::GetMediaDevicesDispatcher,
base::Unretained(this)))) {}
base::Unretained(this))),
std::move(task_runner)) {}
UserMediaClientImpl::~UserMediaClientImpl() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
......@@ -40,9 +40,11 @@ class CONTENT_EXPORT UserMediaClientImpl : public RenderFrameObserver,
UserMediaClientImpl(
RenderFrameImpl* render_frame,
PeerConnectionDependencyFactory* dependency_factory,
std::unique_ptr<MediaStreamDeviceObserver> media_stream_device_observer);
std::unique_ptr<MediaStreamDeviceObserver> media_stream_device_observer,
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
UserMediaClientImpl(RenderFrameImpl* render_frame,
std::unique_ptr<UserMediaProcessor> user_media_processor);
std::unique_ptr<UserMediaProcessor> user_media_processor,
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
~UserMediaClientImpl() override;
MediaStreamDeviceObserver* media_stream_device_observer() const {
......
......@@ -394,7 +394,10 @@ class UserMediaClientImplUnderTest : public UserMediaClientImpl {
public:
UserMediaClientImplUnderTest(UserMediaProcessor* user_media_processor,
RequestState* state)
: UserMediaClientImpl(nullptr, base::WrapUnique(user_media_processor)),
: UserMediaClientImpl(
nullptr,
base::WrapUnique(user_media_processor),
blink::scheduler::GetSingleThreadTaskRunnerForTesting()),
state_(state) {}
void RequestUserMediaForTest(
......
......@@ -6846,7 +6846,8 @@ void RenderFrameImpl::InitializeUserMediaClient() {
DCHECK(!web_user_media_client_);
web_user_media_client_ = new UserMediaClientImpl(
this, RenderThreadImpl::current()->GetPeerConnectionDependencyFactory(),
std::make_unique<MediaStreamDeviceObserver>(this));
std::make_unique<MediaStreamDeviceObserver>(this),
GetTaskRunner(blink::TaskType::kInternalMedia));
#endif
}
......
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