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

Unified Diff: webrtc/p2p/base/stun.h

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/relayserver_unittest.cc ('k') | webrtc/p2p/base/stun.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/stun.h
diff --git a/webrtc/p2p/base/stun.h b/webrtc/p2p/base/stun.h
index 532fe5bec9e947f127972bc2f4f27c0b4ca3563d..ab200687f5ba4d8855730ade4dde2786c0354124 100644
--- a/webrtc/p2p/base/stun.h
+++ b/webrtc/p2p/base/stun.h
@@ -159,8 +159,7 @@ class StunMessage {
const StunUInt16ListAttribute* GetUnknownAttributes() const;
// Takes ownership of the specified attribute and adds it to the message.
- // TODO(zstein): Take a unique_ptr instead of a raw pointer.
- void AddAttribute(StunAttribute* attr);
+ void AddAttribute(std::unique_ptr<StunAttribute> attr);
// Validates that a raw STUN message has a correct MESSAGE-INTEGRITY value.
// This can't currently be done on a StunMessage, since it is affected by
@@ -233,13 +232,15 @@ class StunAttribute {
StunMessage* owner);
// TODO: Allow these create functions to take parameters, to reduce
// the amount of work callers need to do to initialize attributes.
- static StunAddressAttribute* CreateAddress(uint16_t type);
- static StunXorAddressAttribute* CreateXorAddress(uint16_t type);
- static StunUInt32Attribute* CreateUInt32(uint16_t type);
- static StunUInt64Attribute* CreateUInt64(uint16_t type);
- static StunByteStringAttribute* CreateByteString(uint16_t type);
- static StunErrorCodeAttribute* CreateErrorCode();
- static StunUInt16ListAttribute* CreateUnknownAttributes();
+ static std::unique_ptr<StunAddressAttribute> CreateAddress(uint16_t type);
+ static std::unique_ptr<StunXorAddressAttribute> CreateXorAddress(
+ uint16_t type);
+ static std::unique_ptr<StunUInt32Attribute> CreateUInt32(uint16_t type);
+ static std::unique_ptr<StunUInt64Attribute> CreateUInt64(uint16_t type);
+ static std::unique_ptr<StunByteStringAttribute> CreateByteString(
+ uint16_t type);
+ static std::unique_ptr<StunErrorCodeAttribute> CreateErrorCode();
+ static std::unique_ptr<StunUInt16ListAttribute> CreateUnknownAttributes();
protected:
StunAttribute(uint16_t type, uint16_t length);
@@ -412,7 +413,7 @@ class StunByteStringAttribute : public StunAttribute {
// Implements STUN attributes that record an error code.
class StunErrorCodeAttribute : public StunAttribute {
public:
- static const uint16_t MIN_SIZE = 4;
+ static const uint16_t MIN_SIZE;
StunErrorCodeAttribute(uint16_t type, int code, const std::string& reason);
StunErrorCodeAttribute(uint16_t type, uint16_t length);
~StunErrorCodeAttribute();
« no previous file with comments | « webrtc/p2p/base/relayserver_unittest.cc ('k') | webrtc/p2p/base/stun.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698