refactor: use base::ObserverList::Notify()
(#46897)
* refactor: use ObserverList::Notify() in shell/browser/window_list.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/web_contents_zoom_controller.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/usb/usb_chooser_context.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/usb/electron_usb_delegate.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/ui/views/menu_delegate.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/ui/tray_icon.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/ui/electron_menu_model.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/serial/serial_chooser_context.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/native_window.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/serial/electron_serial_delegate.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/browser.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/api/electron_api_web_contents.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/hid/electron_hid_delegate.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use ObserverList::Notify() in shell/browser/hid/hid_chooser_context.cc Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
1687b95849
commit
17e1ff2675
14 changed files with 134 additions and 229 deletions
|
@ -102,19 +102,19 @@ class ElectronUsbDelegate::ContextObservation
|
|||
|
||||
// UsbChooserContext::DeviceObserver:
|
||||
void OnDeviceAdded(const device::mojom::UsbDeviceInfo& device_info) override {
|
||||
for (auto& observer : observer_list_)
|
||||
observer.OnDeviceAdded(device_info);
|
||||
observer_list_.Notify(&content::UsbDelegate::Observer::OnDeviceAdded,
|
||||
device_info);
|
||||
}
|
||||
|
||||
void OnDeviceRemoved(
|
||||
const device::mojom::UsbDeviceInfo& device_info) override {
|
||||
for (auto& observer : observer_list_)
|
||||
observer.OnDeviceRemoved(device_info);
|
||||
observer_list_.Notify(&content::UsbDelegate::Observer::OnDeviceRemoved,
|
||||
device_info);
|
||||
}
|
||||
|
||||
void OnDeviceManagerConnectionError() override {
|
||||
for (auto& observer : observer_list_)
|
||||
observer.OnDeviceManagerConnectionError();
|
||||
observer_list_.Notify(
|
||||
&content::UsbDelegate::Observer::OnDeviceManagerConnectionError);
|
||||
}
|
||||
|
||||
void OnBrowserContextShutdown() override {
|
||||
|
|
|
@ -286,8 +286,7 @@ void UsbChooserContext::OnDeviceAdded(
|
|||
devices_.try_emplace(device_info->guid, device_info->Clone());
|
||||
|
||||
// Notify all observers.
|
||||
for (auto& observer : device_observer_list_)
|
||||
observer.OnDeviceAdded(*device_info);
|
||||
device_observer_list_.Notify(&DeviceObserver::OnDeviceAdded, *device_info);
|
||||
}
|
||||
|
||||
void UsbChooserContext::OnDeviceRemoved(
|
||||
|
@ -304,8 +303,7 @@ void UsbChooserContext::OnDeviceRemoved(
|
|||
DCHECK_EQ(n_erased, 1U);
|
||||
|
||||
// Notify all device observers.
|
||||
for (auto& observer : device_observer_list_)
|
||||
observer.OnDeviceRemoved(*device_info);
|
||||
device_observer_list_.Notify(&DeviceObserver::OnDeviceRemoved, *device_info);
|
||||
|
||||
// If the device was persistent, return. Otherwise, notify all permission
|
||||
// observers that its permissions were revoked.
|
||||
|
@ -327,8 +325,7 @@ void UsbChooserContext::OnDeviceManagerConnectionError() {
|
|||
ephemeral_devices_.clear();
|
||||
|
||||
// Notify all device observers.
|
||||
for (auto& observer : device_observer_list_)
|
||||
observer.OnDeviceManagerConnectionError();
|
||||
device_observer_list_.Notify(&DeviceObserver::OnDeviceManagerConnectionError);
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue