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

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: add ptr_util.h to rtc_base_approved build target 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
« no previous file with comments | « webrtc/p2p/base/port_unittest.cc ('k') | webrtc/p2p/base/relayserver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/relayport.cc
diff --git a/webrtc/p2p/base/relayport.cc b/webrtc/p2p/base/relayport.cc
index 2ab71dc3e4e5664bb47a04a81f5d79494d4da3c5..5eacf6d708e451f1d57452a8a0b4956a1639bc3d 100644
--- a/webrtc/p2p/base/relayport.cc
+++ b/webrtc/p2p/base/relayport.cc
@@ -576,36 +576,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.
@@ -787,12 +783,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() {
« no previous file with comments | « webrtc/p2p/base/port_unittest.cc ('k') | webrtc/p2p/base/relayserver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698