| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // request timing could become too complicated. Callback is ignored by passing | 155 // request timing could become too complicated. Callback is ignored by passing |
| 156 // empty AsyncCallback. | 156 // empty AsyncCallback. |
| 157 rtc::PacketOptions options; | 157 rtc::PacketOptions options; |
| 158 int rv = socket_->SendTo(const_cast<char*>(request_packet->Data()), | 158 int rv = socket_->SendTo(const_cast<char*>(request_packet->Data()), |
| 159 request_packet->Length(), addr, options); | 159 request_packet->Length(), addr, options); |
| 160 if (rv < 0) { | 160 if (rv < 0) { |
| 161 prober_->ReportOnFinished(WRITE_FAILED); | 161 prober_->ReportOnFinished(WRITE_FAILED); |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 | 164 |
| 165 request.sent_time_ms = rtc::Time64(); | 165 request.sent_time_ms = rtc::TimeMillis(); |
| 166 | 166 |
| 167 num_request_sent_++; | 167 num_request_sent_++; |
| 168 RTC_DCHECK(static_cast<size_t>(num_request_sent_) <= server_ips_.size()); | 168 RTC_DCHECK(static_cast<size_t>(num_request_sent_) <= server_ips_.size()); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void StunProber::Requester::Request::ProcessResponse(const char* buf, | 171 void StunProber::Requester::Request::ProcessResponse(const char* buf, |
| 172 size_t buf_len) { | 172 size_t buf_len) { |
| 173 int64_t now = rtc::Time64(); | 173 int64_t now = rtc::TimeMillis(); |
| 174 rtc::ByteBufferReader message(buf, buf_len); | 174 rtc::ByteBufferReader message(buf, buf_len); |
| 175 cricket::StunMessage stun_response; | 175 cricket::StunMessage stun_response; |
| 176 if (!stun_response.Read(&message)) { | 176 if (!stun_response.Read(&message)) { |
| 177 // Invalid or incomplete STUN packet. | 177 // Invalid or incomplete STUN packet. |
| 178 received_time_ms = 0; | 178 received_time_ms = 0; |
| 179 return; | 179 return; |
| 180 } | 180 } |
| 181 | 181 |
| 182 // Get external address of the socket. | 182 // Get external address of the socket. |
| 183 const cricket::StunAddressAttribute* addr_attr = | 183 const cricket::StunAddressAttribute* addr_attr = |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 int StunProber::get_wake_up_interval_ms() { | 406 int StunProber::get_wake_up_interval_ms() { |
| 407 if (interval_ms_ < THREAD_WAKE_UP_INTERVAL_MS) { | 407 if (interval_ms_ < THREAD_WAKE_UP_INTERVAL_MS) { |
| 408 return 1; | 408 return 1; |
| 409 } else { | 409 } else { |
| 410 return THREAD_WAKE_UP_INTERVAL_MS; | 410 return THREAD_WAKE_UP_INTERVAL_MS; |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 | 413 |
| 414 void StunProber::MaybeScheduleStunRequests() { | 414 void StunProber::MaybeScheduleStunRequests() { |
| 415 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 415 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 416 int64_t now = rtc::Time64(); | 416 int64_t now = rtc::TimeMillis(); |
| 417 | 417 |
| 418 if (Done()) { | 418 if (Done()) { |
| 419 invoker_.AsyncInvokeDelayed<void>( | 419 invoker_.AsyncInvokeDelayed<void>( |
| 420 thread_, rtc::Bind(&StunProber::ReportOnFinished, this, SUCCESS), | 420 thread_, rtc::Bind(&StunProber::ReportOnFinished, this, SUCCESS), |
| 421 timeout_ms_); | 421 timeout_ms_); |
| 422 return; | 422 return; |
| 423 } | 423 } |
| 424 if (should_send_next_request(now)) { | 424 if (should_send_next_request(now)) { |
| 425 if (!SendNextRequest()) { | 425 if (!SendNextRequest()) { |
| 426 ReportOnFinished(GENERIC_FAILURE); | 426 ReportOnFinished(GENERIC_FAILURE); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 | 564 |
| 565 void StunProber::ReportOnFinished(StunProber::Status status) { | 565 void StunProber::ReportOnFinished(StunProber::Status status) { |
| 566 if (observer_) { | 566 if (observer_) { |
| 567 observer_->OnFinished(this, status); | 567 observer_->OnFinished(this, status); |
| 568 } | 568 } |
| 569 } | 569 } |
| 570 | 570 |
| 571 } // namespace stunprober | 571 } // namespace stunprober |
| OLD | NEW |