Replace scoped_ptr with unique_ptr in webrtc/api/

But keep #including scoped_ptr.h in .h files, so as not to break
WebRTC users who expect those .h files to give them rtc::scoped_ptr.

BUG=webrtc:5520

Review URL: https://codereview.webrtc.org/1930463002

Cr-Commit-Position: refs/heads/master@{#12530}
This commit is contained in:
kwiberg
2016-04-27 06:47:29 -07:00
committed by Commit bot
parent 034154b46a
commit d1fe281e12
46 changed files with 361 additions and 341 deletions

View File

@ -13,6 +13,7 @@
#include <algorithm>
#include <list>
#include <map>
#include <memory>
#include <utility>
#include <vector>
@ -31,7 +32,6 @@
#include "webrtc/api/test/mockpeerconnectionobservers.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/sslstreamadapter.h"
#include "webrtc/base/thread.h"
@ -154,7 +154,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
const std::string& id,
const MediaConstraintsInterface* constraints,
const PeerConnectionFactory::Options* options,
rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
bool prefer_constraint_apis,
rtc::Thread* worker_thread) {
PeerConnectionTestClient* client(new PeerConnectionTestClient(id));
@ -171,7 +171,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
const MediaConstraintsInterface* constraints,
const PeerConnectionFactory::Options* options,
rtc::Thread* worker_thread) {
rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store(
std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
: nullptr);
@ -184,7 +184,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
const std::string& id,
const PeerConnectionFactory::Options* options,
rtc::Thread* worker_thread) {
rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store(
std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
: nullptr);
@ -199,7 +199,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
void Negotiate() { Negotiate(true, true); }
void Negotiate(bool audio, bool video) {
rtc::scoped_ptr<SessionDescriptionInterface> offer;
std::unique_ptr<SessionDescriptionInterface> offer;
ASSERT_TRUE(DoCreateOffer(&offer));
if (offer->description()->GetContentByName("audio")) {
@ -231,7 +231,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
int sdp_mline_index,
const std::string& msg) override {
LOG(INFO) << id_ << "ReceiveIceMessage";
rtc::scoped_ptr<webrtc::IceCandidateInterface> candidate(
std::unique_ptr<webrtc::IceCandidateInterface> candidate(
webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, msg, nullptr));
EXPECT_TRUE(pc()->AddIceCandidate(candidate.get()));
}
@ -549,7 +549,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
// Verify the CreateDtmfSender interface
void VerifyDtmf() {
rtc::scoped_ptr<DummyDtmfObserver> observer(new DummyDtmfObserver());
std::unique_ptr<DummyDtmfObserver> observer(new DummyDtmfObserver());
rtc::scoped_refptr<DtmfSenderInterface> dtmf_sender;
// We can't create a DTMF sender with an invalid audio track or a non local
@ -804,7 +804,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
bool Init(
const MediaConstraintsInterface* constraints,
const PeerConnectionFactory::Options* options,
rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store,
bool prefer_constraint_apis,
rtc::Thread* worker_thread) {
EXPECT_TRUE(!peer_connection_);
@ -814,7 +814,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
}
prefer_constraint_apis_ = prefer_constraint_apis;
rtc::scoped_ptr<cricket::PortAllocator> port_allocator(
std::unique_ptr<cricket::PortAllocator> port_allocator(
new cricket::FakePortAllocator(worker_thread, nullptr));
fake_audio_capture_module_ = FakeAudioCaptureModule::Create();
@ -838,9 +838,9 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
}
rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection(
rtc::scoped_ptr<cricket::PortAllocator> port_allocator,
std::unique_ptr<cricket::PortAllocator> port_allocator,
const MediaConstraintsInterface* constraints,
rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) {
std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store) {
// CreatePeerConnection with RTCConfiguration.
webrtc::PeerConnectionInterface::RTCConfiguration config;
webrtc::PeerConnectionInterface::IceServer ice_server;
@ -858,10 +858,10 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
// If we are not sending any streams ourselves it is time to add some.
AddMediaStream(true, true);
}
rtc::scoped_ptr<SessionDescriptionInterface> desc(
std::unique_ptr<SessionDescriptionInterface> desc(
webrtc::CreateSessionDescription("offer", msg, nullptr));
EXPECT_TRUE(DoSetRemoteDescription(desc.release()));
rtc::scoped_ptr<SessionDescriptionInterface> answer;
std::unique_ptr<SessionDescriptionInterface> answer;
EXPECT_TRUE(DoCreateAnswer(&answer));
std::string sdp;
EXPECT_TRUE(answer->ToString(&sdp));
@ -874,12 +874,12 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
void HandleIncomingAnswer(const std::string& msg) {
LOG(INFO) << id_ << "HandleIncomingAnswer";
rtc::scoped_ptr<SessionDescriptionInterface> desc(
std::unique_ptr<SessionDescriptionInterface> desc(
webrtc::CreateSessionDescription("answer", msg, nullptr));
EXPECT_TRUE(DoSetRemoteDescription(desc.release()));
}
bool DoCreateOfferAnswer(rtc::scoped_ptr<SessionDescriptionInterface>* desc,
bool DoCreateOfferAnswer(std::unique_ptr<SessionDescriptionInterface>* desc,
bool offer) {
rtc::scoped_refptr<MockCreateSessionDescriptionObserver>
observer(new rtc::RefCountedObject<
@ -905,11 +905,11 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
return observer->result();
}
bool DoCreateOffer(rtc::scoped_ptr<SessionDescriptionInterface>* desc) {
bool DoCreateOffer(std::unique_ptr<SessionDescriptionInterface>* desc) {
return DoCreateOfferAnswer(desc, true);
}
bool DoCreateAnswer(rtc::scoped_ptr<SessionDescriptionInterface>* desc) {
bool DoCreateAnswer(std::unique_ptr<SessionDescriptionInterface>* desc) {
return DoCreateOfferAnswer(desc, false);
}
@ -982,10 +982,10 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
// Needed to keep track of number of frames sent.
rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_;
// Needed to keep track of number of frames received.
std::map<std::string, rtc::scoped_ptr<webrtc::FakeVideoTrackRenderer>>
std::map<std::string, std::unique_ptr<webrtc::FakeVideoTrackRenderer>>
fake_video_renderers_;
// Needed to ensure frames aren't received for removed tracks.
std::vector<rtc::scoped_ptr<webrtc::FakeVideoTrackRenderer>>
std::vector<std::unique_ptr<webrtc::FakeVideoTrackRenderer>>
removed_fake_video_renderers_;
// Needed to keep track of number of frames received when external decoder
// used.
@ -1002,7 +1002,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
std::vector<cricket::FakeVideoCapturer*> video_capturers_;
webrtc::VideoRotation capture_rotation_ = webrtc::kVideoRotation_0;
// |local_video_renderer_| attached to the first created local video track.
rtc::scoped_ptr<webrtc::FakeVideoTrackRenderer> local_video_renderer_;
std::unique_ptr<webrtc::FakeVideoTrackRenderer> local_video_renderer_;
webrtc::FakeConstraints offer_answer_constraints_;
PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options_;
@ -1016,7 +1016,7 @@ class PeerConnectionTestClient : public webrtc::PeerConnectionObserver,
bool remove_cvo_ = false;
rtc::scoped_refptr<DataChannelInterface> data_channel_;
rtc::scoped_ptr<MockDataChannelObserver> data_observer_;
std::unique_ptr<MockDataChannelObserver> data_observer_;
};
class P2PTestConductor : public testing::Test {
@ -1253,7 +1253,7 @@ class P2PTestConductor : public testing::Test {
setup_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
true);
rtc::scoped_ptr<FakeDtlsIdentityStore> dtls_identity_store(
std::unique_ptr<FakeDtlsIdentityStore> dtls_identity_store(
rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore()
: nullptr);
dtls_identity_store->use_alternate_key();
@ -1305,11 +1305,11 @@ class P2PTestConductor : public testing::Test {
// |worker_thread_| is used by both |initiating_client_| and
// |receiving_client_|. Must be destroyed last.
rtc::Thread worker_thread_;
rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_;
rtc::scoped_ptr<rtc::VirtualSocketServer> ss_;
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
rtc::SocketServerScope ss_scope_;
rtc::scoped_ptr<PeerConnectionTestClient> initiating_client_;
rtc::scoped_ptr<PeerConnectionTestClient> receiving_client_;
std::unique_ptr<PeerConnectionTestClient> initiating_client_;
std::unique_ptr<PeerConnectionTestClient> receiving_client_;
bool prefer_constraint_apis_ = true;
};
@ -1405,7 +1405,7 @@ TEST_F(P2PTestConductor, LocalP2PTestDtlsTransferCallee) {
// Keeping the original peer around which will still send packets to the
// receiving client. These SRTP packets will be dropped.
rtc::scoped_ptr<PeerConnectionTestClient> original_peer(
std::unique_ptr<PeerConnectionTestClient> original_peer(
set_initializing_client(CreateDtlsClientWithAlternateKey()));
original_peer->pc()->Close();
@ -1443,7 +1443,7 @@ TEST_F(P2PTestConductor, LocalP2PTestDtlsTransferCaller) {
// Keeping the original peer around which will still send packets to the
// receiving client. These SRTP packets will be dropped.
rtc::scoped_ptr<PeerConnectionTestClient> original_peer(
std::unique_ptr<PeerConnectionTestClient> original_peer(
set_receiving_client(CreateDtlsClientWithAlternateKey()));
original_peer->pc()->Close();