Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: webrtc/modules/desktop_capture/cropped_desktop_frame.cc

Issue 1988783003: Use std::unique_ptr<> to pass frame ownership in DesktopCapturer impls. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/desktop_capture/cropped_desktop_frame.cc
diff --git a/webrtc/modules/desktop_capture/cropped_desktop_frame.cc b/webrtc/modules/desktop_capture/cropped_desktop_frame.cc
index 733fe9b2adf5dc244087a04411305f7dff63afb3..b26d5b0600acf27da8d7cdf4044e93605e66c589 100644
--- a/webrtc/modules/desktop_capture/cropped_desktop_frame.cc
+++ b/webrtc/modules/desktop_capture/cropped_desktop_frame.cc
@@ -19,7 +19,8 @@ namespace webrtc {
// A DesktopFrame that is a sub-rect of another DesktopFrame.
class CroppedDesktopFrame : public DesktopFrame {
public:
- CroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect);
+ CroppedDesktopFrame(std::unique_ptr<DesktopFrame> frame,
+ const DesktopRect& rect);
private:
std::unique_ptr<DesktopFrame> frame_;
@@ -27,23 +28,23 @@ class CroppedDesktopFrame : public DesktopFrame {
RTC_DISALLOW_COPY_AND_ASSIGN(CroppedDesktopFrame);
};
-DesktopFrame*
-CreateCroppedDesktopFrame(DesktopFrame* frame, const DesktopRect& rect) {
- if (!DesktopRect::MakeSize(frame->size()).ContainsRect(rect)) {
- delete frame;
- return NULL;
- }
+std::unique_ptr<DesktopFrame> CreateCroppedDesktopFrame(
+ std::unique_ptr<DesktopFrame> frame,
+ const DesktopRect& rect) {
+ if (!DesktopRect::MakeSize(frame->size()).ContainsRect(rect))
+ return nullptr;
- return new CroppedDesktopFrame(frame, rect);
+ return std::unique_ptr<DesktopFrame>(
+ new CroppedDesktopFrame(std::move(frame), rect));
}
-CroppedDesktopFrame::CroppedDesktopFrame(DesktopFrame* frame,
+CroppedDesktopFrame::CroppedDesktopFrame(std::unique_ptr<DesktopFrame> frame,
const DesktopRect& rect)
: DesktopFrame(rect.size(),
frame->stride(),
frame->GetFrameDataAtPos(rect.top_left()),
- frame->shared_memory()),
- frame_(frame) {
+ frame->shared_memory()) {
+ frame_ = std::move(frame);
}
} // namespace webrtc
« no previous file with comments | « webrtc/modules/desktop_capture/cropped_desktop_frame.h ('k') | webrtc/modules/desktop_capture/cropping_window_capturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698