Skip to content

Commit ac0d183

Browse files
Niels MöllerWebRTC LUCI CQ
authored andcommitted
Prepare for deleting implicit conversion from raw pointer to scoped_refptr.
Updates all webrtc code, to have a small followup cl to just add the "explicit" keyword. Patchset #24 passed all webrtc tests, with explicit. Bug: webrtc:13464 Change-Id: I39863d3752f73209b531120f66916dc9177bf63a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242363 Reviewed-by: Tomas Gunnarsson <[email protected]> Commit-Queue: Niels Moller <[email protected]> Cr-Commit-Position: refs/heads/main@{#35718}
1 parent 9609a82 commit ac0d183

33 files changed

+85
-76
lines changed

api/scoped_refptr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class scoped_refptr {
7575

7676
scoped_refptr() : ptr_(nullptr) {}
7777

78+
// TODO(bugs.webrtc.org/13464): Implicit construction is deprecated. Mark
79+
// explicit, and add a new implicit constructor accepting a nullptr_t.
7880
scoped_refptr(T* p) : ptr_(p) { // NOLINT(runtime/explicit)
7981
if (ptr_)
8082
ptr_->AddRef();

api/video/i444_buffer.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ I444Buffer::~I444Buffer() {}
6161

6262
// static
6363
rtc::scoped_refptr<I444Buffer> I444Buffer::Create(int width, int height) {
64-
return new rtc::RefCountedObject<I444Buffer>(width, height);
64+
return rtc::make_ref_counted<I444Buffer>(width, height);
6565
}
6666

6767
// static
@@ -70,8 +70,8 @@ rtc::scoped_refptr<I444Buffer> I444Buffer::Create(int width,
7070
int stride_y,
7171
int stride_u,
7272
int stride_v) {
73-
return new rtc::RefCountedObject<I444Buffer>(width, height, stride_y,
74-
stride_u, stride_v);
73+
return rtc::make_ref_counted<I444Buffer>(width, height, stride_y, stride_u,
74+
stride_v);
7575
}
7676

7777
// static

common_video/video_frame_buffer_pool.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ rtc::scoped_refptr<I444Buffer> VideoFrameBufferPool::CreateI444Buffer(
143143
return nullptr;
144144
// Allocate new buffer.
145145
rtc::scoped_refptr<I444Buffer> buffer =
146-
new rtc::RefCountedObject<I444Buffer>(width, height);
146+
rtc::make_ref_counted<I444Buffer>(width, height);
147147

148148
if (zero_initialize_)
149149
buffer->InitializeData();

examples/androidnativeapi/jni/android_call_client.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ void CreateOfferObserver::OnSuccess(webrtc::SessionDescriptionInterface* desc) {
265265
webrtc::CreateSessionDescription(webrtc::SdpType::kAnswer, sdp));
266266
pc_->SetRemoteDescription(
267267
std::move(answer),
268-
new rtc::RefCountedObject<SetRemoteSessionDescriptionObserver>());
268+
rtc::make_ref_counted<SetRemoteSessionDescriptionObserver>());
269269
}
270270

271271
void CreateOfferObserver::OnFailure(webrtc::RTCError error) {

examples/objcnativeapi/objc/objc_call_client.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
std::unique_ptr<webrtc::SessionDescriptionInterface> answer(
221221
webrtc::CreateSessionDescription(webrtc::SdpType::kAnswer, sdp));
222222
pc_->SetRemoteDescription(std::move(answer),
223-
new rtc::RefCountedObject<SetRemoteSessionDescriptionObserver>());
223+
rtc::make_ref_counted<SetRemoteSessionDescriptionObserver>());
224224
}
225225

226226
void CreateOfferObserver::OnFailure(webrtc::RTCError error) {

examples/peerconnection/client/conductor.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ class CapturerTrackSource : public webrtc::VideoTrackSource {
8585
capturer = absl::WrapUnique(
8686
webrtc::test::VcmCapturer::Create(kWidth, kHeight, kFps, i));
8787
if (capturer) {
88-
return new rtc::RefCountedObject<CapturerTrackSource>(
89-
std::move(capturer));
88+
return rtc::make_ref_counted<CapturerTrackSource>(std::move(capturer));
9089
}
9190
}
9291

examples/unityplugin/simple_peer_connection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class CapturerTrackSource : public webrtc::VideoTrackSource {
6161
if (!capturer) {
6262
return nullptr;
6363
}
64-
return new rtc::RefCountedObject<CapturerTrackSource>(std::move(capturer));
64+
return rtc::make_ref_counted<CapturerTrackSource>(std::move(capturer));
6565
}
6666

6767
protected:

modules/desktop_capture/desktop_capture_options.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "modules/desktop_capture/win/full_screen_win_application_handler.h"
1616
#endif
1717

18+
#include "rtc_base/ref_counted_object.h"
19+
1820
namespace webrtc {
1921

2022
DesktopCaptureOptions::DesktopCaptureOptions() {}
@@ -36,12 +38,15 @@ DesktopCaptureOptions DesktopCaptureOptions::CreateDefault() {
3638
result.set_x_display(SharedXDisplay::CreateDefault());
3739
#endif
3840
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
39-
result.set_configuration_monitor(new DesktopConfigurationMonitor());
41+
result.set_configuration_monitor(
42+
rtc::make_ref_counted<DesktopConfigurationMonitor>());
4043
result.set_full_screen_window_detector(
41-
new FullScreenWindowDetector(CreateFullScreenMacApplicationHandler));
44+
rtc::make_ref_counted<FullScreenWindowDetector>(
45+
CreateFullScreenMacApplicationHandler));
4246
#elif defined(WEBRTC_WIN)
4347
result.set_full_screen_window_detector(
44-
new FullScreenWindowDetector(CreateFullScreenWinApplicationHandler));
48+
rtc::make_ref_counted<FullScreenWindowDetector>(
49+
CreateFullScreenWinApplicationHandler));
4550
#endif
4651
return result;
4752
}

modules/desktop_capture/linux/x11/shared_x_display.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ rtc::scoped_refptr<SharedXDisplay> SharedXDisplay::Create(
3636
XOpenDisplay(display_name.empty() ? NULL : display_name.c_str());
3737
if (!display) {
3838
RTC_LOG(LS_ERROR) << "Unable to open display";
39-
return NULL;
39+
return nullptr;
4040
}
41-
return new SharedXDisplay(display);
41+
return rtc::scoped_refptr<SharedXDisplay>(new SharedXDisplay(display));
4242
}
4343

4444
// static

modules/desktop_capture/shared_desktop_frame.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ SharedDesktopFrame::~SharedDesktopFrame() {}
2121
// static
2222
std::unique_ptr<SharedDesktopFrame> SharedDesktopFrame::Wrap(
2323
std::unique_ptr<DesktopFrame> desktop_frame) {
24-
return std::unique_ptr<SharedDesktopFrame>(
25-
new SharedDesktopFrame(new Core(std::move(desktop_frame))));
24+
return std::unique_ptr<SharedDesktopFrame>(new SharedDesktopFrame(
25+
rtc::scoped_refptr<Core>(new Core(std::move(desktop_frame)))));
2626
}
2727

2828
SharedDesktopFrame* SharedDesktopFrame::Wrap(DesktopFrame* desktop_frame) {

0 commit comments

Comments
 (0)