From c9a6e4a67ec68d9bc07c1a73ac2a2b54ec484dfa Mon Sep 17 00:00:00 2001 From: zijiehe Date: Fri, 11 Nov 2016 15:13:32 -0800 Subject: [PATCH] CroppingWindowCapturer::CreateCapturer() function to replace raw pointer version The old CroppingWindowCapturer::Create() function returns a raw pointer, which cannot explain the ownership. So this change adds a CreateCapturer() function to return a unique_ptr. BUG=webrtc:6513 Review-Url: https://codereview.webrtc.org/2496993003 Cr-Commit-Position: refs/heads/master@{#15045} --- webrtc/modules/desktop_capture/cropping_window_capturer.cc | 6 ++++++ webrtc/modules/desktop_capture/cropping_window_capturer.h | 4 ++++ .../desktop_capture/cropping_window_capturer_win.cc | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/webrtc/modules/desktop_capture/cropping_window_capturer.cc b/webrtc/modules/desktop_capture/cropping_window_capturer.cc index 8f1c772c99..d2cc0ae2e8 100644 --- a/webrtc/modules/desktop_capture/cropping_window_capturer.cc +++ b/webrtc/modules/desktop_capture/cropping_window_capturer.cc @@ -106,6 +106,12 @@ DesktopCapturer* CroppingWindowCapturer::Create( const DesktopCaptureOptions& options) { return DesktopCapturer::CreateWindowCapturer(options).release(); } + +// static +std::unique_ptr CroppingWindowCapturer::CreateCapturer( + const DesktopCaptureOptions& options) { + return DesktopCapturer::CreateWindowCapturer(options); +} #endif } // namespace webrtc diff --git a/webrtc/modules/desktop_capture/cropping_window_capturer.h b/webrtc/modules/desktop_capture/cropping_window_capturer.h index 4c7c1dbd92..fd6663e5c6 100644 --- a/webrtc/modules/desktop_capture/cropping_window_capturer.h +++ b/webrtc/modules/desktop_capture/cropping_window_capturer.h @@ -24,7 +24,11 @@ namespace webrtc { class CroppingWindowCapturer : public DesktopCapturer, public DesktopCapturer::Callback { public: + // Deprecated, use CreateCapturer() static DesktopCapturer* Create(const DesktopCaptureOptions& options); + static std::unique_ptr CreateCapturer( + const DesktopCaptureOptions& options); + ~CroppingWindowCapturer() override; // DesktopCapturer implementation. diff --git a/webrtc/modules/desktop_capture/cropping_window_capturer_win.cc b/webrtc/modules/desktop_capture/cropping_window_capturer_win.cc index e191d9f354..6ba815fc29 100644 --- a/webrtc/modules/desktop_capture/cropping_window_capturer_win.cc +++ b/webrtc/modules/desktop_capture/cropping_window_capturer_win.cc @@ -215,4 +215,11 @@ DesktopCapturer* CroppingWindowCapturer::Create( return new CroppingWindowCapturerWin(options); } +// static +std::unique_ptr CroppingWindowCapturer::CreateCapturer( + const DesktopCaptureOptions& options) { + return std::unique_ptr( + new CroppingWindowCapturerWin(options)); +} + } // namespace webrtc