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

Unified Diff: webrtc/p2p/stunprober/stunprober.cc

Issue 1162263012: Add SocketFactoryInterface::Prepare and fix how symmetric NAT is determined (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 6 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/stunprober/stunprober.h ('k') | webrtc/p2p/stunprober/stunprober_dependencies.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/stunprober/stunprober.cc
diff --git a/webrtc/p2p/stunprober/stunprober.cc b/webrtc/p2p/stunprober/stunprober.cc
index 938bb21e25f6954e57a939679bbf98a8b635fcc8..29939be95fa88f398b49534bd5dbb1eb3b830050 100644
--- a/webrtc/p2p/stunprober/stunprober.cc
+++ b/webrtc/p2p/stunprober/stunprober.cc
@@ -74,28 +74,11 @@ void StunProber::Requester::SendStunRequest() {
auto addr = server_ips_[num_request_sent_];
request.server_addr = addr.ipaddr();
- int rv = 0;
-
- // Only bind to the interface at the first request.
- if (num_request_sent_ == 0) {
- rtc::IPAddress local_addr;
- rv = prober_->GetLocalAddress(&local_addr);
- if (rv != 0) {
- prober_->End(GENERIC_FAILURE, rv);
- return;
- }
- rv = socket_->Bind(rtc::SocketAddress(local_addr, 0));
- if (rv < 0) {
- prober_->End(GENERIC_FAILURE, rv);
- return;
- }
- }
-
// The write must succeed immediately. Otherwise, the calculating of the STUN
// request timing could become too complicated. Callback is ignored by passing
// empty AsyncCallback.
- rv = socket_->SendTo(addr, const_cast<char*>(request_packet->Data()),
- request_packet->Length(), AsyncCallback());
+ int rv = socket_->SendTo(addr, const_cast<char*>(request_packet->Data()),
+ request_packet->Length(), AsyncCallback());
if (rv < 0) {
prober_->End(WRITE_FAILED, rv);
return;
@@ -279,7 +262,12 @@ void StunProber::OnServerResolved(int index, int result) {
return;
}
- MaybeScheduleStunRequests();
+ socket_factory_->Prepare(GetTotalClientSockets(), GetTotalServerSockets(),
+ [this](int result) {
+ if (result == 0) {
+ this->MaybeScheduleStunRequests();
+ }
+ });
}
int StunProber::GetLocalAddress(rtc::IPAddress* addr) {
@@ -440,6 +428,8 @@ bool StunProber::GetStats(StunProber::Stats* prob_stats) {
stats.num_request_sent = num_sent;
stats.num_response_received = num_received;
stats.target_request_interval_ns = interval_ms_ * 1000;
+ stats.symmetric_nat =
+ stats.srflx_addrs.size() > static_cast<size_t>(GetTotalServerSockets());
if (num_sent) {
stats.success_percent = static_cast<int>(100 * num_received / num_sent);
« no previous file with comments | « webrtc/p2p/stunprober/stunprober.h ('k') | webrtc/p2p/stunprober/stunprober_dependencies.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698