Commit 6a945960 authored by Jason Lin's avatar Jason Lin Committed by Chromium LUCI CQ

VmCameraMicManager calls ShouldUseCrosCameraService in thread pool

See the bug for details. This also changes the behavior a little bit
--- VmCameraMicManager now will subscribe to cras even if the camera
service is not available.

Fixed: 167491603
Change-Id: I7d6852cfe64badc0b8a791f91f24a3ffff150173
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598532
Commit-Queue: Jason Lin <lxj@google.com>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838802}
parent 8004081e
...@@ -79,6 +79,8 @@ VmCameraMicManager::VmCameraMicManager() ...@@ -79,6 +79,8 @@ VmCameraMicManager::VmCameraMicManager()
base::Unretained(this))) {} base::Unretained(this))) {}
void VmCameraMicManager::OnPrimaryUserSessionStarted(Profile* primary_profile) { void VmCameraMicManager::OnPrimaryUserSessionStarted(Profile* primary_profile) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
primary_profile_ = primary_profile; primary_profile_ = primary_profile;
crostini_vm_notification_observer_.Initialize( crostini_vm_notification_observer_.Initialize(
primary_profile_, base::BindRepeating(OpenCrostiniSettings)); primary_profile_, base::BindRepeating(OpenCrostiniSettings));
...@@ -90,14 +92,12 @@ void VmCameraMicManager::OnPrimaryUserSessionStarted(Profile* primary_profile) { ...@@ -90,14 +92,12 @@ void VmCameraMicManager::OnPrimaryUserSessionStarted(Profile* primary_profile) {
} }
// Only do the subscription in real ChromeOS environment. // Only do the subscription in real ChromeOS environment.
if (base::SysInfo::IsRunningOnChromeOS() && if (base::SysInfo::IsRunningOnChromeOS()) {
media::ShouldUseCrosCameraService()) { base::ThreadPool::PostTaskAndReplyWithResult(
auto* camera = media::CameraHalDispatcherImpl::GetInstance(); FROM_HERE, {base::MayBlock()},
// OnActiveClientChange() will be called automatically after the base::BindOnce(media::ShouldUseCrosCameraService),
// subscription, so there is no need to get the current status here. base::BindOnce(&VmCameraMicManager::MaybeSubscribeToCameraService,
camera->AddActiveClientObserver(this); base::Unretained(this)));
OnCameraPrivacySwitchStatusChanged(
camera->AddCameraPrivacySwitchObserver(this));
CrasAudioHandler::Get()->AddAudioObserver(this); CrasAudioHandler::Get()->AddAudioObserver(this);
// Fetch the current value. // Fetch the current value.
...@@ -113,6 +113,22 @@ void VmCameraMicManager::OnPrimaryUserSessionStarted(Profile* primary_profile) { ...@@ -113,6 +113,22 @@ void VmCameraMicManager::OnPrimaryUserSessionStarted(Profile* primary_profile) {
// we do not do clean up (e.g. deregister as observers) here. // we do not do clean up (e.g. deregister as observers) here.
VmCameraMicManager::~VmCameraMicManager() = default; VmCameraMicManager::~VmCameraMicManager() = default;
void VmCameraMicManager::MaybeSubscribeToCameraService(
bool should_use_cros_camera_service) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (!should_use_cros_camera_service) {
return;
}
auto* camera = media::CameraHalDispatcherImpl::GetInstance();
// OnActiveClientChange() will be called automatically after the
// subscription, so there is no need to get the current status here.
camera->AddActiveClientObserver(this);
OnCameraPrivacySwitchStatusChanged(
camera->AddCameraPrivacySwitchObserver(this));
}
void VmCameraMicManager::UpdateVmInfoAndNotifications( void VmCameraMicManager::UpdateVmInfoAndNotifications(
VmType vm, VmType vm,
void (VmInfo::*updator)(bool), void (VmInfo::*updator)(bool),
......
...@@ -130,6 +130,8 @@ class VmCameraMicManager : public media::CameraActiveClientObserver, ...@@ -130,6 +130,8 @@ class VmCameraMicManager : public media::CameraActiveClientObserver,
base::WeakPtrFactory<VmNotificationObserver> weak_ptr_factory_{this}; base::WeakPtrFactory<VmNotificationObserver> weak_ptr_factory_{this};
}; };
void MaybeSubscribeToCameraService(bool should_use_cros_camera_service);
// media::CameraActiveClientObserver // media::CameraActiveClientObserver
void OnActiveClientChange(cros::mojom::CameraClientType type, void OnActiveClientChange(cros::mojom::CameraClientType type,
bool is_active) override; bool is_active) override;
......
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