From ca27f1a1a0026e74999306ab6faa9543830d3116 Mon Sep 17 00:00:00 2001 From: Alex Cooper Date: Thu, 8 Sep 2022 14:42:17 -0700 Subject: [PATCH] Make ScreenCastPortal::CaptureSourceType private https://crrev.com/c/3885576 removed the last downstream consumer of the constructor which took a ScreenCastPortal::CaptureSourceType. Now that it has been removed, that constructor definition can also be removed and the CaptureSourceType enum can be made private. There's still benefit in storing and using this internally as the enum, since it's values match that of the underlying system API. The previously anonymous-namespaced function |ToCaptureSourceType| had to be converted to a private static method as part of this change, since it would be unable to access the type otherwise. Fixed: chromium:1359411 Change-Id: I81ff24fbdddf9db02c9c5152d007dd82c194865a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/274680 Auto-Submit: Alexander Cooper Commit-Queue: Alexander Cooper Commit-Queue: Mark Foltz Reviewed-by: Mark Foltz Cr-Commit-Position: refs/heads/main@{#38084} --- .../linux/wayland/screencast_portal.cc | 34 +++---------------- .../linux/wayland/screencast_portal.h | 28 ++++++--------- 2 files changed, 15 insertions(+), 47 deletions(-) diff --git a/modules/desktop_capture/linux/wayland/screencast_portal.cc b/modules/desktop_capture/linux/wayland/screencast_portal.cc index 5eacae9ed6..f9cdb08533 100644 --- a/modules/desktop_capture/linux/wayland/screencast_portal.cc +++ b/modules/desktop_capture/linux/wayland/screencast_portal.cc @@ -31,7 +31,11 @@ using xdg_portal::StartSessionRequest; using xdg_portal::TearDownSession; using xdg_portal::RequestResponseFromPortalResponse; -ScreenCastPortal::CaptureSourceType ToCaptureSourceType(CaptureType type) { +} // namespace + +// static +ScreenCastPortal::CaptureSourceType ScreenCastPortal::ToCaptureSourceType( + CaptureType type) { switch (type) { case CaptureType::kScreen: return ScreenCastPortal::CaptureSourceType::kScreen; @@ -40,22 +44,6 @@ ScreenCastPortal::CaptureSourceType ToCaptureSourceType(CaptureType type) { } } -// TODO(https://crbug.com/1359411): Migrate downstream consumers off of -// CaptureSourceType and delete this. -CaptureType ToCaptureType(ScreenCastPortal::CaptureSourceType source_type) { - switch (source_type) { - case ScreenCastPortal::CaptureSourceType::kScreen: - return CaptureType::kScreen; - case ScreenCastPortal::CaptureSourceType::kWindow: - return CaptureType::kWindow; - default: - RTC_DCHECK_NOTREACHED(); - return CaptureType::kScreen; - } -} - -} // namespace - ScreenCastPortal::ScreenCastPortal(CaptureType type, PortalNotifier* notifier) : ScreenCastPortal(type, notifier, @@ -76,18 +64,6 @@ ScreenCastPortal::ScreenCastPortal( sources_request_response_signal_handler), user_data_(user_data) {} -ScreenCastPortal::ScreenCastPortal( - CaptureSourceType source_type, - PortalNotifier* notifier, - ProxyRequestResponseHandler proxy_request_response_handler, - SourcesRequestResponseSignalHandler sources_request_response_signal_handler, - gpointer user_data) - : ScreenCastPortal(ToCaptureType(source_type), - notifier, - proxy_request_response_handler, - sources_request_response_signal_handler, - user_data) {} - ScreenCastPortal::~ScreenCastPortal() { Stop(); } diff --git a/modules/desktop_capture/linux/wayland/screencast_portal.h b/modules/desktop_capture/linux/wayland/screencast_portal.h index 65869e6483..96e4ba3ac9 100644 --- a/modules/desktop_capture/linux/wayland/screencast_portal.h +++ b/modules/desktop_capture/linux/wayland/screencast_portal.h @@ -38,16 +38,6 @@ class ScreenCastPortal : public xdg_portal::ScreenCapturePortalInterface { GVariant* parameters, gpointer user_data); - // Values are set based on source type property in - // xdg-desktop-portal/screencast - // https://github.com/flatpak/xdg-desktop-portal/blob/master/data/org.freedesktop.portal.ScreenCast.xml - // TODO(https://crbug.com/1359411): Make this private. - enum class CaptureSourceType : uint32_t { - kScreen = 0b01, - kWindow = 0b10, - kAnyScreenContent = kScreen | kWindow - }; - // Values are set based on cursor mode property in // xdg-desktop-portal/screencast // https://github.com/flatpak/xdg-desktop-portal/blob/master/data/org.freedesktop.portal.ScreenCast.xml @@ -96,14 +86,6 @@ class ScreenCastPortal : public xdg_portal::ScreenCapturePortalInterface { sources_request_response_signal_handler, gpointer user_data); - // TODO(https://crbug.com/1359411): Migrate downstream consumers off of - // CaptureSourceType and delete this. - ScreenCastPortal(CaptureSourceType source_type, - PortalNotifier* notifier, - ProxyRequestResponseHandler proxy_request_response_handler, - SourcesRequestResponseSignalHandler - sources_request_response_signal_handler, - gpointer user_data); ~ScreenCastPortal(); // Initialize ScreenCastPortal with series of DBus calls where we try to @@ -136,6 +118,16 @@ class ScreenCastPortal : public xdg_portal::ScreenCapturePortalInterface { std::string RestoreToken() const; private: + // Values are set based on source type property in + // xdg-desktop-portal/screencast + // https://github.com/flatpak/xdg-desktop-portal/blob/master/data/org.freedesktop.portal.ScreenCast.xml + enum class CaptureSourceType : uint32_t { + kScreen = 0b01, + kWindow = 0b10, + kAnyScreenContent = kScreen | kWindow + }; + static CaptureSourceType ToCaptureSourceType(CaptureType type); + PortalNotifier* notifier_; // A PipeWire stream ID of stream we will be connecting to