OLD | NEW |
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 |
11 #include "webrtc/p2p/base/stunrequest.h" | 11 #include "webrtc/p2p/base/stunrequest.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <memory> |
| 15 |
14 #include "webrtc/base/common.h" | 16 #include "webrtc/base/common.h" |
15 #include "webrtc/base/helpers.h" | 17 #include "webrtc/base/helpers.h" |
16 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
17 #include "webrtc/base/stringencode.h" | 19 #include "webrtc/base/stringencode.h" |
18 | 20 |
19 namespace cricket { | 21 namespace cricket { |
20 | 22 |
21 const uint32_t MSG_STUN_SEND = 1; | 23 const uint32_t MSG_STUN_SEND = 1; |
22 | 24 |
23 const int MAX_SENDS = 9; | 25 const int MAX_SENDS = 9; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 RequestMap::iterator iter = requests_.find(id); | 134 RequestMap::iterator iter = requests_.find(id); |
133 if (iter == requests_.end()) { | 135 if (iter == requests_.end()) { |
134 // TODO(pthatcher): Log unknown responses without being too spammy | 136 // TODO(pthatcher): Log unknown responses without being too spammy |
135 // in the logs. | 137 // in the logs. |
136 return false; | 138 return false; |
137 } | 139 } |
138 | 140 |
139 // Parse the STUN message and continue processing as usual. | 141 // Parse the STUN message and continue processing as usual. |
140 | 142 |
141 rtc::ByteBufferReader buf(data, size); | 143 rtc::ByteBufferReader buf(data, size); |
142 rtc::scoped_ptr<StunMessage> response(iter->second->msg_->CreateNew()); | 144 std::unique_ptr<StunMessage> response(iter->second->msg_->CreateNew()); |
143 if (!response->Read(&buf)) { | 145 if (!response->Read(&buf)) { |
144 LOG(LS_WARNING) << "Failed to read STUN response " << rtc::hex_encode(id); | 146 LOG(LS_WARNING) << "Failed to read STUN response " << rtc::hex_encode(id); |
145 return false; | 147 return false; |
146 } | 148 } |
147 | 149 |
148 return CheckResponse(response.get()); | 150 return CheckResponse(response.get()); |
149 } | 151 } |
150 | 152 |
151 StunRequest::StunRequest() | 153 StunRequest::StunRequest() |
152 : count_(0), timeout_(false), manager_(0), | 154 : count_(0), timeout_(false), manager_(0), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 230 } |
229 | 231 |
230 int StunRequest::resend_delay() { | 232 int StunRequest::resend_delay() { |
231 if (count_ == 0) { | 233 if (count_ == 0) { |
232 return 0; | 234 return 0; |
233 } | 235 } |
234 return DELAY_UNIT * std::min(1 << (count_-1), DELAY_MAX_FACTOR); | 236 return DELAY_UNIT * std::min(1 << (count_-1), DELAY_MAX_FACTOR); |
235 } | 237 } |
236 | 238 |
237 } // namespace cricket | 239 } // namespace cricket |
OLD | NEW |