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

Side by Side Diff: webrtc/p2p/base/stun.h

Issue 2735523002: Make StunMessage::attrs_ a vector of unique_ptrs instead of a pointer to a vector of pointers. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/p2p/base/stun.cc » ('j') | webrtc/p2p/base/stun.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 class StunErrorCodeAttribute; 125 class StunErrorCodeAttribute;
126 class StunUInt16ListAttribute; 126 class StunUInt16ListAttribute;
127 127
128 // Records a complete STUN/TURN message. Each message consists of a type and 128 // Records a complete STUN/TURN message. Each message consists of a type and
129 // any number of attributes. Each attribute is parsed into an instance of an 129 // any number of attributes. Each attribute is parsed into an instance of an
130 // appropriate class (see above). The Get* methods will return instances of 130 // appropriate class (see above). The Get* methods will return instances of
131 // that attribute class. 131 // that attribute class.
132 class StunMessage { 132 class StunMessage {
133 public: 133 public:
134 StunMessage(); 134 StunMessage();
135 virtual ~StunMessage(); 135 virtual ~StunMessage() = default;
136 136
137 int type() const { return type_; } 137 int type() const { return type_; }
138 size_t length() const { return length_; } 138 size_t length() const { return length_; }
139 const std::string& transaction_id() const { return transaction_id_; } 139 const std::string& transaction_id() const { return transaction_id_; }
140 140
141 // Returns true if the message confirms to RFC3489 rather than 141 // Returns true if the message confirms to RFC3489 rather than
142 // RFC5389. The main difference between two version of the STUN 142 // RFC5389. The main difference between two version of the STUN
143 // protocol is the presence of the magic cookie and different length 143 // protocol is the presence of the magic cookie and different length
144 // of transaction ID. For outgoing packets version of the protocol 144 // of transaction ID. For outgoing packets version of the protocol
145 // is determined by the lengths of the transaction ID. 145 // is determined by the lengths of the transaction ID.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 virtual StunAttributeValueType GetAttributeValueType(int type) const; 192 virtual StunAttributeValueType GetAttributeValueType(int type) const;
193 193
194 private: 194 private:
195 StunAttribute* CreateAttribute(int type, size_t length) /* const*/; 195 StunAttribute* CreateAttribute(int type, size_t length) /* const*/;
196 const StunAttribute* GetAttribute(int type) const; 196 const StunAttribute* GetAttribute(int type) const;
197 static bool IsValidTransactionId(const std::string& transaction_id); 197 static bool IsValidTransactionId(const std::string& transaction_id);
198 198
199 uint16_t type_; 199 uint16_t type_;
200 uint16_t length_; 200 uint16_t length_;
201 std::string transaction_id_; 201 std::string transaction_id_;
202 std::vector<StunAttribute*>* attrs_; 202 std::vector<std::unique_ptr<StunAttribute>> attrs_;
203 }; 203 };
204 204
205 // Base class for all STUN/TURN attributes. 205 // Base class for all STUN/TURN attributes.
206 class StunAttribute { 206 class StunAttribute {
207 public: 207 public:
208 virtual ~StunAttribute() { 208 virtual ~StunAttribute() {
209 } 209 }
210 210
211 int type() const { return type_; } 211 int type() const { return type_; }
212 size_t length() const { return length_; } 212 size_t length() const { return length_; }
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 case STUN_ATTR_ICE_CONTROLLING: return STUN_VALUE_UINT64; 630 case STUN_ATTR_ICE_CONTROLLING: return STUN_VALUE_UINT64;
631 default: return StunMessage::GetAttributeValueType(type); 631 default: return StunMessage::GetAttributeValueType(type);
632 } 632 }
633 } 633 }
634 virtual StunMessage* CreateNew() const { return new IceMessage(); } 634 virtual StunMessage* CreateNew() const { return new IceMessage(); }
635 }; 635 };
636 636
637 } // namespace cricket 637 } // namespace cricket
638 638
639 #endif // WEBRTC_P2P_BASE_STUN_H_ 639 #endif // WEBRTC_P2P_BASE_STUN_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/stun.cc » ('j') | webrtc/p2p/base/stun.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698