Index: webrtc/p2p/base/turnport.cc |
diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc |
index 62b7450982e32d277772db98e7643824327963a4..90151692215e23d773524600dc0cfb1141576a6e 100644 |
--- a/webrtc/p2p/base/turnport.cc |
+++ b/webrtc/p2p/base/turnport.cc |
@@ -12,15 +12,16 @@ |
#include <functional> |
-#include "webrtc/p2p/base/common.h" |
-#include "webrtc/p2p/base/stun.h" |
#include "webrtc/base/asyncpacketsocket.h" |
#include "webrtc/base/byteorder.h" |
#include "webrtc/base/checks.h" |
#include "webrtc/base/logging.h" |
#include "webrtc/base/nethelpers.h" |
+#include "webrtc/base/ptr_util.h" |
#include "webrtc/base/socketaddress.h" |
#include "webrtc/base/stringencode.h" |
+#include "webrtc/p2p/base/common.h" |
+#include "webrtc/p2p/base/stun.h" |
namespace cricket { |
@@ -928,12 +929,12 @@ void TurnPort::SendRequest(StunRequest* req, int delay) { |
void TurnPort::AddRequestAuthInfo(StunMessage* msg) { |
// If we've gotten the necessary data from the server, add it to our request. |
RTC_DCHECK(!hash_.empty()); |
- msg->AddAttribute(new StunByteStringAttribute( |
+ msg->AddAttribute(rtc::MakeUnique<StunByteStringAttribute>( |
STUN_ATTR_USERNAME, credentials_.username)); |
- msg->AddAttribute(new StunByteStringAttribute( |
- STUN_ATTR_REALM, realm_)); |
- msg->AddAttribute(new StunByteStringAttribute( |
- STUN_ATTR_NONCE, nonce_)); |
+ msg->AddAttribute( |
+ rtc::MakeUnique<StunByteStringAttribute>(STUN_ATTR_REALM, realm_)); |
+ msg->AddAttribute( |
+ rtc::MakeUnique<StunByteStringAttribute>(STUN_ATTR_NONCE, nonce_)); |
const bool success = msg->AddMessageIntegrity(hash()); |
RTC_DCHECK(success); |
} |
@@ -1109,10 +1110,10 @@ TurnAllocateRequest::TurnAllocateRequest(TurnPort* port) |
void TurnAllocateRequest::Prepare(StunMessage* request) { |
// Create the request as indicated in RFC 5766, Section 6.1. |
request->SetType(TURN_ALLOCATE_REQUEST); |
- StunUInt32Attribute* transport_attr = StunAttribute::CreateUInt32( |
- STUN_ATTR_REQUESTED_TRANSPORT); |
+ auto transport_attr = |
+ StunAttribute::CreateUInt32(STUN_ATTR_REQUESTED_TRANSPORT); |
transport_attr->SetValue(IPPROTO_UDP << 24); |
- request->AddAttribute(transport_attr); |
+ request->AddAttribute(std::move(transport_attr)); |
if (!port_->hash().empty()) { |
port_->AddRequestAuthInfo(request); |
} |
@@ -1286,8 +1287,8 @@ void TurnRefreshRequest::Prepare(StunMessage* request) { |
// No attributes need to be included. |
request->SetType(TURN_REFRESH_REQUEST); |
if (lifetime_ > -1) { |
- request->AddAttribute(new StunUInt32Attribute( |
- STUN_ATTR_LIFETIME, lifetime_)); |
+ request->AddAttribute( |
+ rtc::MakeUnique<StunUInt32Attribute>(STUN_ATTR_LIFETIME, lifetime_)); |
} |
port_->AddRequestAuthInfo(request); |
@@ -1356,7 +1357,7 @@ TurnCreatePermissionRequest::TurnCreatePermissionRequest( |
void TurnCreatePermissionRequest::Prepare(StunMessage* request) { |
// Create the request as indicated in RFC5766, Section 9.1. |
request->SetType(TURN_CREATE_PERMISSION_REQUEST); |
- request->AddAttribute(new StunXorAddressAttribute( |
+ request->AddAttribute(rtc::MakeUnique<StunXorAddressAttribute>( |
STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_)); |
port_->AddRequestAuthInfo(request); |
} |
@@ -1417,9 +1418,9 @@ TurnChannelBindRequest::TurnChannelBindRequest( |
void TurnChannelBindRequest::Prepare(StunMessage* request) { |
// Create the request as indicated in RFC5766, Section 11.1. |
request->SetType(TURN_CHANNEL_BIND_REQUEST); |
- request->AddAttribute(new StunUInt32Attribute( |
+ request->AddAttribute(rtc::MakeUnique<StunUInt32Attribute>( |
STUN_ATTR_CHANNEL_NUMBER, channel_id_ << 16)); |
- request->AddAttribute(new StunXorAddressAttribute( |
+ request->AddAttribute(rtc::MakeUnique<StunXorAddressAttribute>( |
STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_)); |
port_->AddRequestAuthInfo(request); |
} |
@@ -1501,10 +1502,10 @@ int TurnEntry::Send(const void* data, size_t size, bool payload, |
msg.SetType(TURN_SEND_INDICATION); |
msg.SetTransactionID( |
rtc::CreateRandomString(kStunTransactionIdLength)); |
- msg.AddAttribute(new StunXorAddressAttribute( |
+ msg.AddAttribute(rtc::MakeUnique<StunXorAddressAttribute>( |
STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_)); |
- msg.AddAttribute(new StunByteStringAttribute( |
- STUN_ATTR_DATA, data, size)); |
+ msg.AddAttribute( |
+ rtc::MakeUnique<StunByteStringAttribute>(STUN_ATTR_DATA, data, size)); |
const bool success = msg.Write(&buf); |
RTC_DCHECK(success); |