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

VmCameraMicManager: Move notification controlling logic into VmInfo

This CL does not change the logic, but moves notification controlling
logic into VmInfo. The reason is that we are going to implement some
notification debounce logic into each VmInfo. This makes thing a bit
simpler. It also merges `VmNotificationObserver` into `VmInfo` because
we don't really need a separate class.

A few notes:

* `vm_info_map_`'s type is changed from `base::flat_map` to `std::map`
  because VmInfo is not copyable now.
* VmCameraMicManager::{Open,Close}Notification() is moved into `VmInfo`
  with only some trivial changes.

Bug: b/167491603
Change-Id: Ib41f68c67887e71563b90aeda37ef54ee60b1138
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2641827
Commit-Queue: Jason Lin <lxj@google.com>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846029}
parent 35640c58
......@@ -84,27 +84,6 @@ class VmCameraMicManager : public media::CameraActiveClientObserver,
class VmInfo;
class VmNotificationObserver : public message_center::NotificationObserver {
public:
using OpenSettingsFunction = base::RepeatingCallback<void(Profile*)>;
VmNotificationObserver();
~VmNotificationObserver();
void Initialize(Profile* profile, OpenSettingsFunction open_settings);
base::WeakPtr<NotificationObserver> GetWeakPtr();
// message_center::NotificationObserver:
void Click(const base::Optional<int>& button_index,
const base::Optional<base::string16>& reply) override;
private:
Profile* profile_ = nullptr;
OpenSettingsFunction open_settings_;
base::WeakPtrFactory<VmNotificationObserver> weak_ptr_factory_{this};
};
void MaybeSubscribeToCameraService(bool should_use_cros_camera_service);
// media::CameraActiveClientObserver
......@@ -124,18 +103,11 @@ class VmCameraMicManager : public media::CameraActiveClientObserver,
static std::string GetNotificationId(VmType vm, NotificationType type);
void UpdateVmInfoAndNotifications(VmType vm,
void (VmInfo::*updator)(bool),
bool value);
void UpdateVmInfo(VmType vm, void (VmInfo::*updator)(bool), bool value);
void NotifyActiveChanged();
void OpenNotification(VmType vm, NotificationType type);
void CloseNotification(VmType vm, NotificationType type);
Profile* primary_profile_ = nullptr;
VmNotificationObserver crostini_vm_notification_observer_;
VmNotificationObserver plugin_vm_notification_observer_;
base::flat_map<VmType, VmInfo> vm_info_map_;
std::map<VmType, VmInfo> vm_info_map_;
base::RetainingOneShotTimer observer_timer_;
base::ObserverList<Observer> observers_;
......
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