Replace scoped_ptr with unique_ptr in webrtc/p2p/ 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/1923163003 Cr-Commit-Position: refs/heads/master@{#12532}
diff --git a/webrtc/p2p/base/asyncstuntcpsocket_unittest.cc b/webrtc/p2p/base/asyncstuntcpsocket_unittest.cc index 22c1b26..5929d1f 100644 --- a/webrtc/p2p/base/asyncstuntcpsocket_unittest.cc +++ b/webrtc/p2p/base/asyncstuntcpsocket_unittest.cc
@@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> + #include "webrtc/p2p/base/asyncstuntcpsocket.h" #include "webrtc/base/asyncsocket.h" #include "webrtc/base/gunit.h" @@ -122,11 +124,11 @@ return ret; } - rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; + std::unique_ptr<rtc::VirtualSocketServer> vss_; rtc::SocketServerScope ss_scope_; - rtc::scoped_ptr<AsyncStunTCPSocket> send_socket_; - rtc::scoped_ptr<AsyncStunTCPSocket> recv_socket_; - rtc::scoped_ptr<rtc::AsyncPacketSocket> listen_socket_; + std::unique_ptr<AsyncStunTCPSocket> send_socket_; + std::unique_ptr<AsyncStunTCPSocket> recv_socket_; + std::unique_ptr<rtc::AsyncPacketSocket> listen_socket_; std::list<std::string> recv_packets_; };
diff --git a/webrtc/p2p/base/basicpacketsocketfactory.cc b/webrtc/p2p/base/basicpacketsocketfactory.cc index 697518d..a05f9df 100644 --- a/webrtc/p2p/base/basicpacketsocketfactory.cc +++ b/webrtc/p2p/base/basicpacketsocketfactory.cc
@@ -17,7 +17,6 @@ #include "webrtc/base/logging.h" #include "webrtc/base/nethelpers.h" #include "webrtc/base/physicalsocketserver.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/socketadapters.h" #include "webrtc/base/ssladapter.h" #include "webrtc/base/thread.h"
diff --git a/webrtc/p2p/base/dtlstransport.h b/webrtc/p2p/base/dtlstransport.h index 276b05f..2ff2ea5 100644 --- a/webrtc/p2p/base/dtlstransport.h +++ b/webrtc/p2p/base/dtlstransport.h
@@ -11,6 +11,8 @@ #ifndef WEBRTC_P2P_BASE_DTLSTRANSPORT_H_ #define WEBRTC_P2P_BASE_DTLSTRANSPORT_H_ +#include <memory> + #include "webrtc/p2p/base/dtlstransportchannel.h" #include "webrtc/p2p/base/transport.h" @@ -67,7 +69,7 @@ if (local_fp) { // Sanity check local fingerprint. if (certificate_) { - rtc::scoped_ptr<rtc::SSLFingerprint> local_fp_tmp( + std::unique_ptr<rtc::SSLFingerprint> local_fp_tmp( rtc::SSLFingerprint::Create(local_fp->algorithm, certificate_->identity())); ASSERT(local_fp_tmp.get() != NULL); @@ -242,7 +244,7 @@ rtc::scoped_refptr<rtc::RTCCertificate> certificate_; rtc::SSLRole secure_role_; rtc::SSLProtocolVersion ssl_max_version_; - rtc::scoped_ptr<rtc::SSLFingerprint> remote_fingerprint_; + std::unique_ptr<rtc::SSLFingerprint> remote_fingerprint_; }; } // namespace cricket
diff --git a/webrtc/p2p/base/p2ptransportchannel.h b/webrtc/p2p/base/p2ptransportchannel.h index 08c2b4f..2afe03e 100644 --- a/webrtc/p2p/base/p2ptransportchannel.h +++ b/webrtc/p2p/base/p2ptransportchannel.h
@@ -21,6 +21,7 @@ #define WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ #include <map> +#include <memory> #include <set> #include <string> #include <vector>
diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc index d921a1e..8ff0b6e 100644 --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> + #include "webrtc/p2p/base/p2ptransportchannel.h" #include "webrtc/p2p/base/testrelayserver.h" #include "webrtc/p2p/base/teststunserver.h" @@ -211,7 +213,7 @@ std::string name_; // TODO - Currently not used. std::list<std::string> ch_packets_; - rtc::scoped_ptr<cricket::P2PTransportChannel> ch_; + std::unique_ptr<cricket::P2PTransportChannel> ch_; }; struct CandidatesData : public rtc::MessageData { @@ -255,7 +257,7 @@ } rtc::FakeNetworkManager network_manager_; - rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; + std::unique_ptr<cricket::BasicPortAllocator> allocator_; ChannelData cd1_; ChannelData cd2_; cricket::IceRole role_; @@ -702,7 +704,7 @@ void OnMessage(rtc::Message* msg) { switch (msg->message_id) { case MSG_ADD_CANDIDATES: { - rtc::scoped_ptr<CandidatesData> data( + std::unique_ptr<CandidatesData> data( static_cast<CandidatesData*>(msg->pdata)); cricket::P2PTransportChannel* rch = GetRemoteChannel(data->channel); for (auto& c : data->candidates) { @@ -717,7 +719,7 @@ break; } case MSG_REMOVE_CANDIDATES: { - rtc::scoped_ptr<CandidatesData> data( + std::unique_ptr<CandidatesData> data( static_cast<CandidatesData*>(msg->pdata)); cricket::P2PTransportChannel* rch = GetRemoteChannel(data->channel); for (cricket::Candidate& c : data->candidates) { @@ -797,12 +799,12 @@ private: rtc::Thread* main_; - rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; - rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; - rtc::scoped_ptr<rtc::NATSocketServer> nss_; - rtc::scoped_ptr<rtc::FirewallSocketServer> ss_; + std::unique_ptr<rtc::PhysicalSocketServer> pss_; + std::unique_ptr<rtc::VirtualSocketServer> vss_; + std::unique_ptr<rtc::NATSocketServer> nss_; + std::unique_ptr<rtc::FirewallSocketServer> ss_; rtc::SocketServerScope ss_scope_; - rtc::scoped_ptr<cricket::TestStunServer> stun_server_; + std::unique_ptr<cricket::TestStunServer> stun_server_; cricket::TestTurnServer turn_server_; cricket::TestRelayServer relay_server_; rtc::SocksProxyServer socks_server1_; @@ -1994,8 +1996,8 @@ void reset_channel_ready_to_send() { channel_ready_to_send_ = false; } private: - rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; - rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; + std::unique_ptr<rtc::PhysicalSocketServer> pss_; + std::unique_ptr<rtc::VirtualSocketServer> vss_; rtc::SocketServerScope ss_scope_; cricket::CandidatePairInterface* last_selected_candidate_pair_ = nullptr; int last_sent_packet_id_ = -1; @@ -2640,10 +2642,10 @@ } private: - rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; + std::unique_ptr<cricket::BasicPortAllocator> allocator_; rtc::FakeNetworkManager network_manager_; cricket::TestTurnServer turn_server_; - rtc::scoped_ptr<cricket::P2PTransportChannel> channel_; + std::unique_ptr<cricket::P2PTransportChannel> channel_; }; // Test that Relay/Relay connections will be pinged first when no other
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc index 0238aa2..2ee012a 100644 --- a/webrtc/p2p/base/port.cc +++ b/webrtc/p2p/base/port.cc
@@ -21,7 +21,6 @@ #include "webrtc/base/logging.h" #include "webrtc/base/messagedigest.h" #include "webrtc/base/network.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/stringencode.h" #include "webrtc/base/stringutils.h" @@ -278,7 +277,7 @@ // If this is an authenticated STUN request, then signal unknown address and // send back a proper binding response. - rtc::scoped_ptr<IceMessage> msg; + std::unique_ptr<IceMessage> msg; std::string remote_username; if (!GetStunMessage(data, size, addr, &msg, &remote_username)) { LOG_J(LS_ERROR, this) << "Received non-STUN packet from unknown address (" @@ -325,7 +324,7 @@ bool Port::GetStunMessage(const char* data, size_t size, const rtc::SocketAddress& addr, - rtc::scoped_ptr<IceMessage>* out_msg, + std::unique_ptr<IceMessage>* out_msg, std::string* out_username) { // NOTE: This could clearly be optimized to avoid allocating any memory. // However, at the data rates we'll be looking at on the client side, @@ -342,7 +341,7 @@ // Parse the request message. If the packet is not a complete and correct // STUN message, then ignore it. - rtc::scoped_ptr<IceMessage> stun_msg(new IceMessage()); + std::unique_ptr<IceMessage> stun_msg(new IceMessage()); rtc::ByteBufferReader buf(data, size); if (!stun_msg->Read(&buf) || (buf.Length() > 0)) { return false; @@ -895,7 +894,7 @@ void Connection::OnReadPacket( const char* data, size_t size, const rtc::PacketTime& packet_time) { - rtc::scoped_ptr<IceMessage> msg; + std::unique_ptr<IceMessage> msg; std::string remote_ufrag; const rtc::SocketAddress& addr(remote_candidate_.address()); if (!port_->GetStunMessage(data, size, addr, &msg, &remote_ufrag)) {
diff --git a/webrtc/p2p/base/port.h b/webrtc/p2p/base/port.h index 2961355..7ec33bc 100644 --- a/webrtc/p2p/base/port.h +++ b/webrtc/p2p/base/port.h
@@ -12,6 +12,7 @@ #define WEBRTC_P2P_BASE_PORT_H_ #include <map> +#include <memory> #include <set> #include <string> #include <vector> @@ -336,7 +337,7 @@ bool GetStunMessage(const char* data, size_t size, const rtc::SocketAddress& addr, - rtc::scoped_ptr<IceMessage>* out_msg, + std::unique_ptr<IceMessage>* out_msg, std::string* out_username); // Checks if the address in addr is compatible with the port's ip.
diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc index fc49f20..7e787e0 100644 --- a/webrtc/p2p/base/port_unittest.cc +++ b/webrtc/p2p/base/port_unittest.cc
@@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> + #include "webrtc/p2p/base/basicpacketsocketfactory.h" #include "webrtc/p2p/base/relayport.h" #include "webrtc/p2p/base/stunport.h" @@ -26,7 +28,6 @@ #include "webrtc/base/natserver.h" #include "webrtc/base/natsocketfactory.h" #include "webrtc/base/physicalsocketserver.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/socketaddress.h" #include "webrtc/base/ssladapter.h" #include "webrtc/base/stringutils.h" @@ -43,7 +44,6 @@ using rtc::NAT_PORT_RESTRICTED; using rtc::NAT_SYMMETRIC; using rtc::PacketSocketFactory; -using rtc::scoped_ptr; using rtc::Socket; using rtc::SocketAddress; using namespace cricket; @@ -212,8 +212,8 @@ const rtc::SentPacket& sent_packet) { PortInterface::SignalSentPacket(sent_packet); } - rtc::scoped_ptr<Buffer> last_stun_buf_; - rtc::scoped_ptr<IceMessage> last_stun_msg_; + std::unique_ptr<Buffer> last_stun_buf_; + std::unique_ptr<IceMessage> last_stun_msg_; int type_preference_ = 0; }; @@ -344,12 +344,12 @@ } IceMode ice_mode_; - rtc::scoped_ptr<Port> port_; + std::unique_ptr<Port> port_; int complete_count_; Connection* conn_; SocketAddress remote_address_; - rtc::scoped_ptr<StunMessage> remote_request_; + std::unique_ptr<StunMessage> remote_request_; std::string remote_frag_; bool nominated_; bool connection_ready_to_send_ = false; @@ -764,18 +764,18 @@ private: rtc::Thread* main_; - 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::Network network_; rtc::BasicPacketSocketFactory socket_factory_; - rtc::scoped_ptr<rtc::NATServer> nat_server1_; - rtc::scoped_ptr<rtc::NATServer> nat_server2_; + std::unique_ptr<rtc::NATServer> nat_server1_; + std::unique_ptr<rtc::NATServer> nat_server2_; rtc::NATSocketFactory nat_factory1_; rtc::NATSocketFactory nat_factory2_; rtc::BasicPacketSocketFactory nat_socket_factory1_; rtc::BasicPacketSocketFactory nat_socket_factory2_; - scoped_ptr<TestStunServer> stun_server_; + std::unique_ptr<TestStunServer> stun_server_; TestTurnServer turn_server_; TestRelayServer relay_server_; std::string username_; @@ -1217,7 +1217,7 @@ ch1.Start(); ASSERT_EQ_WAIT(1, ch1.complete_count(), kTimeout); - rtc::scoped_ptr<rtc::AsyncSocket> server( + std::unique_ptr<rtc::AsyncSocket> server( vss()->CreateAsyncSocket(kLocalAddr2.family(), SOCK_STREAM)); // Bind but not listen. EXPECT_EQ(0, server->Bind(kLocalAddr2)); @@ -1322,7 +1322,7 @@ // should remain equal to the request generated by the port and role of port // must be in controlling. TEST_F(PortTest, TestLoopbackCal) { - rtc::scoped_ptr<TestPort> lport( + std::unique_ptr<TestPort> lport( CreateTestPort(kLocalAddr1, "lfrag", "lpass")); lport->SetIceRole(cricket::ICEROLE_CONTROLLING); lport->SetIceTiebreaker(kTiebreaker1); @@ -1354,7 +1354,7 @@ ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); msg = lport->last_stun_msg(); EXPECT_EQ(STUN_BINDING_REQUEST, msg->type()); - rtc::scoped_ptr<IceMessage> modified_req( + std::unique_ptr<IceMessage> modified_req( CreateStunMessage(STUN_BINDING_REQUEST)); const StunByteStringAttribute* username_attr = msg->GetByteString( STUN_ATTR_USERNAME); @@ -1368,7 +1368,7 @@ modified_req->AddFingerprint(); lport->Reset(); - rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); + std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); WriteStunMessage(modified_req.get(), buf.get()); conn1->OnReadPacket(buf->Data(), buf->Length(), rtc::PacketTime()); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); @@ -1382,11 +1382,11 @@ // value of tiebreaker, when it receives ping request from |rport| it will // send role conflict signal. TEST_F(PortTest, TestIceRoleConflict) { - rtc::scoped_ptr<TestPort> lport( + std::unique_ptr<TestPort> lport( CreateTestPort(kLocalAddr1, "lfrag", "lpass")); lport->SetIceRole(cricket::ICEROLE_CONTROLLING); lport->SetIceTiebreaker(kTiebreaker1); - rtc::scoped_ptr<TestPort> rport( + std::unique_ptr<TestPort> rport( CreateTestPort(kLocalAddr2, "rfrag", "rpass")); rport->SetIceRole(cricket::ICEROLE_CONTROLLING); rport->SetIceTiebreaker(kTiebreaker2); @@ -1430,8 +1430,7 @@ FakePacketSocketFactory socket_factory; socket_factory.set_next_udp_socket(socket); - scoped_ptr<UDPPort> port( - CreateUdpPort(kLocalAddr1, &socket_factory)); + std::unique_ptr<UDPPort> port(CreateUdpPort(kLocalAddr1, &socket_factory)); socket->set_state(AsyncPacketSocket::STATE_BINDING); port->PrepareAddress(); @@ -1447,8 +1446,7 @@ FakePacketSocketFactory socket_factory; socket_factory.set_next_server_tcp_socket(socket); - scoped_ptr<TCPPort> port( - CreateTcpPort(kLocalAddr1, &socket_factory)); + std::unique_ptr<TCPPort> port(CreateTcpPort(kLocalAddr1, &socket_factory)); socket->set_state(AsyncPacketSocket::STATE_BINDING); port->PrepareAddress(); @@ -1461,7 +1459,7 @@ void PortTest::TestCrossFamilyPorts(int type) { FakePacketSocketFactory factory; - scoped_ptr<Port> ports[4]; + std::unique_ptr<Port> ports[4]; SocketAddress addresses[4] = {SocketAddress("192.168.1.3", 0), SocketAddress("192.168.1.4", 0), SocketAddress("2001:db8::1", 0), @@ -1531,7 +1529,7 @@ TEST_F(PortTest, TestUdpV6CrossTypePorts) { FakePacketSocketFactory factory; - scoped_ptr<Port> ports[4]; + std::unique_ptr<Port> ports[4]; SocketAddress addresses[4] = {SocketAddress("2001:db8::1", 0), SocketAddress("fe80::1", 0), SocketAddress("fe80::2", 0), @@ -1564,23 +1562,23 @@ // get through DefaultDscpValue. TEST_F(PortTest, TestDefaultDscpValue) { int dscp; - rtc::scoped_ptr<UDPPort> udpport(CreateUdpPort(kLocalAddr1)); + std::unique_ptr<UDPPort> udpport(CreateUdpPort(kLocalAddr1)); EXPECT_EQ(0, udpport->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_CS6)); EXPECT_EQ(0, udpport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); - rtc::scoped_ptr<TCPPort> tcpport(CreateTcpPort(kLocalAddr1)); + std::unique_ptr<TCPPort> tcpport(CreateTcpPort(kLocalAddr1)); EXPECT_EQ(0, tcpport->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_AF31)); EXPECT_EQ(0, tcpport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); EXPECT_EQ(rtc::DSCP_AF31, dscp); - rtc::scoped_ptr<StunPort> stunport( + std::unique_ptr<StunPort> stunport( CreateStunPort(kLocalAddr1, nat_socket_factory1())); EXPECT_EQ(0, stunport->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_AF41)); EXPECT_EQ(0, stunport->GetOption(rtc::Socket::OPT_DSCP, &dscp)); EXPECT_EQ(rtc::DSCP_AF41, dscp); - rtc::scoped_ptr<TurnPort> turnport1(CreateTurnPort( - kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); + std::unique_ptr<TurnPort> turnport1( + CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); // Socket is created in PrepareAddress. turnport1->PrepareAddress(); EXPECT_EQ(0, turnport1->SetOption(rtc::Socket::OPT_DSCP, @@ -1588,8 +1586,8 @@ EXPECT_EQ(0, turnport1->GetOption(rtc::Socket::OPT_DSCP, &dscp)); EXPECT_EQ(rtc::DSCP_CS7, dscp); // This will verify correct value returned without the socket. - rtc::scoped_ptr<TurnPort> turnport2(CreateTurnPort( - kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); + std::unique_ptr<TurnPort> turnport2( + CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); EXPECT_EQ(0, turnport2->SetOption(rtc::Socket::OPT_DSCP, rtc::DSCP_CS6)); EXPECT_EQ(0, turnport2->GetOption(rtc::Socket::OPT_DSCP, &dscp)); @@ -1598,9 +1596,9 @@ // Test sending STUN messages. TEST_F(PortTest, TestSendStunMessage) { - rtc::scoped_ptr<TestPort> lport( + std::unique_ptr<TestPort> lport( CreateTestPort(kLocalAddr1, "lfrag", "lpass")); - rtc::scoped_ptr<TestPort> rport( + std::unique_ptr<TestPort> rport( CreateTestPort(kLocalAddr2, "rfrag", "rpass")); lport->SetIceRole(cricket::ICEROLE_CONTROLLING); lport->SetIceTiebreaker(kTiebreaker1); @@ -1647,7 +1645,7 @@ ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL); // Save a copy of the BINDING-REQUEST for use below. - rtc::scoped_ptr<IceMessage> request(CopyStunMessage(msg)); + std::unique_ptr<IceMessage> request(CopyStunMessage(msg)); // Respond with a BINDING-RESPONSE. rport->SendBindingResponse(request.get(), lport->Candidates()[0].address()); @@ -1738,9 +1736,9 @@ } TEST_F(PortTest, TestUseCandidateAttribute) { - rtc::scoped_ptr<TestPort> lport( + std::unique_ptr<TestPort> lport( CreateTestPort(kLocalAddr1, "lfrag", "lpass")); - rtc::scoped_ptr<TestPort> rport( + std::unique_ptr<TestPort> rport( CreateTestPort(kLocalAddr2, "rfrag", "rpass")); lport->SetIceRole(cricket::ICEROLE_CONTROLLING); lport->SetIceTiebreaker(kTiebreaker1); @@ -1765,11 +1763,11 @@ } TEST_F(PortTest, TestNetworkInfoAttribute) { - rtc::scoped_ptr<TestPort> lport( + std::unique_ptr<TestPort> lport( CreateTestPort(kLocalAddr1, "lfrag", "lpass")); // Set the network type for rport to be cellular so its cost will be 999. SetNetworkType(rtc::ADAPTER_TYPE_CELLULAR); - rtc::scoped_ptr<TestPort> rport( + std::unique_ptr<TestPort> rport( CreateTestPort(kLocalAddr2, "rfrag", "rpass")); lport->SetIceRole(cricket::ICEROLE_CONTROLLING); lport->SetIceTiebreaker(kTiebreaker1); @@ -1812,11 +1810,10 @@ // Test handling STUN messages. TEST_F(PortTest, TestHandleStunMessage) { // Our port will act as the "remote" port. - rtc::scoped_ptr<TestPort> port( - CreateTestPort(kLocalAddr2, "rfrag", "rpass")); + std::unique_ptr<TestPort> port(CreateTestPort(kLocalAddr2, "rfrag", "rpass")); - rtc::scoped_ptr<IceMessage> in_msg, out_msg; - rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); + std::unique_ptr<IceMessage> in_msg, out_msg; + std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); rtc::SocketAddress addr(kLocalAddr1); std::string username; @@ -1862,11 +1859,10 @@ // Tests handling of ICE binding requests with missing or incorrect usernames. TEST_F(PortTest, TestHandleStunMessageBadUsername) { - rtc::scoped_ptr<TestPort> port( - CreateTestPort(kLocalAddr2, "rfrag", "rpass")); + std::unique_ptr<TestPort> port(CreateTestPort(kLocalAddr2, "rfrag", "rpass")); - rtc::scoped_ptr<IceMessage> in_msg, out_msg; - rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); + std::unique_ptr<IceMessage> in_msg, out_msg; + std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); rtc::SocketAddress addr(kLocalAddr1); std::string username; @@ -1931,11 +1927,10 @@ // Test handling STUN messages with missing or malformed M-I. TEST_F(PortTest, TestHandleStunMessageBadMessageIntegrity) { // Our port will act as the "remote" port. - rtc::scoped_ptr<TestPort> port( - CreateTestPort(kLocalAddr2, "rfrag", "rpass")); + std::unique_ptr<TestPort> port(CreateTestPort(kLocalAddr2, "rfrag", "rpass")); - rtc::scoped_ptr<IceMessage> in_msg, out_msg; - rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); + std::unique_ptr<IceMessage> in_msg, out_msg; + std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); rtc::SocketAddress addr(kLocalAddr1); std::string username; @@ -1972,11 +1967,10 @@ // Test handling STUN messages with missing or malformed FINGERPRINT. TEST_F(PortTest, TestHandleStunMessageBadFingerprint) { // Our port will act as the "remote" port. - rtc::scoped_ptr<TestPort> port( - CreateTestPort(kLocalAddr2, "rfrag", "rpass")); + std::unique_ptr<TestPort> port(CreateTestPort(kLocalAddr2, "rfrag", "rpass")); - rtc::scoped_ptr<IceMessage> in_msg, out_msg; - rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); + std::unique_ptr<IceMessage> in_msg, out_msg; + std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); rtc::SocketAddress addr(kLocalAddr1); std::string username; @@ -2038,14 +2032,14 @@ // Test handling of STUN binding indication messages . STUN binding // indications are allowed only to the connection which is in read mode. TEST_F(PortTest, TestHandleStunBindingIndication) { - rtc::scoped_ptr<TestPort> lport( + std::unique_ptr<TestPort> lport( CreateTestPort(kLocalAddr2, "lfrag", "lpass")); lport->SetIceRole(cricket::ICEROLE_CONTROLLING); lport->SetIceTiebreaker(kTiebreaker1); // Verifying encoding and decoding STUN indication message. - rtc::scoped_ptr<IceMessage> in_msg, out_msg; - rtc::scoped_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); + std::unique_ptr<IceMessage> in_msg, out_msg; + std::unique_ptr<ByteBufferWriter> buf(new ByteBufferWriter()); rtc::SocketAddress addr(kLocalAddr1); std::string username; @@ -2060,7 +2054,7 @@ // Verify connection can handle STUN indication and updates // last_ping_received. - rtc::scoped_ptr<TestPort> rport( + std::unique_ptr<TestPort> rport( CreateTestPort(kLocalAddr2, "rfrag", "rpass")); rport->SetIceRole(cricket::ICEROLE_CONTROLLED); rport->SetIceTiebreaker(kTiebreaker2); @@ -2096,8 +2090,7 @@ } TEST_F(PortTest, TestComputeCandidatePriority) { - rtc::scoped_ptr<TestPort> port( - CreateTestPort(kLocalAddr1, "name", "pass")); + std::unique_ptr<TestPort> port(CreateTestPort(kLocalAddr1, "name", "pass")); port->set_type_preference(90); port->set_component(177); port->AddCandidateAddress(SocketAddress("192.168.1.4", 1234)); @@ -2134,7 +2127,7 @@ // In the case of shared socket, one port may be shared by local and stun. // Test that candidates with different types will have different foundation. TEST_F(PortTest, TestFoundation) { - rtc::scoped_ptr<TestPort> testport( + std::unique_ptr<TestPort> testport( CreateTestPort(kLocalAddr1, "name", "pass")); testport->AddCandidateAddress(kLocalAddr1, kLocalAddr1, LOCAL_PORT_TYPE, @@ -2148,21 +2141,21 @@ // This test verifies the foundation of different types of ICE candidates. TEST_F(PortTest, TestCandidateFoundation) { - rtc::scoped_ptr<rtc::NATServer> nat_server( + std::unique_ptr<rtc::NATServer> nat_server( CreateNatServer(kNatAddr1, NAT_OPEN_CONE)); - rtc::scoped_ptr<UDPPort> udpport1(CreateUdpPort(kLocalAddr1)); + std::unique_ptr<UDPPort> udpport1(CreateUdpPort(kLocalAddr1)); udpport1->PrepareAddress(); - rtc::scoped_ptr<UDPPort> udpport2(CreateUdpPort(kLocalAddr1)); + std::unique_ptr<UDPPort> udpport2(CreateUdpPort(kLocalAddr1)); udpport2->PrepareAddress(); EXPECT_EQ(udpport1->Candidates()[0].foundation(), udpport2->Candidates()[0].foundation()); - rtc::scoped_ptr<TCPPort> tcpport1(CreateTcpPort(kLocalAddr1)); + std::unique_ptr<TCPPort> tcpport1(CreateTcpPort(kLocalAddr1)); tcpport1->PrepareAddress(); - rtc::scoped_ptr<TCPPort> tcpport2(CreateTcpPort(kLocalAddr1)); + std::unique_ptr<TCPPort> tcpport2(CreateTcpPort(kLocalAddr1)); tcpport2->PrepareAddress(); EXPECT_EQ(tcpport1->Candidates()[0].foundation(), tcpport2->Candidates()[0].foundation()); - rtc::scoped_ptr<Port> stunport( + std::unique_ptr<Port> stunport( CreateStunPort(kLocalAddr1, nat_socket_factory1())); stunport->PrepareAddress(); ASSERT_EQ_WAIT(1U, stunport->Candidates().size(), kTimeout); @@ -2175,8 +2168,7 @@ EXPECT_NE(udpport2->Candidates()[0].foundation(), stunport->Candidates()[0].foundation()); // Verify GTURN candidate foundation. - rtc::scoped_ptr<RelayPort> relayport( - CreateGturnPort(kLocalAddr1)); + std::unique_ptr<RelayPort> relayport(CreateGturnPort(kLocalAddr1)); relayport->AddServerAddress( cricket::ProtocolAddress(kRelayUdpIntAddr, cricket::PROTO_UDP)); relayport->PrepareAddress(); @@ -2186,8 +2178,8 @@ EXPECT_NE(udpport2->Candidates()[0].foundation(), relayport->Candidates()[0].foundation()); // Verifying TURN candidate foundation. - rtc::scoped_ptr<Port> turnport1(CreateTurnPort( - kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); + std::unique_ptr<Port> turnport1( + CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); turnport1->PrepareAddress(); ASSERT_EQ_WAIT(1U, turnport1->Candidates().size(), kTimeout); EXPECT_NE(udpport1->Candidates()[0].foundation(), @@ -2196,8 +2188,8 @@ turnport1->Candidates()[0].foundation()); EXPECT_NE(stunport->Candidates()[0].foundation(), turnport1->Candidates()[0].foundation()); - rtc::scoped_ptr<Port> turnport2(CreateTurnPort( - kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); + std::unique_ptr<Port> turnport2( + CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); turnport2->PrepareAddress(); ASSERT_EQ_WAIT(1U, turnport2->Candidates().size(), kTimeout); EXPECT_EQ(turnport1->Candidates()[0].foundation(), @@ -2208,9 +2200,9 @@ SocketAddress kTurnUdpExtAddr2("99.99.98.5", 0); TestTurnServer turn_server2( rtc::Thread::Current(), kTurnUdpIntAddr2, kTurnUdpExtAddr2); - rtc::scoped_ptr<Port> turnport3(CreateTurnPort( - kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP, - kTurnUdpIntAddr2)); + std::unique_ptr<Port> turnport3( + CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP, + kTurnUdpIntAddr2)); turnport3->PrepareAddress(); ASSERT_EQ_WAIT(1U, turnport3->Candidates().size(), kTimeout); EXPECT_NE(turnport3->Candidates()[0].foundation(), @@ -2220,7 +2212,7 @@ // different foundations if their relay protocols are different. TestTurnServer turn_server3(rtc::Thread::Current(), kTurnTcpIntAddr, kTurnUdpExtAddr, PROTO_TCP); - rtc::scoped_ptr<Port> turnport4( + std::unique_ptr<Port> turnport4( CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_TCP, PROTO_UDP)); turnport4->PrepareAddress(); ASSERT_EQ_WAIT(1U, turnport4->Candidates().size(), kTimeout); @@ -2231,16 +2223,16 @@ // This test verifies the related addresses of different types of // ICE candiates. TEST_F(PortTest, TestCandidateRelatedAddress) { - rtc::scoped_ptr<rtc::NATServer> nat_server( + std::unique_ptr<rtc::NATServer> nat_server( CreateNatServer(kNatAddr1, NAT_OPEN_CONE)); - rtc::scoped_ptr<UDPPort> udpport(CreateUdpPort(kLocalAddr1)); + std::unique_ptr<UDPPort> udpport(CreateUdpPort(kLocalAddr1)); udpport->PrepareAddress(); // For UDPPort, related address will be empty. EXPECT_TRUE(udpport->Candidates()[0].related_address().IsNil()); // Testing related address for stun candidates. // For stun candidate related address must be equal to the base // socket address. - rtc::scoped_ptr<StunPort> stunport( + std::unique_ptr<StunPort> stunport( CreateStunPort(kLocalAddr1, nat_socket_factory1())); stunport->PrepareAddress(); ASSERT_EQ_WAIT(1U, stunport->Candidates().size(), kTimeout); @@ -2253,8 +2245,7 @@ // Verifying the related address for the GTURN candidates. // NOTE: In case of GTURN related address will be equal to the mapped // address, but address(mapped) will not be XOR. - rtc::scoped_ptr<RelayPort> relayport( - CreateGturnPort(kLocalAddr1)); + std::unique_ptr<RelayPort> relayport(CreateGturnPort(kLocalAddr1)); relayport->AddServerAddress( cricket::ProtocolAddress(kRelayUdpIntAddr, cricket::PROTO_UDP)); relayport->PrepareAddress(); @@ -2264,8 +2255,8 @@ relayport->Candidates()[0].related_address()); // Verifying the related address for TURN candidate. // For TURN related address must be equal to the mapped address. - rtc::scoped_ptr<Port> turnport(CreateTurnPort( - kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); + std::unique_ptr<Port> turnport( + CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); turnport->PrepareAddress(); ASSERT_EQ_WAIT(1U, turnport->Candidates().size(), kTimeout); EXPECT_EQ(kTurnUdpExtAddr.ipaddr(), @@ -2285,10 +2276,10 @@ // Test the Connection priority is calculated correctly. TEST_F(PortTest, TestConnectionPriority) { - rtc::scoped_ptr<TestPort> lport( + std::unique_ptr<TestPort> lport( CreateTestPort(kLocalAddr1, "lfrag", "lpass")); lport->set_type_preference(cricket::ICE_TYPE_PREFERENCE_HOST); - rtc::scoped_ptr<TestPort> rport( + std::unique_ptr<TestPort> rport( CreateTestPort(kLocalAddr2, "rfrag", "rpass")); rport->set_type_preference(cricket::ICE_TYPE_PREFERENCE_RELAY); lport->set_component(123); @@ -2428,9 +2419,9 @@ kLocalAddr1, "lfrag", "lpass", cricket::ICEROLE_CONTROLLING, kTiebreaker1); - rtc::scoped_ptr<TestPort> ice_lite_port(CreateTestPort( - kLocalAddr2, "rfrag", "rpass", - cricket::ICEROLE_CONTROLLED, kTiebreaker2)); + std::unique_ptr<TestPort> ice_lite_port( + CreateTestPort(kLocalAddr2, "rfrag", "rpass", cricket::ICEROLE_CONTROLLED, + kTiebreaker2)); // Setup TestChannel. This behaves like FULL mode client. TestChannel ch1(ice_full_port); ch1.SetIceMode(ICEMODE_FULL); @@ -2462,7 +2453,7 @@ // But we need a connection to send a response message. ice_lite_port->CreateConnection( ice_full_port->Candidates()[0], cricket::Port::ORIGIN_MESSAGE); - rtc::scoped_ptr<IceMessage> request(CopyStunMessage(msg)); + std::unique_ptr<IceMessage> request(CopyStunMessage(msg)); ice_lite_port->SendBindingResponse( request.get(), ice_full_port->Candidates()[0].address()); @@ -2576,21 +2567,21 @@ } TEST_F(PortTest, TestSupportsProtocol) { - rtc::scoped_ptr<Port> udp_port(CreateUdpPort(kLocalAddr1)); + std::unique_ptr<Port> udp_port(CreateUdpPort(kLocalAddr1)); EXPECT_TRUE(udp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); EXPECT_FALSE(udp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); - rtc::scoped_ptr<Port> stun_port( + std::unique_ptr<Port> stun_port( CreateStunPort(kLocalAddr1, nat_socket_factory1())); EXPECT_TRUE(stun_port->SupportsProtocol(UDP_PROTOCOL_NAME)); EXPECT_FALSE(stun_port->SupportsProtocol(TCP_PROTOCOL_NAME)); - rtc::scoped_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1)); + std::unique_ptr<Port> tcp_port(CreateTcpPort(kLocalAddr1)); EXPECT_TRUE(tcp_port->SupportsProtocol(TCP_PROTOCOL_NAME)); EXPECT_TRUE(tcp_port->SupportsProtocol(SSLTCP_PROTOCOL_NAME)); EXPECT_FALSE(tcp_port->SupportsProtocol(UDP_PROTOCOL_NAME)); - rtc::scoped_ptr<Port> turn_port( + std::unique_ptr<Port> turn_port( CreateTurnPort(kLocalAddr1, nat_socket_factory1(), PROTO_UDP, PROTO_UDP)); EXPECT_TRUE(turn_port->SupportsProtocol(UDP_PROTOCOL_NAME)); EXPECT_FALSE(turn_port->SupportsProtocol(TCP_PROTOCOL_NAME));
diff --git a/webrtc/p2p/base/pseudotcp.cc b/webrtc/p2p/base/pseudotcp.cc index 1dfdcbb..612623b 100644 --- a/webrtc/p2p/base/pseudotcp.cc +++ b/webrtc/p2p/base/pseudotcp.cc
@@ -14,6 +14,7 @@ #include <stdlib.h> #include <algorithm> +#include <memory> #include <set> #include "webrtc/base/arraysize.h" @@ -22,7 +23,6 @@ #include "webrtc/base/byteorder.h" #include "webrtc/base/common.h" #include "webrtc/base/logging.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/socket.h" #include "webrtc/base/stringutils.h" #include "webrtc/base/timeutils.h" @@ -518,7 +518,7 @@ uint32_t now = Now(); - rtc::scoped_ptr<uint8_t[]> buffer(new uint8_t[MAX_PACKET]); + std::unique_ptr<uint8_t[]> buffer(new uint8_t[MAX_PACKET]); long_to_bytes(m_conv, buffer.get()); long_to_bytes(seq, buffer.get() + 4); long_to_bytes(m_rcv_nxt, buffer.get() + 8);
diff --git a/webrtc/p2p/base/relayport_unittest.cc b/webrtc/p2p/base/relayport_unittest.cc index d644d67..738ea9a 100644 --- a/webrtc/p2p/base/relayport_unittest.cc +++ b/webrtc/p2p/base/relayport_unittest.cc
@@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> + #include "webrtc/p2p/base/basicpacketsocketfactory.h" #include "webrtc/p2p/base/relayport.h" #include "webrtc/p2p/base/relayserver.h" @@ -15,7 +17,6 @@ #include "webrtc/base/helpers.h" #include "webrtc/base/logging.h" #include "webrtc/base/physicalsocketserver.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/socketadapters.h" #include "webrtc/base/socketaddress.h" #include "webrtc/base/ssladapter.h" @@ -179,7 +180,7 @@ // Create a tcp server socket that listens on the fake address so // the relay port can attempt to connect to it. - rtc::scoped_ptr<rtc::AsyncSocket> tcp_server_socket( + std::unique_ptr<rtc::AsyncSocket> tcp_server_socket( CreateServerSocket(kRelayTcpAddr)); // Add server addresses to the relay port and let it start. @@ -244,16 +245,15 @@ typedef std::map<rtc::AsyncPacketSocket*, int> PacketMap; rtc::Thread* main_; - rtc::scoped_ptr<rtc::PhysicalSocketServer> - physical_socket_server_; - rtc::scoped_ptr<rtc::VirtualSocketServer> virtual_socket_server_; + std::unique_ptr<rtc::PhysicalSocketServer> physical_socket_server_; + std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_; rtc::SocketServerScope ss_scope_; rtc::Network network_; rtc::BasicPacketSocketFactory socket_factory_; std::string username_; std::string password_; - rtc::scoped_ptr<cricket::RelayPort> relay_port_; - rtc::scoped_ptr<cricket::RelayServer> relay_server_; + std::unique_ptr<cricket::RelayPort> relay_port_; + std::unique_ptr<cricket::RelayServer> relay_server_; std::vector<cricket::ProtocolAddress> failed_connections_; std::vector<cricket::ProtocolAddress> soft_timedout_connections_; PacketMap received_packet_count_;
diff --git a/webrtc/p2p/base/relayserver_unittest.cc b/webrtc/p2p/base/relayserver_unittest.cc index 3581f71..1d07a07 100644 --- a/webrtc/p2p/base/relayserver_unittest.cc +++ b/webrtc/p2p/base/relayserver_unittest.cc
@@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> #include <string> #include "webrtc/p2p/base/relayserver.h" @@ -60,16 +61,14 @@ } void Allocate() { - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_ALLOCATE_REQUEST)); + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_ALLOCATE_REQUEST)); AddUsernameAttr(req.get(), username_); AddLifetimeAttr(req.get(), LIFETIME); Send1(req.get()); delete Receive1(); } void Bind() { - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_BINDING_REQUEST)); + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_BINDING_REQUEST)); AddUsernameAttr(req.get(), username_); Send2(req.get()); delete Receive1(); @@ -172,12 +171,12 @@ msg->AddAttribute(attr); } - 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<RelayServer> server_; - rtc::scoped_ptr<rtc::TestClient> client1_; - rtc::scoped_ptr<rtc::TestClient> client2_; + std::unique_ptr<RelayServer> server_; + std::unique_ptr<rtc::TestClient> client1_; + std::unique_ptr<rtc::TestClient> client2_; std::string username_; std::string password_; }; @@ -190,8 +189,8 @@ // Send an allocate request without a username and verify it is rejected. TEST_F(RelayServerTest, TestAllocateNoUsername) { - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_ALLOCATE_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_ALLOCATE_REQUEST)), + res; Send1(req.get()); res.reset(Receive1()); @@ -209,8 +208,8 @@ // Send a binding request and verify that it is rejected. TEST_F(RelayServerTest, TestBindingRequest) { - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_BINDING_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_BINDING_REQUEST)), + res; AddUsernameAttr(req.get(), username_); Send1(req.get()); @@ -229,8 +228,8 @@ // Send an allocate request and verify that it is accepted. TEST_F(RelayServerTest, TestAllocate) { - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_ALLOCATE_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_ALLOCATE_REQUEST)), + res; AddUsernameAttr(req.get(), username_); AddLifetimeAttr(req.get(), LIFETIME); @@ -259,8 +258,8 @@ TEST_F(RelayServerTest, TestReallocate) { Allocate(); - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_ALLOCATE_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_ALLOCATE_REQUEST)), + res; AddMagicCookieAttr(req.get()); AddUsernameAttr(req.get(), username_); @@ -289,8 +288,8 @@ TEST_F(RelayServerTest, TestRemoteBind) { Allocate(); - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_BINDING_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_BINDING_REQUEST)), + res; AddUsernameAttr(req.get(), username_); Send2(req.get()); @@ -304,7 +303,7 @@ ASSERT_TRUE(recv_data != NULL); rtc::ByteBufferReader buf(recv_data->bytes(), recv_data->length()); - rtc::scoped_ptr<StunMessage> res2(new StunMessage()); + std::unique_ptr<StunMessage> res2(new StunMessage()); EXPECT_TRUE(res2->Read(&buf)); EXPECT_EQ(STUN_BINDING_REQUEST, res2->type()); EXPECT_EQ(req->transaction_id(), res2->transaction_id()); @@ -335,8 +334,7 @@ Allocate(); Bind(); - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_SEND_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_SEND_REQUEST)), res; AddMagicCookieAttr(req.get()); Send1(req.get()); @@ -358,8 +356,7 @@ Allocate(); Bind(); - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_SEND_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_SEND_REQUEST)), res; AddMagicCookieAttr(req.get()); AddUsernameAttr(req.get(), "foobarbizbaz"); @@ -383,8 +380,7 @@ Allocate(); Bind(); - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_SEND_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_SEND_REQUEST)), res; AddMagicCookieAttr(req.get()); AddUsernameAttr(req.get(), username_); @@ -407,8 +403,7 @@ Allocate(); Bind(); - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_SEND_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_SEND_REQUEST)), res; AddMagicCookieAttr(req.get()); AddUsernameAttr(req.get(), username_); AddDestinationAttr(req.get(), client2_addr); @@ -432,8 +427,8 @@ Allocate(); Bind(); - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_BINDING_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_BINDING_REQUEST)), + res; AddMagicCookieAttr(req.get()); AddUsernameAttr(req.get(), username_); @@ -458,8 +453,7 @@ Bind(); for (int i = 0; i < 10; i++) { - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_SEND_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_SEND_REQUEST)), res; AddMagicCookieAttr(req.get()); AddUsernameAttr(req.get(), username_); AddDestinationAttr(req.get(), client2_addr); @@ -501,8 +495,7 @@ // Wait twice the lifetime to make sure the server has expired the binding. rtc::Thread::Current()->ProcessMessages((LIFETIME * 2) * 1000); - rtc::scoped_ptr<StunMessage> req( - CreateStunMessage(STUN_SEND_REQUEST)), res; + std::unique_ptr<StunMessage> req(CreateStunMessage(STUN_SEND_REQUEST)), res; AddMagicCookieAttr(req.get()); AddUsernameAttr(req.get(), username_); AddDestinationAttr(req.get(), client2_addr);
diff --git a/webrtc/p2p/base/stun.cc b/webrtc/p2p/base/stun.cc index d0f0014..ac3fd5f 100644 --- a/webrtc/p2p/base/stun.cc +++ b/webrtc/p2p/base/stun.cc
@@ -12,12 +12,13 @@ #include <string.h> +#include <memory> + #include "webrtc/base/byteorder.h" #include "webrtc/base/common.h" #include "webrtc/base/crc32.h" #include "webrtc/base/logging.h" #include "webrtc/base/messagedigest.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/stringencode.h" using rtc::ByteBufferReader; @@ -173,7 +174,7 @@ // Getting length of the message to calculate Message Integrity. size_t mi_pos = current_pos; - rtc::scoped_ptr<char[]> temp_data(new char[current_pos]); + std::unique_ptr<char[]> temp_data(new char[current_pos]); memcpy(temp_data.get(), data, current_pos); if (size > mi_pos + kStunAttributeHeaderSize + kStunMessageIntegritySize) { // Stun message has other attributes after message integrity.
diff --git a/webrtc/p2p/base/stun_unittest.cc b/webrtc/p2p/base/stun_unittest.cc index 2213397..d7ca999 100644 --- a/webrtc/p2p/base/stun_unittest.cc +++ b/webrtc/p2p/base/stun_unittest.cc
@@ -16,7 +16,6 @@ #include "webrtc/base/gunit.h" #include "webrtc/base/logging.h" #include "webrtc/base/messagedigest.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/socketaddress.h" namespace cricket {
diff --git a/webrtc/p2p/base/stunport.h b/webrtc/p2p/base/stunport.h index a0eba51..cd844aa 100644 --- a/webrtc/p2p/base/stunport.h +++ b/webrtc/p2p/base/stunport.h
@@ -11,6 +11,7 @@ #ifndef WEBRTC_P2P_BASE_STUNPORT_H_ #define WEBRTC_P2P_BASE_STUNPORT_H_ +#include <memory> #include <string> #include "webrtc/p2p/base/port.h" @@ -224,7 +225,7 @@ StunRequestManager requests_; rtc::AsyncPacketSocket* socket_; int error_; - rtc::scoped_ptr<AddressResolver> resolver_; + std::unique_ptr<AddressResolver> resolver_; bool ready_; int stun_keepalive_delay_; int stun_keepalive_lifetime_;
diff --git a/webrtc/p2p/base/stunport_unittest.cc b/webrtc/p2p/base/stunport_unittest.cc index 1926b93..702ec25 100644 --- a/webrtc/p2p/base/stunport_unittest.cc +++ b/webrtc/p2p/base/stunport_unittest.cc
@@ -8,13 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> + #include "webrtc/p2p/base/basicpacketsocketfactory.h" #include "webrtc/p2p/base/stunport.h" #include "webrtc/p2p/base/teststunserver.h" #include "webrtc/base/gunit.h" #include "webrtc/base/helpers.h" #include "webrtc/base/physicalsocketserver.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/socketaddress.h" #include "webrtc/base/ssladapter.h" #include "webrtc/base/virtualsocketserver.h" @@ -155,15 +156,15 @@ } private: - 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::Network network_; rtc::BasicPacketSocketFactory socket_factory_; - rtc::scoped_ptr<cricket::UDPPort> stun_port_; - rtc::scoped_ptr<cricket::TestStunServer> stun_server_1_; - rtc::scoped_ptr<cricket::TestStunServer> stun_server_2_; - rtc::scoped_ptr<rtc::AsyncPacketSocket> socket_; + std::unique_ptr<cricket::UDPPort> stun_port_; + std::unique_ptr<cricket::TestStunServer> stun_server_1_; + std::unique_ptr<cricket::TestStunServer> stun_server_2_; + std::unique_ptr<rtc::AsyncPacketSocket> socket_; bool done_; bool error_; int stun_keepalive_delay_;
diff --git a/webrtc/p2p/base/stunrequest.cc b/webrtc/p2p/base/stunrequest.cc index 546dd15..b12e7cb 100644 --- a/webrtc/p2p/base/stunrequest.cc +++ b/webrtc/p2p/base/stunrequest.cc
@@ -11,6 +11,8 @@ #include "webrtc/p2p/base/stunrequest.h" #include <algorithm> +#include <memory> + #include "webrtc/base/common.h" #include "webrtc/base/helpers.h" #include "webrtc/base/logging.h" @@ -139,7 +141,7 @@ // Parse the STUN message and continue processing as usual. rtc::ByteBufferReader buf(data, size); - rtc::scoped_ptr<StunMessage> response(iter->second->msg_->CreateNew()); + std::unique_ptr<StunMessage> response(iter->second->msg_->CreateNew()); if (!response->Read(&buf)) { LOG(LS_WARNING) << "Failed to read STUN response " << rtc::hex_encode(id); return false;
diff --git a/webrtc/p2p/base/stunserver.h b/webrtc/p2p/base/stunserver.h index a7eeab1..3f7e7de 100644 --- a/webrtc/p2p/base/stunserver.h +++ b/webrtc/p2p/base/stunserver.h
@@ -11,6 +11,8 @@ #ifndef WEBRTC_P2P_BASE_STUNSERVER_H_ #define WEBRTC_P2P_BASE_STUNSERVER_H_ +#include <memory> + #include "webrtc/p2p/base/stun.h" #include "webrtc/base/asyncudpsocket.h" #include "webrtc/base/scoped_ptr.h" @@ -58,7 +60,7 @@ StunMessage* response) const; private: - rtc::scoped_ptr<rtc::AsyncUDPSocket> socket_; + std::unique_ptr<rtc::AsyncUDPSocket> socket_; }; } // namespace cricket
diff --git a/webrtc/p2p/base/stunserver_unittest.cc b/webrtc/p2p/base/stunserver_unittest.cc index 973ab2a..e468447 100644 --- a/webrtc/p2p/base/stunserver_unittest.cc +++ b/webrtc/p2p/base/stunserver_unittest.cc
@@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> #include <string> #include "webrtc/p2p/base/stunserver.h" @@ -62,11 +63,11 @@ return msg; } private: - 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::Thread worker_; - rtc::scoped_ptr<StunServer> server_; - rtc::scoped_ptr<rtc::TestClient> client_; + std::unique_ptr<StunServer> server_; + std::unique_ptr<rtc::TestClient> client_; }; // Disable for TSan v2, see
diff --git a/webrtc/p2p/base/tcpport.h b/webrtc/p2p/base/tcpport.h index cfc6245..77bbd09 100644 --- a/webrtc/p2p/base/tcpport.h +++ b/webrtc/p2p/base/tcpport.h
@@ -12,7 +12,9 @@ #define WEBRTC_P2P_BASE_TCPPORT_H_ #include <list> +#include <memory> #include <string> + #include "webrtc/p2p/base/port.h" #include "webrtc/base/asyncpacketsocket.h" @@ -164,7 +166,7 @@ const rtc::PacketTime& packet_time); void OnReadyToSend(rtc::AsyncPacketSocket* socket); - rtc::scoped_ptr<rtc::AsyncPacketSocket> socket_; + std::unique_ptr<rtc::AsyncPacketSocket> socket_; int error_; bool outgoing_;
diff --git a/webrtc/p2p/base/testrelayserver.h b/webrtc/p2p/base/testrelayserver.h index 87cb9e5..ba64008 100644 --- a/webrtc/p2p/base/testrelayserver.h +++ b/webrtc/p2p/base/testrelayserver.h
@@ -11,6 +11,8 @@ #ifndef WEBRTC_P2P_BASE_TESTRELAYSERVER_H_ #define WEBRTC_P2P_BASE_TESTRELAYSERVER_H_ +#include <memory> + #include "webrtc/p2p/base/relayserver.h" #include "webrtc/base/asynctcpsocket.h" #include "webrtc/base/scoped_ptr.h" @@ -90,10 +92,10 @@ } private: cricket::RelayServer server_; - rtc::scoped_ptr<rtc::AsyncSocket> tcp_int_socket_; - rtc::scoped_ptr<rtc::AsyncSocket> tcp_ext_socket_; - rtc::scoped_ptr<rtc::AsyncSocket> ssl_int_socket_; - rtc::scoped_ptr<rtc::AsyncSocket> ssl_ext_socket_; + std::unique_ptr<rtc::AsyncSocket> tcp_int_socket_; + std::unique_ptr<rtc::AsyncSocket> tcp_ext_socket_; + std::unique_ptr<rtc::AsyncSocket> ssl_int_socket_; + std::unique_ptr<rtc::AsyncSocket> ssl_ext_socket_; }; } // namespace cricket
diff --git a/webrtc/p2p/base/transport_unittest.cc b/webrtc/p2p/base/transport_unittest.cc index 15bbe6e..658c143 100644 --- a/webrtc/p2p/base/transport_unittest.cc +++ b/webrtc/p2p/base/transport_unittest.cc
@@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> + #include "webrtc/base/fakesslidentity.h" #include "webrtc/base/gunit.h" #include "webrtc/base/network.h" @@ -50,7 +52,7 @@ } protected: - rtc::scoped_ptr<FakeTransport> transport_; + std::unique_ptr<FakeTransport> transport_; FakeTransportChannel* channel_; };
diff --git a/webrtc/p2p/base/transportdescription.h b/webrtc/p2p/base/transportdescription.h index 003780b..d9cd524 100644 --- a/webrtc/p2p/base/transportdescription.h +++ b/webrtc/p2p/base/transportdescription.h
@@ -12,6 +12,7 @@ #define WEBRTC_P2P_BASE_TRANSPORTDESCRIPTION_H_ #include <algorithm> +#include <memory> #include <string> #include <vector> @@ -139,7 +140,7 @@ IceMode ice_mode; ConnectionRole connection_role; - rtc::scoped_ptr<rtc::SSLFingerprint> identity_fingerprint; + std::unique_ptr<rtc::SSLFingerprint> identity_fingerprint; }; } // namespace cricket
diff --git a/webrtc/p2p/base/transportdescriptionfactory.cc b/webrtc/p2p/base/transportdescriptionfactory.cc index 1ddf55d..e57b7e3 100644 --- a/webrtc/p2p/base/transportdescriptionfactory.cc +++ b/webrtc/p2p/base/transportdescriptionfactory.cc
@@ -10,6 +10,8 @@ #include "webrtc/p2p/base/transportdescriptionfactory.h" +#include <memory> + #include "webrtc/p2p/base/transportdescription.h" #include "webrtc/base/helpers.h" #include "webrtc/base/logging.h" @@ -25,7 +27,7 @@ TransportDescription* TransportDescriptionFactory::CreateOffer( const TransportOptions& options, const TransportDescription* current_description) const { - rtc::scoped_ptr<TransportDescription> desc(new TransportDescription()); + std::unique_ptr<TransportDescription> desc(new TransportDescription()); // Generate the ICE credentials if we don't already have them. if (!current_description || options.ice_restart) { @@ -59,7 +61,7 @@ return NULL; } - rtc::scoped_ptr<TransportDescription> desc(new TransportDescription()); + std::unique_ptr<TransportDescription> desc(new TransportDescription()); // Generate the ICE credentials if we don't already have them or ice is // being restarted. if (!current_description || options.ice_restart) {
diff --git a/webrtc/p2p/base/turnport_unittest.cc b/webrtc/p2p/base/turnport_unittest.cc index 2c93ead..56d4460 100644 --- a/webrtc/p2p/base/turnport_unittest.cc +++ b/webrtc/p2p/base/turnport_unittest.cc
@@ -11,6 +11,8 @@ #include <dirent.h> #endif +#include <memory> + #include "webrtc/p2p/base/basicpacketsocketfactory.h" #include "webrtc/p2p/base/p2pconstants.h" #include "webrtc/p2p/base/portallocator.h" @@ -26,7 +28,6 @@ #include "webrtc/base/helpers.h" #include "webrtc/base/logging.h" #include "webrtc/base/physicalsocketserver.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/socketaddress.h" #include "webrtc/base/ssladapter.h" #include "webrtc/base/thread.h" @@ -507,15 +508,15 @@ protected: rtc::Thread* main_; - rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; - rtc::scoped_ptr<TurnPortTestVirtualSocketServer> ss_; + std::unique_ptr<rtc::PhysicalSocketServer> pss_; + std::unique_ptr<TurnPortTestVirtualSocketServer> ss_; rtc::SocketServerScope ss_scope_; rtc::Network network_; rtc::BasicPacketSocketFactory socket_factory_; - rtc::scoped_ptr<rtc::AsyncPacketSocket> socket_; + std::unique_ptr<rtc::AsyncPacketSocket> socket_; cricket::TestTurnServer turn_server_; - rtc::scoped_ptr<TurnPort> turn_port_; - rtc::scoped_ptr<UDPPort> udp_port_; + std::unique_ptr<TurnPort> turn_port_; + std::unique_ptr<UDPPort> udp_port_; bool turn_ready_; bool turn_error_; bool turn_unknown_address_;
diff --git a/webrtc/p2p/base/turnserver.h b/webrtc/p2p/base/turnserver.h index e520a9e..c9eb803 100644 --- a/webrtc/p2p/base/turnserver.h +++ b/webrtc/p2p/base/turnserver.h
@@ -13,6 +13,7 @@ #include <list> #include <map> +#include <memory> #include <set> #include <string> @@ -125,7 +126,7 @@ TurnServer* server_; rtc::Thread* thread_; TurnServerConnection conn_; - rtc::scoped_ptr<rtc::AsyncPacketSocket> external_socket_; + std::unique_ptr<rtc::AsyncPacketSocket> external_socket_; std::string key_; std::string transaction_id_; std::string username_; @@ -269,8 +270,7 @@ InternalSocketMap server_sockets_; ServerSocketMap server_listen_sockets_; - rtc::scoped_ptr<rtc::PacketSocketFactory> - external_socket_factory_; + std::unique_ptr<rtc::PacketSocketFactory> external_socket_factory_; rtc::SocketAddress external_addr_; AllocationMap allocations_;
diff --git a/webrtc/p2p/client/basicportallocator.h b/webrtc/p2p/client/basicportallocator.h index ca1a23a..c66ae59 100644 --- a/webrtc/p2p/client/basicportallocator.h +++ b/webrtc/p2p/client/basicportallocator.h
@@ -11,6 +11,7 @@ #ifndef WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ #define WEBRTC_P2P_CLIENT_BASICPORTALLOCATOR_H_ +#include <memory> #include <string> #include <vector> @@ -185,7 +186,7 @@ BasicPortAllocator* allocator_; rtc::Thread* network_thread_; - rtc::scoped_ptr<rtc::PacketSocketFactory> owned_socket_factory_; + std::unique_ptr<rtc::PacketSocketFactory> owned_socket_factory_; rtc::PacketSocketFactory* socket_factory_; bool allocation_started_; bool network_manager_started_; @@ -320,7 +321,7 @@ State state_; uint32_t flags_; ProtocolList protocols_; - rtc::scoped_ptr<rtc::AsyncPacketSocket> udp_socket_; + std::unique_ptr<rtc::AsyncPacketSocket> udp_socket_; // There will be only one udp port per AllocationSequence. UDPPort* udp_port_; std::vector<TurnPort*> turn_ports_;
diff --git a/webrtc/p2p/client/fakeportallocator.h b/webrtc/p2p/client/fakeportallocator.h index fb18826..d16c9b6 100644 --- a/webrtc/p2p/client/fakeportallocator.h +++ b/webrtc/p2p/client/fakeportallocator.h
@@ -11,7 +11,9 @@ #ifndef WEBRTC_P2P_CLIENT_FAKEPORTALLOCATOR_H_ #define WEBRTC_P2P_CLIENT_FAKEPORTALLOCATOR_H_ +#include <memory> #include <string> + #include "webrtc/p2p/base/basicpacketsocketfactory.h" #include "webrtc/p2p/base/portallocator.h" #include "webrtc/p2p/base/udpport.h" @@ -133,7 +135,7 @@ rtc::Thread* worker_thread_; rtc::PacketSocketFactory* factory_; rtc::Network network_; - rtc::scoped_ptr<cricket::Port> port_; + std::unique_ptr<cricket::Port> port_; bool running_; int port_config_count_; }; @@ -177,7 +179,7 @@ private: rtc::Thread* worker_thread_; rtc::PacketSocketFactory* factory_; - rtc::scoped_ptr<rtc::BasicPacketSocketFactory> owned_factory_; + std::unique_ptr<rtc::BasicPacketSocketFactory> owned_factory_; ServerAddresses stun_servers_; std::vector<RelayServerConfig> turn_servers_; };
diff --git a/webrtc/p2p/client/portallocator_unittest.cc b/webrtc/p2p/client/portallocator_unittest.cc index a76900a..2181903 100644 --- a/webrtc/p2p/client/portallocator_unittest.cc +++ b/webrtc/p2p/client/portallocator_unittest.cc
@@ -8,6 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> + #include "webrtc/p2p/base/basicpacketsocketfactory.h" #include "webrtc/p2p/base/p2pconstants.h" #include "webrtc/p2p/base/p2ptransportchannel.h" @@ -370,19 +372,19 @@ allocator().set_step_delay(cricket::kMinimumStepDelay); } - rtc::scoped_ptr<rtc::PhysicalSocketServer> pss_; - rtc::scoped_ptr<rtc::VirtualSocketServer> vss_; - rtc::scoped_ptr<rtc::FirewallSocketServer> fss_; + std::unique_ptr<rtc::PhysicalSocketServer> pss_; + std::unique_ptr<rtc::VirtualSocketServer> vss_; + std::unique_ptr<rtc::FirewallSocketServer> fss_; rtc::SocketServerScope ss_scope_; - rtc::scoped_ptr<rtc::NATServer> nat_server_; + std::unique_ptr<rtc::NATServer> nat_server_; rtc::NATSocketFactory nat_factory_; - rtc::scoped_ptr<rtc::BasicPacketSocketFactory> nat_socket_factory_; - rtc::scoped_ptr<cricket::TestStunServer> stun_server_; + std::unique_ptr<rtc::BasicPacketSocketFactory> nat_socket_factory_; + std::unique_ptr<cricket::TestStunServer> stun_server_; cricket::TestRelayServer relay_server_; cricket::TestTurnServer turn_server_; rtc::FakeNetworkManager network_manager_; - rtc::scoped_ptr<cricket::BasicPortAllocator> allocator_; - rtc::scoped_ptr<cricket::PortAllocatorSession> session_; + std::unique_ptr<cricket::BasicPortAllocator> allocator_; + std::unique_ptr<cricket::PortAllocatorSession> session_; std::vector<cricket::PortInterface*> ports_; std::vector<cricket::Candidate> candidates_; bool candidate_allocation_done_;
diff --git a/webrtc/p2p/quic/quicconnectionhelper_unittest.cc b/webrtc/p2p/quic/quicconnectionhelper_unittest.cc index 1a7313c..b56ae8c 100644 --- a/webrtc/p2p/quic/quicconnectionhelper_unittest.cc +++ b/webrtc/p2p/quic/quicconnectionhelper_unittest.cc
@@ -8,11 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> + #include "webrtc/p2p/quic/quicconnectionhelper.h" #include "net/quic/quic_time.h" #include "webrtc/base/gunit.h" -#include "webrtc/base/scoped_ptr.h" using cricket::QuicAlarm; using cricket::QuicConnectionHelper; @@ -89,7 +90,7 @@ // Used for setting clock time relative to alarm. MockClock clock_; - rtc::scoped_ptr<QuicAlarm> alarm_; + std::unique_ptr<QuicAlarm> alarm_; }; // Test that the alarm is fired.
diff --git a/webrtc/p2p/quic/quicsession.cc b/webrtc/p2p/quic/quicsession.cc index a70aa0b..7464c68 100644 --- a/webrtc/p2p/quic/quicsession.cc +++ b/webrtc/p2p/quic/quicsession.cc
@@ -20,7 +20,7 @@ namespace cricket { -QuicSession::QuicSession(rtc::scoped_ptr<net::QuicConnection> connection, +QuicSession::QuicSession(std::unique_ptr<net::QuicConnection> connection, const net::QuicConfig& config) : net::QuicSession(connection.release(), config) {}
diff --git a/webrtc/p2p/quic/quicsession.h b/webrtc/p2p/quic/quicsession.h index e0ea296..a6da38a 100644 --- a/webrtc/p2p/quic/quicsession.h +++ b/webrtc/p2p/quic/quicsession.h
@@ -11,6 +11,7 @@ #ifndef WEBRTC_P2P_QUIC_QUICSESSION_H_ #define WEBRTC_P2P_QUIC_QUICSESSION_H_ +#include <memory> #include <string> #include "net/quic/quic_crypto_client_stream.h" @@ -29,7 +30,7 @@ // reading/writing of data using QUIC packets. class QuicSession : public net::QuicSession, public sigslot::has_slots<> { public: - QuicSession(rtc::scoped_ptr<net::QuicConnection> connection, + QuicSession(std::unique_ptr<net::QuicConnection> connection, const net::QuicConfig& config); ~QuicSession() override; @@ -82,7 +83,7 @@ virtual ReliableQuicStream* CreateDataStream(net::QuicStreamId id); private: - rtc::scoped_ptr<net::QuicCryptoStream> crypto_stream_; + std::unique_ptr<net::QuicCryptoStream> crypto_stream_; RTC_DISALLOW_COPY_AND_ASSIGN(QuicSession); };
diff --git a/webrtc/p2p/quic/quicsession_unittest.cc b/webrtc/p2p/quic/quicsession_unittest.cc index 04b7d1e..eae0a2b 100644 --- a/webrtc/p2p/quic/quicsession_unittest.cc +++ b/webrtc/p2p/quic/quicsession_unittest.cc
@@ -10,6 +10,7 @@ #include "webrtc/p2p/quic/quicsession.h" +#include <memory> #include <string> #include <vector> @@ -117,7 +118,7 @@ const std::string& signature, const net::ProofVerifyContext* verify_context, std::string* error_details, - scoped_ptr<net::ProofVerifyDetails>* verify_details, + std::unique_ptr<net::ProofVerifyDetails>* verify_details, net::ProofVerifierCallback* callback) override { return success_ ? net::QUIC_SUCCESS : net::QUIC_FAILURE; } @@ -179,9 +180,9 @@ // Wrapper for QuicSession and transport channel that stores incoming data. class QuicSessionForTest : public QuicSession { public: - QuicSessionForTest(rtc::scoped_ptr<net::QuicConnection> connection, + QuicSessionForTest(std::unique_ptr<net::QuicConnection> connection, const net::QuicConfig& config, - rtc::scoped_ptr<FakeTransportChannel> channel) + std::unique_ptr<FakeTransportChannel> channel) : QuicSession(std::move(connection), config), channel_(std::move(channel)) { channel_->SignalReadPacket.connect( @@ -219,7 +220,7 @@ private: // Transports QUIC packets to/from peer. - rtc::scoped_ptr<FakeTransportChannel> channel_; + std::unique_ptr<FakeTransportChannel> channel_; // Stores data received by peer once it is sent from the other peer. std::string last_received_data_; // Handles incoming streams from sender. @@ -235,8 +236,8 @@ // Instantiates |client_peer_| and |server_peer_|. void CreateClientAndServerSessions(); - rtc::scoped_ptr<QuicSessionForTest> CreateSession( - rtc::scoped_ptr<FakeTransportChannel> channel, + std::unique_ptr<QuicSessionForTest> CreateSession( + std::unique_ptr<FakeTransportChannel> channel, Perspective perspective); QuicCryptoClientStream* CreateCryptoClientStream(QuicSessionForTest* session, @@ -244,7 +245,7 @@ QuicCryptoServerStream* CreateCryptoServerStream(QuicSessionForTest* session, bool handshake_success); - rtc::scoped_ptr<QuicConnection> CreateConnection( + std::unique_ptr<QuicConnection> CreateConnection( FakeTransportChannel* channel, Perspective perspective); @@ -268,16 +269,16 @@ QuicConfig config_; QuicClock clock_; - rtc::scoped_ptr<QuicSessionForTest> client_peer_; - rtc::scoped_ptr<QuicSessionForTest> server_peer_; + std::unique_ptr<QuicSessionForTest> client_peer_; + std::unique_ptr<QuicSessionForTest> server_peer_; }; // Initializes "client peer" who begins crypto handshake and "server peer" who // establishes encryption with client. void QuicSessionTest::CreateClientAndServerSessions() { - rtc::scoped_ptr<FakeTransportChannel> channel1( + std::unique_ptr<FakeTransportChannel> channel1( new FakeTransportChannel("channel1", 0)); - rtc::scoped_ptr<FakeTransportChannel> channel2( + std::unique_ptr<FakeTransportChannel> channel2( new FakeTransportChannel("channel2", 0)); // Prevent channel1->OnReadPacket and channel2->OnReadPacket from calling @@ -294,12 +295,12 @@ server_peer_ = CreateSession(std::move(channel2), Perspective::IS_SERVER); } -rtc::scoped_ptr<QuicSessionForTest> QuicSessionTest::CreateSession( - rtc::scoped_ptr<FakeTransportChannel> channel, +std::unique_ptr<QuicSessionForTest> QuicSessionTest::CreateSession( + std::unique_ptr<FakeTransportChannel> channel, Perspective perspective) { - rtc::scoped_ptr<QuicConnection> quic_connection = + std::unique_ptr<QuicConnection> quic_connection = CreateConnection(channel.get(), perspective); - return rtc::scoped_ptr<QuicSessionForTest>(new QuicSessionForTest( + return std::unique_ptr<QuicSessionForTest>(new QuicSessionForTest( std::move(quic_connection), config_, std::move(channel))); } @@ -326,7 +327,7 @@ return new QuicCryptoServerStream(server_config, session); } -rtc::scoped_ptr<QuicConnection> QuicSessionTest::CreateConnection( +std::unique_ptr<QuicConnection> QuicSessionTest::CreateConnection( FakeTransportChannel* channel, Perspective perspective) { FakeQuicPacketWriter* writer = new FakeQuicPacketWriter(channel); @@ -334,7 +335,7 @@ IPAddress ip(0, 0, 0, 0); bool owns_writer = true; - return rtc::scoped_ptr<QuicConnection>(new QuicConnection( + return std::unique_ptr<QuicConnection>(new QuicConnection( 0, net::IPEndPoint(ip, 0), &quic_helper_, writer, owns_writer, perspective, net::QuicSupportedVersions())); }
diff --git a/webrtc/p2p/quic/quictransportchannel.cc b/webrtc/p2p/quic/quictransportchannel.cc index 446fd42..5196ac0 100644 --- a/webrtc/p2p/quic/quictransportchannel.cc +++ b/webrtc/p2p/quic/quictransportchannel.cc
@@ -110,7 +110,7 @@ const std::string& signature, const net::ProofVerifyContext* verify_context, std::string* error_details, - scoped_ptr<net::ProofVerifyDetails>* verify_details, + std::unique_ptr<net::ProofVerifyDetails>* verify_details, net::ProofVerifierCallback* callback) override { LOG(LS_INFO) << "VerifyProof() ignoring credentials and returning success"; return net::QUIC_SUCCESS; @@ -435,7 +435,7 @@ ? net::Perspective::IS_CLIENT : net::Perspective::IS_SERVER; bool owns_writer = false; - rtc::scoped_ptr<net::QuicConnection> connection(new net::QuicConnection( + std::unique_ptr<net::QuicConnection> connection(new net::QuicConnection( kConnectionId, kConnectionIpEndpoint, &helper_, this, owns_writer, perspective, net::QuicSupportedVersions())); quic_.reset(new QuicSession(std::move(connection), config_));
diff --git a/webrtc/p2p/quic/quictransportchannel.h b/webrtc/p2p/quic/quictransportchannel.h index 49d786c..c9c253d 100644 --- a/webrtc/p2p/quic/quictransportchannel.h +++ b/webrtc/p2p/quic/quictransportchannel.h
@@ -11,6 +11,7 @@ #ifndef WEBRTC_P2P_QUIC_QUICTRANSPORTCHANNEL_H_ #define WEBRTC_P2P_QUIC_QUICTRANSPORTCHANNEL_H_ +#include <memory> #include <string> #include <vector> @@ -117,7 +118,7 @@ size_t result_len) override; // TODO(mikescarlett): Remove this method once TransportChannel does not // require defining it. - rtc::scoped_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate() + std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate() const override { return nullptr; } @@ -277,7 +278,7 @@ QuicTransportState quic_state_ = QUIC_TRANSPORT_NEW; // QUIC session which establishes the crypto handshake and converts data // to/from QUIC packets. - rtc::scoped_ptr<QuicSession> quic_; + std::unique_ptr<QuicSession> quic_; // Non-crypto config for |quic_|. net::QuicConfig config_; // Helper for net::QuicConnection that provides timing and @@ -288,9 +289,9 @@ // the handshake. This must be set before we start QUIC. rtc::Optional<rtc::SSLRole> ssl_role_; // Config for QUIC crypto client stream, used when |ssl_role_| is SSL_CLIENT. - rtc::scoped_ptr<net::QuicCryptoClientConfig> quic_crypto_client_config_; + std::unique_ptr<net::QuicCryptoClientConfig> quic_crypto_client_config_; // Config for QUIC crypto server stream, used when |ssl_role_| is SSL_SERVER. - rtc::scoped_ptr<net::QuicCryptoServerConfig> quic_crypto_server_config_; + std::unique_ptr<net::QuicCryptoServerConfig> quic_crypto_server_config_; // This peer's certificate. rtc::scoped_refptr<rtc::RTCCertificate> local_certificate_; // Fingerprint of the remote peer. This must be set before we start QUIC.
diff --git a/webrtc/p2p/quic/quictransportchannel_unittest.cc b/webrtc/p2p/quic/quictransportchannel_unittest.cc index c64aa40..45d3db8 100644 --- a/webrtc/p2p/quic/quictransportchannel_unittest.cc +++ b/webrtc/p2p/quic/quictransportchannel_unittest.cc
@@ -10,13 +10,13 @@ #include "webrtc/p2p/quic/quictransportchannel.h" +#include <memory> #include <set> #include <string> #include <vector> #include "webrtc/base/common.h" #include "webrtc/base/gunit.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/sslidentity.h" #include "webrtc/p2p/base/faketransportcontroller.h" @@ -103,7 +103,7 @@ quic_channel_.SignalClosed.connect(this, &QuicTestPeer::OnClosed); ice_channel_.SetAsync(true); rtc::scoped_refptr<rtc::RTCCertificate> local_cert = - rtc::RTCCertificate::Create(rtc::scoped_ptr<rtc::SSLIdentity>( + rtc::RTCCertificate::Create(std::unique_ptr<rtc::SSLIdentity>( rtc::SSLIdentity::Generate(name_, rtc::KT_DEFAULT))); quic_channel_.SetLocalCertificate(local_cert); local_fingerprint_.reset(CreateFingerprint(local_cert.get())); @@ -148,7 +148,7 @@ if (!get_digest_algorithm || digest_algorithm.empty()) { return nullptr; } - rtc::scoped_ptr<rtc::SSLFingerprint> fingerprint( + std::unique_ptr<rtc::SSLFingerprint> fingerprint( rtc::SSLFingerprint::Create(digest_algorithm, cert->identity())); if (digest_algorithm != rtc::DIGEST_SHA_256) { return nullptr; @@ -198,7 +198,7 @@ QuicTransportChannel* quic_channel() { return &quic_channel_; } - rtc::scoped_ptr<rtc::SSLFingerprint>& local_fingerprint() { + std::unique_ptr<rtc::SSLFingerprint>& local_fingerprint() { return local_fingerprint_; } @@ -228,7 +228,7 @@ size_t bytes_received_; // Bytes received by QUIC channel. FailableTransportChannel ice_channel_; // Simulates an ICE channel. QuicTransportChannel quic_channel_; // QUIC channel to test. - rtc::scoped_ptr<rtc::SSLFingerprint> local_fingerprint_; + std::unique_ptr<rtc::SSLFingerprint> local_fingerprint_; ReliableQuicStream* incoming_quic_stream_ = nullptr; bool signal_closed_emitted_ = false; }; @@ -258,9 +258,9 @@ peer1_.quic_channel()->SetSslRole(peer1_ssl_role); peer2_.quic_channel()->SetSslRole(peer2_ssl_role); - rtc::scoped_ptr<rtc::SSLFingerprint>& peer1_fingerprint = + std::unique_ptr<rtc::SSLFingerprint>& peer1_fingerprint = peer1_.local_fingerprint(); - rtc::scoped_ptr<rtc::SSLFingerprint>& peer2_fingerprint = + std::unique_ptr<rtc::SSLFingerprint>& peer2_fingerprint = peer2_.local_fingerprint(); peer1_.quic_channel()->SetRemoteFingerprint( @@ -464,7 +464,7 @@ // Set the SSL role, then test that GetSslRole returns the same value. TEST_F(QuicTransportChannelTest, SetGetSslRole) { ASSERT_TRUE(peer1_.quic_channel()->SetSslRole(rtc::SSL_SERVER)); - rtc::scoped_ptr<rtc::SSLRole> role(new rtc::SSLRole()); + std::unique_ptr<rtc::SSLRole> role(new rtc::SSLRole()); ASSERT_TRUE(peer1_.quic_channel()->GetSslRole(role.get())); EXPECT_EQ(rtc::SSL_SERVER, *role); }
diff --git a/webrtc/p2p/quic/reliablequicstream_unittest.cc b/webrtc/p2p/quic/reliablequicstream_unittest.cc index b887589..9f55c91 100644 --- a/webrtc/p2p/quic/reliablequicstream_unittest.cc +++ b/webrtc/p2p/quic/reliablequicstream_unittest.cc
@@ -10,6 +10,7 @@ #include "webrtc/p2p/quic/reliablequicstream.h" +#include <memory> #include <string> #include "net/base/ip_address_number.h" @@ -181,8 +182,8 @@ } protected: - rtc::scoped_ptr<ReliableQuicStream> stream_; - rtc::scoped_ptr<MockQuicSession> session_; + std::unique_ptr<ReliableQuicStream> stream_; + std::unique_ptr<MockQuicSession> session_; // Data written by the ReliableQuicStream. std::string write_buffer_;
diff --git a/webrtc/p2p/stunprober/main.cc b/webrtc/p2p/stunprober/main.cc index 9ef91e0..9d0fff8 100644 --- a/webrtc/p2p/stunprober/main.cc +++ b/webrtc/p2p/stunprober/main.cc
@@ -14,13 +14,14 @@ #include <iostream> #include <map> +#include <memory> + #include "webrtc/base/checks.h" #include "webrtc/base/flags.h" #include "webrtc/base/helpers.h" #include "webrtc/base/nethelpers.h" #include "webrtc/base/network.h" #include "webrtc/base/logging.h" -#include "webrtc/base/scoped_ptr.h" #include "webrtc/base/ssladapter.h" #include "webrtc/base/stringutils.h" #include "webrtc/base/thread.h" @@ -119,9 +120,9 @@ rtc::InitializeSSL(); rtc::InitRandom(rtc::Time32()); rtc::Thread* thread = rtc::ThreadManager::Instance()->WrapCurrentThread(); - rtc::scoped_ptr<rtc::BasicPacketSocketFactory> socket_factory( + std::unique_ptr<rtc::BasicPacketSocketFactory> socket_factory( new rtc::BasicPacketSocketFactory()); - rtc::scoped_ptr<rtc::BasicNetworkManager> network_manager( + std::unique_ptr<rtc::BasicNetworkManager> network_manager( new rtc::BasicNetworkManager()); rtc::NetworkManager::NetworkList networks; network_manager->GetNetworks(&networks);
diff --git a/webrtc/p2p/stunprober/stunprober.cc b/webrtc/p2p/stunprober/stunprober.cc index a54a843..41ec6b4 100644 --- a/webrtc/p2p/stunprober/stunprober.cc +++ b/webrtc/p2p/stunprober/stunprober.cc
@@ -9,6 +9,7 @@ */ #include <map> +#include <memory> #include <set> #include <string> @@ -90,11 +91,11 @@ StunProber* prober_; // The socket for this session. - rtc::scoped_ptr<rtc::AsyncPacketSocket> socket_; + std::unique_ptr<rtc::AsyncPacketSocket> socket_; // Temporary SocketAddress and buffer for RecvFrom. rtc::SocketAddress addr_; - rtc::scoped_ptr<rtc::ByteBufferWriter> response_packet_; + std::unique_ptr<rtc::ByteBufferWriter> response_packet_; std::vector<Request*> requests_; std::vector<rtc::SocketAddress> server_ips_; @@ -141,7 +142,7 @@ rtc::CreateRandomString(cricket::kStunTransactionIdLength)); message.SetType(cricket::STUN_BINDING_REQUEST); - rtc::scoped_ptr<rtc::ByteBufferWriter> request_packet( + std::unique_ptr<rtc::ByteBufferWriter> request_packet( new rtc::ByteBufferWriter(nullptr, kMaxUdpBufferSize)); if (!message.Write(request_packet.get())) { prober_->ReportOnFinished(WRITE_FAILED); @@ -345,7 +346,7 @@ // Prepare all the sockets beforehand. All of them will bind to "any" address. while (sockets_.size() < total_socket_required()) { - rtc::scoped_ptr<rtc::AsyncPacketSocket> socket( + std::unique_ptr<rtc::AsyncPacketSocket> socket( socket_factory_->CreateUdpSocket(rtc::SocketAddress(INADDR_ANY, 0), 0, 0)); if (!socket) {
diff --git a/webrtc/p2p/stunprober/stunprober_unittest.cc b/webrtc/p2p/stunprober/stunprober_unittest.cc index cdcc14a..f5ee4bf 100644 --- a/webrtc/p2p/stunprober/stunprober_unittest.cc +++ b/webrtc/p2p/stunprober/stunprober_unittest.cc
@@ -8,13 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include <memory> + #include "webrtc/base/asyncresolverinterface.h" #include "webrtc/base/basictypes.h" #include "webrtc/base/bind.h" #include "webrtc/base/checks.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/virtualsocketserver.h" #include "webrtc/p2p/base/basicpacketsocketfactory.h" @@ -83,7 +84,7 @@ rtc::NetworkManager::NetworkList networks; networks.push_back(&ipv4_network1); - rtc::scoped_ptr<rtc::BasicPacketSocketFactory> socket_factory( + std::unique_ptr<rtc::BasicPacketSocketFactory> socket_factory( new rtc::BasicPacketSocketFactory()); // Set up the expected results for verification. @@ -119,14 +120,14 @@ } rtc::Thread* main_; - 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<StunProber> prober; + std::unique_ptr<StunProber> prober; int result_ = 0; bool stopped_ = false; - rtc::scoped_ptr<cricket::TestStunServer> stun_server_1_; - rtc::scoped_ptr<cricket::TestStunServer> stun_server_2_; + std::unique_ptr<cricket::TestStunServer> stun_server_1_; + std::unique_ptr<cricket::TestStunServer> stun_server_2_; }; TEST_F(StunProberTest, NonSharedMode) {