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

Unified Diff: webrtc/modules/desktop_capture/shared_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, 7 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/shared_desktop_frame.cc
diff --git a/webrtc/modules/desktop_capture/shared_desktop_frame.cc b/webrtc/modules/desktop_capture/shared_desktop_frame.cc
index 8d10827e29cc2b78d472e8c28beaeb90064f1b81..24da9d4a4f003950366a073f6d268415b9f83142 100644
--- a/webrtc/modules/desktop_capture/shared_desktop_frame.cc
+++ b/webrtc/modules/desktop_capture/shared_desktop_frame.cc
@@ -19,7 +19,7 @@ namespace webrtc {
class SharedDesktopFrame::Core {
Wez 2016/05/18 01:29:50 nit: While you're here... couldn't this effectivel
Sergey Ulanov 2016/05/31 12:02:49 Done.
public:
- Core(DesktopFrame* frame) : frame_(frame) {}
+ Core(std::unique_ptr<DesktopFrame> frame) : frame_(std::move(frame)) {}
DesktopFrame* frame() { return frame_.get(); }
@@ -49,17 +49,22 @@ class SharedDesktopFrame::Core {
SharedDesktopFrame::~SharedDesktopFrame() {}
// static
+std::unique_ptr<SharedDesktopFrame> SharedDesktopFrame::Wrap(
+ std::unique_ptr<DesktopFrame> desktop_frame) {
+ return std::unique_ptr<SharedDesktopFrame>(
+ new SharedDesktopFrame(new Core(std::move(desktop_frame))));
+}
+
SharedDesktopFrame* SharedDesktopFrame::Wrap(DesktopFrame* desktop_frame) {
- rtc::scoped_refptr<Core> core(new Core(desktop_frame));
- return new SharedDesktopFrame(core);
+ return Wrap(std::unique_ptr<DesktopFrame>(desktop_frame)).release();
}
DesktopFrame* SharedDesktopFrame::GetUnderlyingFrame() {
return core_->frame();
}
-SharedDesktopFrame* SharedDesktopFrame::Share() {
- SharedDesktopFrame* result = new SharedDesktopFrame(core_);
+std::unique_ptr<SharedDesktopFrame> SharedDesktopFrame::Share() {
+ std::unique_ptr<SharedDesktopFrame> result(new SharedDesktopFrame(core_));
result->set_dpi(dpi());
result->set_capture_time_ms(capture_time_ms());
*result->mutable_updated_region() = updated_region();

Powered by Google App Engine
This is Rietveld 408576698