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

Side by Side Diff: webrtc/p2p/stunprober/stunprober.cc

Issue 2881973002: Get tests working on systems that only support IPv6. (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 shared_socket_mode_ = shared_socket_mode; 273 shared_socket_mode_ = shared_socket_mode;
274 274
275 requests_per_ip_ = num_request_per_ip; 275 requests_per_ip_ = num_request_per_ip;
276 if (requests_per_ip_ == 0 || servers.size() == 0) { 276 if (requests_per_ip_ == 0 || servers.size() == 0) {
277 return false; 277 return false;
278 } 278 }
279 279
280 timeout_ms_ = timeout_ms; 280 timeout_ms_ = timeout_ms;
281 servers_ = servers; 281 servers_ = servers;
282 observer_ = observer; 282 observer_ = observer;
283 // Remove addresses that are already resolved.
284 for (auto it = servers_.begin(); it != servers_.end();) {
285 if (it->ipaddr().family() != AF_UNSPEC) {
286 all_servers_addrs_.push_back(*it);
287 it = servers_.erase(it);
288 } else {
289 ++it;
290 }
291 }
292 if (servers_.empty()) {
293 CreateSockets();
294 return true;
295 }
283 return ResolveServerName(servers_.back()); 296 return ResolveServerName(servers_.back());
284 } 297 }
285 298
286 bool StunProber::Start(StunProber::Observer* observer) { 299 bool StunProber::Start(StunProber::Observer* observer) {
287 observer_ = observer; 300 observer_ = observer;
288 if (total_ready_sockets_ != total_socket_required()) { 301 if (total_ready_sockets_ != total_socket_required()) {
289 return false; 302 return false;
290 } 303 }
291 MaybeScheduleStunRequests(); 304 MaybeScheduleStunRequests();
292 return true; 305 return true;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 ReportOnPrepared(RESOLVE_FAILED); 345 ReportOnPrepared(RESOLVE_FAILED);
333 } 346 }
334 return; 347 return;
335 } 348 }
336 349
337 if (all_servers_addrs_.size() == 0) { 350 if (all_servers_addrs_.size() == 0) {
338 ReportOnPrepared(RESOLVE_FAILED); 351 ReportOnPrepared(RESOLVE_FAILED);
339 return; 352 return;
340 } 353 }
341 354
355 CreateSockets();
356 }
357
358 void StunProber::CreateSockets() {
342 // Dedupe. 359 // Dedupe.
343 std::set<rtc::SocketAddress> addrs(all_servers_addrs_.begin(), 360 std::set<rtc::SocketAddress> addrs(all_servers_addrs_.begin(),
344 all_servers_addrs_.end()); 361 all_servers_addrs_.end());
345 all_servers_addrs_.assign(addrs.begin(), addrs.end()); 362 all_servers_addrs_.assign(addrs.begin(), addrs.end());
346 363
347 // Prepare all the sockets beforehand. All of them will bind to "any" address. 364 // Prepare all the sockets beforehand. All of them will bind to "any" address.
348 while (sockets_.size() < total_socket_required()) { 365 while (sockets_.size() < total_socket_required()) {
349 std::unique_ptr<rtc::AsyncPacketSocket> socket( 366 std::unique_ptr<rtc::AsyncPacketSocket> socket(
350 socket_factory_->CreateUdpSocket(rtc::SocketAddress(INADDR_ANY, 0), 0, 367 socket_factory_->CreateUdpSocket(rtc::SocketAddress(INADDR_ANY, 0), 0,
351 0)); 368 0));
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 581 }
565 } 582 }
566 583
567 void StunProber::ReportOnFinished(StunProber::Status status) { 584 void StunProber::ReportOnFinished(StunProber::Status status) {
568 if (observer_) { 585 if (observer_) {
569 observer_->OnFinished(this, status); 586 observer_->OnFinished(this, status);
570 } 587 }
571 } 588 }
572 589
573 } // namespace stunprober 590 } // namespace stunprober
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698