From 7bafbd6c8c9eb2c100604fc18cac4acc0de339af Mon Sep 17 00:00:00 2001 From: Alex Cooper Date: Thu, 2 Dec 2021 13:30:59 -0800 Subject: [PATCH] DesktopCaptureOptions should return refptrs where possible There are cases for each of these getters where other code later takes a reference to the passed object, meaning that these getters should be returning a refptr. To prevent additional overhead from places that simply access the getter to call additional methods without needing to worry about taking a ref, the return values are converted to const refs. Bug: webrtc:13465 Change-Id: Ib27969c7f5ef9d6aadf3c95ac171ae6e778cdbfa Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/239720 Reviewed-by: Mark Foltz Commit-Queue: Alexander Cooper Cr-Commit-Position: refs/heads/main@{#35465} --- modules/desktop_capture/desktop_capture_options.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/desktop_capture/desktop_capture_options.h b/modules/desktop_capture/desktop_capture_options.h index 26eb0f535f..19bea1f6d0 100644 --- a/modules/desktop_capture/desktop_capture_options.h +++ b/modules/desktop_capture/desktop_capture_options.h @@ -43,7 +43,9 @@ class RTC_EXPORT DesktopCaptureOptions { DesktopCaptureOptions& operator=(DesktopCaptureOptions&& options); #if defined(WEBRTC_USE_X11) - SharedXDisplay* x_display() const { return x_display_; } + const rtc::scoped_refptr& x_display() const { + return x_display_; + } void set_x_display(rtc::scoped_refptr x_display) { x_display_ = x_display; } @@ -53,7 +55,8 @@ class RTC_EXPORT DesktopCaptureOptions { // TODO(zijiehe): Remove both DesktopConfigurationMonitor and // FullScreenChromeWindowDetector out of DesktopCaptureOptions. It's not // reasonable for external consumers to set these two parameters. - DesktopConfigurationMonitor* configuration_monitor() const { + const rtc::scoped_refptr& configuration_monitor() + const { return configuration_monitor_; } // If nullptr is set, ScreenCapturer won't work and WindowCapturer may return @@ -67,7 +70,8 @@ class RTC_EXPORT DesktopCaptureOptions { void set_allow_iosurface(bool allow) { allow_iosurface_ = allow; } #endif - FullScreenWindowDetector* full_screen_window_detector() const { + const rtc::scoped_refptr& + full_screen_window_detector() const { return full_screen_window_detector_; } void set_full_screen_window_detector(