From 961f38245824e90dc3e380a619a29c5bb84ced4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Wed, 12 Jan 2022 10:06:55 +0100 Subject: [PATCH] Update api/ to not use implicit T* --> scoped_refptr conversion Bug: webrtc:13464 Change-Id: I5dc292fefd27bfd43574f3e0c63c0e1da6dddcae Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/244091 Reviewed-by: Harald Alvestrand Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/main@{#35667} --- api/scoped_refptr_unittest.cc | 12 ++++++------ api/test/mock_data_channel.h | 3 ++- api/test/mock_media_stream_interface.h | 4 ++-- api/test/mock_peer_connection_factory_interface.h | 3 ++- api/test/mock_peerconnectioninterface.h | 2 +- api/test/mock_rtp_transceiver.h | 2 +- api/test/mock_video_track.h | 2 +- api/video/video_frame_buffer.cc | 2 +- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/api/scoped_refptr_unittest.cc b/api/scoped_refptr_unittest.cc index 75a202bccd..22b61209cd 100644 --- a/api/scoped_refptr_unittest.cc +++ b/api/scoped_refptr_unittest.cc @@ -48,7 +48,7 @@ class ScopedRefCounted { TEST(ScopedRefptrTest, IsCopyConstructable) { FunctionsCalled called; - scoped_refptr ptr = new ScopedRefCounted(&called); + scoped_refptr ptr(new ScopedRefCounted(&called)); scoped_refptr another_ptr = ptr; EXPECT_TRUE(ptr); @@ -59,7 +59,7 @@ TEST(ScopedRefptrTest, IsCopyConstructable) { TEST(ScopedRefptrTest, IsCopyAssignable) { FunctionsCalled called; scoped_refptr another_ptr; - scoped_refptr ptr = new ScopedRefCounted(&called); + scoped_refptr ptr(new ScopedRefCounted(&called)); another_ptr = ptr; EXPECT_TRUE(ptr); @@ -69,7 +69,7 @@ TEST(ScopedRefptrTest, IsCopyAssignable) { TEST(ScopedRefptrTest, IsMoveConstructableWithoutExtraAddRefRelease) { FunctionsCalled called; - scoped_refptr ptr = new ScopedRefCounted(&called); + scoped_refptr ptr(new ScopedRefCounted(&called)); scoped_refptr another_ptr = std::move(ptr); EXPECT_FALSE(ptr); @@ -81,7 +81,7 @@ TEST(ScopedRefptrTest, IsMoveConstructableWithoutExtraAddRefRelease) { TEST(ScopedRefptrTest, IsMoveAssignableWithoutExtraAddRefRelease) { FunctionsCalled called; scoped_refptr another_ptr; - scoped_refptr ptr = new ScopedRefCounted(&called); + scoped_refptr ptr(new ScopedRefCounted(&called)); another_ptr = std::move(ptr); EXPECT_FALSE(ptr); @@ -100,8 +100,8 @@ TEST(ScopedRefptrTest, MovableDuringVectorReallocation) { std::vector> 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 9346ffd638..40f7edb08a 100644 --- a/api/test/mock_data_channel.h +++ b/api/test/mock_data_channel.h @@ -22,7 +22,8 @@ class MockDataChannelInterface final : public rtc::RefCountedObject { public: static rtc::scoped_refptr Create() { - return new MockDataChannelInterface(); + return rtc::scoped_refptr( + new MockDataChannelInterface()); } MOCK_METHOD(void, diff --git a/api/test/mock_media_stream_interface.h b/api/test/mock_media_stream_interface.h index 29521e6e23..95d581d494 100644 --- a/api/test/mock_media_stream_interface.h +++ b/api/test/mock_media_stream_interface.h @@ -22,7 +22,7 @@ class MockAudioSource final : public rtc::RefCountedObject { public: static rtc::scoped_refptr Create() { - return new MockAudioSource(); + return rtc::scoped_refptr(new MockAudioSource()); } MOCK_METHOD(void, @@ -55,7 +55,7 @@ class MockAudioSource final class MockAudioTrack final : public rtc::RefCountedObject { public: static rtc::scoped_refptr Create() { - return new MockAudioTrack(); + return rtc::scoped_refptr(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 c2f2435fb8..0454d89b69 100644 --- a/api/test/mock_peer_connection_factory_interface.h +++ b/api/test/mock_peer_connection_factory_interface.h @@ -23,7 +23,8 @@ class MockPeerConnectionFactoryInterface final : public rtc::RefCountedObject { public: static rtc::scoped_refptr Create() { - return new MockPeerConnectionFactoryInterface(); + return rtc::scoped_refptr( + new MockPeerConnectionFactoryInterface()); } MOCK_METHOD(void, SetOptions, (const Options&), (override)); diff --git a/api/test/mock_peerconnectioninterface.h b/api/test/mock_peerconnectioninterface.h index fc740b0718..025e19c63e 100644 --- a/api/test/mock_peerconnectioninterface.h +++ b/api/test/mock_peerconnectioninterface.h @@ -29,7 +29,7 @@ class MockPeerConnectionInterface : public rtc::RefCountedObject { public: static rtc::scoped_refptr Create() { - return new MockPeerConnectionInterface(); + return rtc::make_ref_counted(); } // PeerConnectionInterface diff --git a/api/test/mock_rtp_transceiver.h b/api/test/mock_rtp_transceiver.h index a0a08c4772..db587d0768 100644 --- a/api/test/mock_rtp_transceiver.h +++ b/api/test/mock_rtp_transceiver.h @@ -23,7 +23,7 @@ class MockRtpTransceiver final : public rtc::RefCountedObject { public: static rtc::scoped_refptr Create() { - return new MockRtpTransceiver(); + return rtc::scoped_refptr(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 58a531bf42..705d13509b 100644 --- a/api/test/mock_video_track.h +++ b/api/test/mock_video_track.h @@ -24,7 +24,7 @@ class MockVideoTrack final : public rtc::RefCountedObject { public: static rtc::scoped_refptr Create() { - return new MockVideoTrack(); + return rtc::scoped_refptr(new MockVideoTrack()); } // NotifierInterface diff --git a/api/video/video_frame_buffer.cc b/api/video/video_frame_buffer.cc index 2b493dcc42..f6904b5a08 100644 --- a/api/video/video_frame_buffer.cc +++ b/api/video/video_frame_buffer.cc @@ -94,7 +94,7 @@ int I420BufferInterface::ChromaHeight() const { } rtc::scoped_refptr I420BufferInterface::ToI420() { - return this; + return rtc::scoped_refptr(this); } const I420BufferInterface* I420BufferInterface::GetI420() const {