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 <mfoltz@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/main@{#35465}
This commit is contained in:
Alex Cooper
2021-12-02 13:30:59 -08:00
committed by WebRTC LUCI CQ
parent 43fc10fc40
commit 7bafbd6c8c

View File

@ -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<SharedXDisplay>& x_display() const {
return x_display_;
}
void set_x_display(rtc::scoped_refptr<SharedXDisplay> 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<DesktopConfigurationMonitor>& 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<FullScreenWindowDetector>&
full_screen_window_detector() const {
return full_screen_window_detector_;
}
void set_full_screen_window_detector(