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 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 int StunRequest::type() { | 185 int StunRequest::type() { |
186 ASSERT(msg_ != NULL); | 186 ASSERT(msg_ != NULL); |
187 return msg_->type(); | 187 return msg_->type(); |
188 } | 188 } |
189 | 189 |
190 const StunMessage* StunRequest::msg() const { | 190 const StunMessage* StunRequest::msg() const { |
191 return msg_; | 191 return msg_; |
192 } | 192 } |
193 | 193 |
194 int StunRequest::Elapsed() const { | 194 int StunRequest::Elapsed() const { |
195 return static_cast<int>(rtc::Time64() - tstamp_); | 195 return static_cast<int>(rtc::TimeMillis() - tstamp_); |
196 } | 196 } |
197 | 197 |
198 | 198 |
199 void StunRequest::set_manager(StunRequestManager* manager) { | 199 void StunRequest::set_manager(StunRequestManager* manager) { |
200 ASSERT(!manager_); | 200 ASSERT(!manager_); |
201 manager_ = manager; | 201 manager_ = manager; |
202 } | 202 } |
203 | 203 |
204 void StunRequest::OnMessage(rtc::Message* pmsg) { | 204 void StunRequest::OnMessage(rtc::Message* pmsg) { |
205 ASSERT(manager_ != NULL); | 205 ASSERT(manager_ != NULL); |
206 ASSERT(pmsg->message_id == MSG_STUN_SEND); | 206 ASSERT(pmsg->message_id == MSG_STUN_SEND); |
207 | 207 |
208 if (timeout_) { | 208 if (timeout_) { |
209 OnTimeout(); | 209 OnTimeout(); |
210 delete this; | 210 delete this; |
211 return; | 211 return; |
212 } | 212 } |
213 | 213 |
214 tstamp_ = rtc::Time64(); | 214 tstamp_ = rtc::TimeMillis(); |
215 | 215 |
216 rtc::ByteBufferWriter buf; | 216 rtc::ByteBufferWriter buf; |
217 msg_->Write(&buf); | 217 msg_->Write(&buf); |
218 manager_->SignalSendPacket(buf.Data(), buf.Length(), this); | 218 manager_->SignalSendPacket(buf.Data(), buf.Length(), this); |
219 | 219 |
220 OnSent(); | 220 OnSent(); |
221 manager_->thread_->PostDelayed(resend_delay(), this, MSG_STUN_SEND, NULL); | 221 manager_->thread_->PostDelayed(resend_delay(), this, MSG_STUN_SEND, NULL); |
222 } | 222 } |
223 | 223 |
224 void StunRequest::OnSent() { | 224 void StunRequest::OnSent() { |
225 count_ += 1; | 225 count_ += 1; |
226 if (count_ == MAX_SENDS) | 226 if (count_ == MAX_SENDS) |
227 timeout_ = true; | 227 timeout_ = true; |
228 } | 228 } |
229 | 229 |
230 int StunRequest::resend_delay() { | 230 int StunRequest::resend_delay() { |
231 if (count_ == 0) { | 231 if (count_ == 0) { |
232 return 0; | 232 return 0; |
233 } | 233 } |
234 return DELAY_UNIT * std::min(1 << (count_-1), DELAY_MAX_FACTOR); | 234 return DELAY_UNIT * std::min(1 << (count_-1), DELAY_MAX_FACTOR); |
235 } | 235 } |
236 | 236 |
237 } // namespace cricket | 237 } // namespace cricket |
OLD | NEW |