Commit 2e7fb209 authored by Ricky Liang's avatar Ricky Liang Committed by Commit Bot

Ensure that CameraHalDispatcher::RegisterClient runs on the right thread

In crrev.com/c/1687018 we added a local call site to RegisterClient, so
we can no longer assume the method is always called through Mojo IPC.

      enabled.

Bug: 1000842
Test: Make sure Chrome debug build starts on Nocturne with ARC++
Change-Id: Ibe546396646bab01c7caec02ff72f8122ac80181
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1817875Reviewed-by: default avatarWei Lee <wtlee@chromium.org>
Reviewed-by: default avatarShik Chen <shik@chromium.org>
Commit-Queue: Ricky Liang <jcliang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699208}
parent 30ac208e
...@@ -186,14 +186,13 @@ void CameraHalDispatcherImpl::RegisterServer( ...@@ -186,14 +186,13 @@ void CameraHalDispatcherImpl::RegisterServer(
void CameraHalDispatcherImpl::RegisterClient( void CameraHalDispatcherImpl::RegisterClient(
cros::mojom::CameraHalClientPtr client) { cros::mojom::CameraHalClientPtr client) {
DCHECK(proxy_task_runner_->BelongsToCurrentThread()); // RegisterClient can be called locally by ArcCameraBridge. Unretained
auto client_observer = // reference is safe here because CameraHalDispatcherImpl owns
std::make_unique<MojoCameraClientObserver>(std::move(client)); // |proxy_thread_|.
client_observer->client().set_connection_error_handler(base::BindOnce( proxy_task_runner_->PostTask(
&CameraHalDispatcherImpl::OnCameraHalClientConnectionError, FROM_HERE,
base::Unretained(this), base::Unretained(client_observer.get()))); base::BindOnce(&CameraHalDispatcherImpl::RegisterClientOnProxyThread,
AddClientObserver(std::move(client_observer)); base::Unretained(this), client.PassInterface()));
VLOG(1) << "Camera HAL client registered";
} }
void CameraHalDispatcherImpl::GetJpegDecodeAccelerator( void CameraHalDispatcherImpl::GetJpegDecodeAccelerator(
...@@ -331,6 +330,19 @@ void CameraHalDispatcherImpl::StartServiceLoop(base::ScopedFD socket_fd, ...@@ -331,6 +330,19 @@ void CameraHalDispatcherImpl::StartServiceLoop(base::ScopedFD socket_fd,
} }
} }
void CameraHalDispatcherImpl::RegisterClientOnProxyThread(
mojo::InterfacePtrInfo<cros::mojom::CameraHalClient> client_ptr_info) {
DCHECK(proxy_task_runner_->BelongsToCurrentThread());
cros::mojom::CameraHalClientPtr client_ptr(std::move(client_ptr_info));
auto client_observer =
std::make_unique<MojoCameraClientObserver>(std::move(client_ptr));
client_observer->client().set_connection_error_handler(base::BindOnce(
&CameraHalDispatcherImpl::OnCameraHalClientConnectionError,
base::Unretained(this), base::Unretained(client_observer.get())));
AddClientObserver(std::move(client_observer));
VLOG(1) << "Camera HAL client registered";
}
void CameraHalDispatcherImpl::AddClientObserverOnProxyThread( void CameraHalDispatcherImpl::AddClientObserverOnProxyThread(
std::unique_ptr<CameraClientObserver> observer) { std::unique_ptr<CameraClientObserver> observer) {
DCHECK(proxy_task_runner_->BelongsToCurrentThread()); DCHECK(proxy_task_runner_->BelongsToCurrentThread());
......
...@@ -93,6 +93,8 @@ class CAPTURE_EXPORT CameraHalDispatcherImpl final ...@@ -93,6 +93,8 @@ class CAPTURE_EXPORT CameraHalDispatcherImpl final
// Runs on |blocking_io_thread_|. // Runs on |blocking_io_thread_|.
void StartServiceLoop(base::ScopedFD socket_fd, base::WaitableEvent* started); void StartServiceLoop(base::ScopedFD socket_fd, base::WaitableEvent* started);
void RegisterClientOnProxyThread(
mojo::InterfacePtrInfo<cros::mojom::CameraHalClient> client_ptr_info);
void AddClientObserverOnProxyThread( void AddClientObserverOnProxyThread(
std::unique_ptr<CameraClientObserver> observer); std::unique_ptr<CameraClientObserver> observer);
......
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