Commit 691fb5d5 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert CameraModuleCallbacks to new Mojo types

This CL converts CameraModuleCallbacks{Ptr, Request} in media to
the new Mojo type, and uses pending_remote<CameraModuleCallbacks>
in camera_commom.mojom.

Bug: 955171
Change-Id: I3184cb445f9211033af7176c9d97352b2edb849f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1862913
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707753}
parent c5d145e9
...@@ -363,9 +363,7 @@ void CameraHalDelegate::SetCameraModuleOnIpcThread( ...@@ -363,9 +363,7 @@ void CameraHalDelegate::SetCameraModuleOnIpcThread(
void CameraHalDelegate::ResetMojoInterfaceOnIpcThread() { void CameraHalDelegate::ResetMojoInterfaceOnIpcThread() {
DCHECK(ipc_task_runner_->BelongsToCurrentThread()); DCHECK(ipc_task_runner_->BelongsToCurrentThread());
camera_module_.reset(); camera_module_.reset();
if (camera_module_callbacks_.is_bound()) { camera_module_callbacks_.reset();
camera_module_callbacks_.Close();
}
vendor_tag_ops_delegate_.Reset(); vendor_tag_ops_delegate_.Reset();
builtin_camera_info_updated_.Reset(); builtin_camera_info_updated_.Reset();
camera_module_has_been_set_.Reset(); camera_module_has_been_set_.Reset();
...@@ -416,12 +414,8 @@ void CameraHalDelegate::OnGotNumberOfCamerasOnIpcThread(int32_t num_cameras) { ...@@ -416,12 +414,8 @@ void CameraHalDelegate::OnGotNumberOfCamerasOnIpcThread(int32_t num_cameras) {
// Per camera HAL v3 specification SetCallbacks() should be called after the // Per camera HAL v3 specification SetCallbacks() should be called after the
// first time GetNumberOfCameras() is called, and before other CameraModule // first time GetNumberOfCameras() is called, and before other CameraModule
// functions are called. // functions are called.
cros::mojom::CameraModuleCallbacksPtr camera_module_callbacks_ptr;
cros::mojom::CameraModuleCallbacksRequest camera_module_callbacks_request =
mojo::MakeRequest(&camera_module_callbacks_ptr);
camera_module_callbacks_.Bind(std::move(camera_module_callbacks_request));
camera_module_->SetCallbacks( camera_module_->SetCallbacks(
std::move(camera_module_callbacks_ptr), camera_module_callbacks_.BindNewPipeAndPassRemote(),
base::BindOnce(&CameraHalDelegate::OnSetCallbacksOnIpcThread, this)); base::BindOnce(&CameraHalDelegate::OnSetCallbacksOnIpcThread, this));
camera_module_->GetVendorTagOps( camera_module_->GetVendorTagOps(
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "media/capture/video/chromeos/vendor_tag_ops_delegate.h" #include "media/capture/video/chromeos/vendor_tag_ops_delegate.h"
#include "media/capture/video/video_capture_device_factory.h" #include "media/capture/video/video_capture_device_factory.h"
#include "media/capture/video_capture_types.h" #include "media/capture/video_capture_types.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/receiver.h"
namespace media { namespace media {
...@@ -176,9 +176,9 @@ class CAPTURE_EXPORT CameraHalDelegate final ...@@ -176,9 +176,9 @@ class CAPTURE_EXPORT CameraHalDelegate final
// to |ipc_task_runner_|. // to |ipc_task_runner_|.
cros::mojom::CameraModulePtr camera_module_; cros::mojom::CameraModulePtr camera_module_;
// The Mojo binding serving the camera module callbacks. Bound to // The Mojo receiver serving the camera module callbacks. Bound to
// |ipc_task_runner_|. // |ipc_task_runner_|.
mojo::Binding<cros::mojom::CameraModuleCallbacks> camera_module_callbacks_; mojo::Receiver<cros::mojom::CameraModuleCallbacks> camera_module_callbacks_;
// An internal delegate to handle VendorTagOps mojo connection and query // An internal delegate to handle VendorTagOps mojo connection and query
// information of vendor tags. Bound to |ipc_task_runner_|. // information of vendor tags. Bound to |ipc_task_runner_|.
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "media/capture/video/chromeos/video_capture_device_factory_chromeos.h" #include "media/capture/video/chromeos/video_capture_device_factory_chromeos.h"
#include "media/capture/video/mock_gpu_memory_buffer_manager.h" #include "media/capture/video/mock_gpu_memory_buffer_manager.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -154,7 +155,7 @@ TEST_F(CameraHalDelegateTest, GetBuiltinCameraInfo) { ...@@ -154,7 +155,7 @@ TEST_F(CameraHalDelegateTest, GetBuiltinCameraInfo) {
}; };
auto set_callbacks_cb = auto set_callbacks_cb =
[&](cros::mojom::CameraModuleCallbacksPtr& callbacks, [&](mojo::PendingRemote<cros::mojom::CameraModuleCallbacks>& callbacks,
cros::mojom::CameraModule::SetCallbacksCallback&) { cros::mojom::CameraModule::SetCallbacksCallback&) {
mock_camera_module_.NotifyCameraDeviceChange( mock_camera_module_.NotifyCameraDeviceChange(
2, cros::mojom::CameraDeviceStatus::CAMERA_DEVICE_STATUS_PRESENT); 2, cros::mojom::CameraDeviceStatus::CAMERA_DEVICE_STATUS_PRESENT);
...@@ -163,9 +164,9 @@ TEST_F(CameraHalDelegateTest, GetBuiltinCameraInfo) { ...@@ -163,9 +164,9 @@ TEST_F(CameraHalDelegateTest, GetBuiltinCameraInfo) {
EXPECT_CALL(mock_camera_module_, DoGetNumberOfCameras(_)) EXPECT_CALL(mock_camera_module_, DoGetNumberOfCameras(_))
.Times(1) .Times(1)
.WillOnce(Invoke(get_number_of_cameras_cb)); .WillOnce(Invoke(get_number_of_cameras_cb));
EXPECT_CALL( EXPECT_CALL(mock_camera_module_,
mock_camera_module_, DoSetCallbacks(
DoSetCallbacks(A<cros::mojom::CameraModuleCallbacksPtr&>(), A<mojo::PendingRemote<cros::mojom::CameraModuleCallbacks>&>(),
A<cros::mojom::CameraModule::SetCallbacksCallback&>())) A<cros::mojom::CameraModule::SetCallbacksCallback&>()))
.Times(1) .Times(1)
.WillOnce(Invoke(set_callbacks_cb)); .WillOnce(Invoke(set_callbacks_cb));
......
...@@ -41,10 +41,10 @@ void MockCameraModule::GetCameraInfo(int32_t camera_id, ...@@ -41,10 +41,10 @@ void MockCameraModule::GetCameraInfo(int32_t camera_id,
} }
void MockCameraModule::SetCallbacks( void MockCameraModule::SetCallbacks(
cros::mojom::CameraModuleCallbacksPtr callbacks, mojo::PendingRemote<cros::mojom::CameraModuleCallbacks> callbacks,
SetCallbacksCallback callback) { SetCallbacksCallback callback) {
DoSetCallbacks(callbacks, callback); DoSetCallbacks(callbacks, callback);
callbacks_ = std::move(callbacks); callbacks_.Bind(std::move(callbacks));
std::move(callback).Run(0); std::move(callback).Run(0);
} }
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "media/capture/video/chromeos/mojom/camera_common.mojom.h" #include "media/capture/video/chromeos/mojom/camera_common.mojom.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
namespace media { namespace media {
...@@ -41,10 +43,12 @@ class MockCameraModule : public cros::mojom::CameraModule { ...@@ -41,10 +43,12 @@ class MockCameraModule : public cros::mojom::CameraModule {
MOCK_METHOD2(DoGetCameraInfo, MOCK_METHOD2(DoGetCameraInfo,
void(int32_t camera_id, GetCameraInfoCallback& callback)); void(int32_t camera_id, GetCameraInfoCallback& callback));
void SetCallbacks(cros::mojom::CameraModuleCallbacksPtr callbacks, void SetCallbacks(
mojo::PendingRemote<cros::mojom::CameraModuleCallbacks> callbacks,
SetCallbacksCallback callback) override; SetCallbacksCallback callback) override;
MOCK_METHOD2(DoSetCallbacks, MOCK_METHOD2(
void(cros::mojom::CameraModuleCallbacksPtr& callbacks, DoSetCallbacks,
void(mojo::PendingRemote<cros::mojom::CameraModuleCallbacks>& callbacks,
SetCallbacksCallback& callback)); SetCallbacksCallback& callback));
void Init(InitCallback callback) override; void Init(InitCallback callback) override;
...@@ -82,7 +86,7 @@ class MockCameraModule : public cros::mojom::CameraModule { ...@@ -82,7 +86,7 @@ class MockCameraModule : public cros::mojom::CameraModule {
base::Thread mock_module_thread_; base::Thread mock_module_thread_;
mojo::Binding<cros::mojom::CameraModule> binding_; mojo::Binding<cros::mojom::CameraModule> binding_;
cros::mojom::CameraModuleCallbacksPtr callbacks_; mojo::Remote<cros::mojom::CameraModuleCallbacks> callbacks_;
DISALLOW_COPY_AND_ASSIGN(MockCameraModule); DISALLOW_COPY_AND_ASSIGN(MockCameraModule);
}; };
......
...@@ -101,7 +101,8 @@ interface CameraModule { ...@@ -101,7 +101,8 @@ interface CameraModule {
GetCameraInfo@2(int32 camera_id) => (int32 result, CameraInfo? camera_info); GetCameraInfo@2(int32 camera_id) => (int32 result, CameraInfo? camera_info);
// Registers the CameraModuleCallbacks interface with the camera HAL. // Registers the CameraModuleCallbacks interface with the camera HAL.
SetCallbacks@3(CameraModuleCallbacks callbacks) => (int32 result); SetCallbacks@3(pending_remote<CameraModuleCallbacks> callbacks)
=> (int32 result);
// Turns on or off the torch mode of the flash unit associated with the given // Turns on or off the torch mode of the flash unit associated with the given
// |camera_id|. // |camera_id|.
......
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