Update api/ to not use implicit T* --> scoped_refptr<T> conversion
Bug: webrtc:13464
Change-Id: I5dc292fefd27bfd43574f3e0c63c0e1da6dddcae
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244091
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35667}
diff --git a/api/scoped_refptr_unittest.cc b/api/scoped_refptr_unittest.cc
index 75a202b..22b6120 100644
--- a/api/scoped_refptr_unittest.cc
+++ b/api/scoped_refptr_unittest.cc
@@ -48,7 +48,7 @@
TEST(ScopedRefptrTest, IsCopyConstructable) {
FunctionsCalled called;
- scoped_refptr<ScopedRefCounted> ptr = new ScopedRefCounted(&called);
+ scoped_refptr<ScopedRefCounted> ptr(new ScopedRefCounted(&called));
scoped_refptr<ScopedRefCounted> another_ptr = ptr;
EXPECT_TRUE(ptr);
@@ -59,7 +59,7 @@
TEST(ScopedRefptrTest, IsCopyAssignable) {
FunctionsCalled called;
scoped_refptr<ScopedRefCounted> another_ptr;
- scoped_refptr<ScopedRefCounted> ptr = new ScopedRefCounted(&called);
+ scoped_refptr<ScopedRefCounted> ptr(new ScopedRefCounted(&called));
another_ptr = ptr;
EXPECT_TRUE(ptr);
@@ -69,7 +69,7 @@
TEST(ScopedRefptrTest, IsMoveConstructableWithoutExtraAddRefRelease) {
FunctionsCalled called;
- scoped_refptr<ScopedRefCounted> ptr = new ScopedRefCounted(&called);
+ scoped_refptr<ScopedRefCounted> ptr(new ScopedRefCounted(&called));
scoped_refptr<ScopedRefCounted> another_ptr = std::move(ptr);
EXPECT_FALSE(ptr);
@@ -81,7 +81,7 @@
TEST(ScopedRefptrTest, IsMoveAssignableWithoutExtraAddRefRelease) {
FunctionsCalled called;
scoped_refptr<ScopedRefCounted> another_ptr;
- scoped_refptr<ScopedRefCounted> ptr = new ScopedRefCounted(&called);
+ scoped_refptr<ScopedRefCounted> ptr(new ScopedRefCounted(&called));
another_ptr = std::move(ptr);
EXPECT_FALSE(ptr);
@@ -100,8 +100,8 @@
std::vector<scoped_refptr<ScopedRefCounted>> ptrs;
ptrs.reserve(1);
// Insert more elements than reserved to provoke reallocation.
- ptrs.push_back(new ScopedRefCounted(&called));
- ptrs.push_back(new ScopedRefCounted(&called));
+ ptrs.emplace_back(new ScopedRefCounted(&called));
+ ptrs.emplace_back(new ScopedRefCounted(&called));
EXPECT_EQ(called.addref, 2);
EXPECT_EQ(called.release, 0);
diff --git a/api/test/mock_data_channel.h b/api/test/mock_data_channel.h
index 9346ffd..40f7edb 100644
--- a/api/test/mock_data_channel.h
+++ b/api/test/mock_data_channel.h
@@ -22,7 +22,8 @@
: public rtc::RefCountedObject<webrtc::DataChannelInterface> {
public:
static rtc::scoped_refptr<MockDataChannelInterface> Create() {
- return new MockDataChannelInterface();
+ return rtc::scoped_refptr<MockDataChannelInterface>(
+ new MockDataChannelInterface());
}
MOCK_METHOD(void,
diff --git a/api/test/mock_media_stream_interface.h b/api/test/mock_media_stream_interface.h
index 29521e6..95d581d 100644
--- a/api/test/mock_media_stream_interface.h
+++ b/api/test/mock_media_stream_interface.h
@@ -22,7 +22,7 @@
: public rtc::RefCountedObject<AudioSourceInterface> {
public:
static rtc::scoped_refptr<MockAudioSource> Create() {
- return new MockAudioSource();
+ return rtc::scoped_refptr<MockAudioSource>(new MockAudioSource());
}
MOCK_METHOD(void,
@@ -55,7 +55,7 @@
class MockAudioTrack final : public rtc::RefCountedObject<AudioTrackInterface> {
public:
static rtc::scoped_refptr<MockAudioTrack> Create() {
- return new MockAudioTrack();
+ return rtc::scoped_refptr<MockAudioTrack>(new MockAudioTrack());
}
MOCK_METHOD(void,
diff --git a/api/test/mock_peer_connection_factory_interface.h b/api/test/mock_peer_connection_factory_interface.h
index c2f2435..0454d89 100644
--- a/api/test/mock_peer_connection_factory_interface.h
+++ b/api/test/mock_peer_connection_factory_interface.h
@@ -23,7 +23,8 @@
: public rtc::RefCountedObject<webrtc::PeerConnectionFactoryInterface> {
public:
static rtc::scoped_refptr<MockPeerConnectionFactoryInterface> Create() {
- return new MockPeerConnectionFactoryInterface();
+ return rtc::scoped_refptr<MockPeerConnectionFactoryInterface>(
+ new MockPeerConnectionFactoryInterface());
}
MOCK_METHOD(void, SetOptions, (const Options&), (override));
diff --git a/api/test/mock_peerconnectioninterface.h b/api/test/mock_peerconnectioninterface.h
index fc740b0..025e19c 100644
--- a/api/test/mock_peerconnectioninterface.h
+++ b/api/test/mock_peerconnectioninterface.h
@@ -29,7 +29,7 @@
: public rtc::RefCountedObject<webrtc::PeerConnectionInterface> {
public:
static rtc::scoped_refptr<MockPeerConnectionInterface> Create() {
- return new MockPeerConnectionInterface();
+ return rtc::make_ref_counted<MockPeerConnectionInterface>();
}
// PeerConnectionInterface
diff --git a/api/test/mock_rtp_transceiver.h b/api/test/mock_rtp_transceiver.h
index a0a08c4..db587d0 100644
--- a/api/test/mock_rtp_transceiver.h
+++ b/api/test/mock_rtp_transceiver.h
@@ -23,7 +23,7 @@
: public rtc::RefCountedObject<RtpTransceiverInterface> {
public:
static rtc::scoped_refptr<MockRtpTransceiver> Create() {
- return new MockRtpTransceiver();
+ return rtc::scoped_refptr<MockRtpTransceiver>(new MockRtpTransceiver());
}
MOCK_METHOD(cricket::MediaType, media_type, (), (const, override));
diff --git a/api/test/mock_video_track.h b/api/test/mock_video_track.h
index 58a531b..705d135 100644
--- a/api/test/mock_video_track.h
+++ b/api/test/mock_video_track.h
@@ -24,7 +24,7 @@
: public rtc::RefCountedObject<webrtc::VideoTrackInterface> {
public:
static rtc::scoped_refptr<MockVideoTrack> Create() {
- return new MockVideoTrack();
+ return rtc::scoped_refptr<MockVideoTrack>(new MockVideoTrack());
}
// NotifierInterface
diff --git a/api/video/video_frame_buffer.cc b/api/video/video_frame_buffer.cc
index 2b493dc..f6904b5 100644
--- a/api/video/video_frame_buffer.cc
+++ b/api/video/video_frame_buffer.cc
@@ -94,7 +94,7 @@
}
rtc::scoped_refptr<I420BufferInterface> I420BufferInterface::ToI420() {
- return this;
+ return rtc::scoped_refptr<I420BufferInterface>(this);
}
const I420BufferInterface* I420BufferInterface::GetI420() const {