Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: webrtc/p2p/base/relayport.cc

Issue 2757893003: Add MakeUnique from chromium and change StunMessage::AddAttribute to take a unique_ptr. (Closed)
Patch Set: Better fix to undefined reference to MIN_SIZE error. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/relayport.cc
diff --git a/webrtc/p2p/base/relayport.cc b/webrtc/p2p/base/relayport.cc
index 3d56c4acb437f09fa075e8047740f69314a8af3b..1431b93c632ef7daf557925def3a086706b0e51b 100644
--- a/webrtc/p2p/base/relayport.cc
+++ b/webrtc/p2p/base/relayport.cc
@@ -568,36 +568,32 @@ int RelayEntry::SendTo(const void* data, size_t size,
RelayMessage request;
request.SetType(STUN_SEND_REQUEST);
- StunByteStringAttribute* magic_cookie_attr =
+ auto magic_cookie_attr =
StunAttribute::CreateByteString(STUN_ATTR_MAGIC_COOKIE);
magic_cookie_attr->CopyBytes(TURN_MAGIC_COOKIE_VALUE,
sizeof(TURN_MAGIC_COOKIE_VALUE));
- request.AddAttribute(magic_cookie_attr);
+ request.AddAttribute(std::move(magic_cookie_attr));
- StunByteStringAttribute* username_attr =
- StunAttribute::CreateByteString(STUN_ATTR_USERNAME);
+ auto username_attr = StunAttribute::CreateByteString(STUN_ATTR_USERNAME);
username_attr->CopyBytes(port_->username_fragment().c_str(),
port_->username_fragment().size());
- request.AddAttribute(username_attr);
+ request.AddAttribute(std::move(username_attr));
- StunAddressAttribute* addr_attr =
- StunAttribute::CreateAddress(STUN_ATTR_DESTINATION_ADDRESS);
+ auto addr_attr = StunAttribute::CreateAddress(STUN_ATTR_DESTINATION_ADDRESS);
addr_attr->SetIP(addr.ipaddr());
addr_attr->SetPort(addr.port());
- request.AddAttribute(addr_attr);
+ request.AddAttribute(std::move(addr_attr));
// Attempt to lock
if (ext_addr_ == addr) {
- StunUInt32Attribute* options_attr =
- StunAttribute::CreateUInt32(STUN_ATTR_OPTIONS);
+ auto options_attr = StunAttribute::CreateUInt32(STUN_ATTR_OPTIONS);
options_attr->SetValue(0x1);
- request.AddAttribute(options_attr);
+ request.AddAttribute(std::move(options_attr));
}
- StunByteStringAttribute* data_attr =
- StunAttribute::CreateByteString(STUN_ATTR_DATA);
+ auto data_attr = StunAttribute::CreateByteString(STUN_ATTR_DATA);
data_attr->CopyBytes(data, size);
- request.AddAttribute(data_attr);
+ request.AddAttribute(std::move(data_attr));
// TODO: compute the HMAC.
@@ -779,12 +775,11 @@ AllocateRequest::AllocateRequest(RelayEntry* entry,
void AllocateRequest::Prepare(StunMessage* request) {
request->SetType(STUN_ALLOCATE_REQUEST);
- StunByteStringAttribute* username_attr =
- StunAttribute::CreateByteString(STUN_ATTR_USERNAME);
+ auto username_attr = StunAttribute::CreateByteString(STUN_ATTR_USERNAME);
username_attr->CopyBytes(
entry_->port()->username_fragment().c_str(),
entry_->port()->username_fragment().size());
- request->AddAttribute(username_attr);
+ request->AddAttribute(std::move(username_attr));
}
void AllocateRequest::OnSent() {

Powered by Google App Engine
This is Rietveld 408576698