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

Side by Side Diff: webrtc/p2p/base/transportcontroller.cc

Issue 2571683004: Fixing possible crash due to RefCountedChannel assignment operator. (Closed)
Patch Set: Use RefCountedObject instead of custom class. Created 4 years 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
« no previous file with comments | « webrtc/p2p/base/transportcontroller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "webrtc/p2p/base/transportcontroller.h" 11 #include "webrtc/p2p/base/transportcontroller.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <memory> 14 #include <memory>
15 15
16 #include "webrtc/base/bind.h" 16 #include "webrtc/base/bind.h"
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/thread.h" 18 #include "webrtc/base/thread.h"
19 #include "webrtc/p2p/base/port.h" 19 #include "webrtc/p2p/base/port.h"
20 20
21 namespace cricket { 21 namespace {
22 22
23 enum { 23 enum {
24 MSG_ICECONNECTIONSTATE, 24 MSG_ICECONNECTIONSTATE,
25 MSG_RECEIVING, 25 MSG_RECEIVING,
26 MSG_ICEGATHERINGSTATE, 26 MSG_ICEGATHERINGSTATE,
27 MSG_CANDIDATESGATHERED, 27 MSG_CANDIDATESGATHERED,
28 }; 28 };
29 29
30 struct CandidatesData : public rtc::MessageData { 30 struct CandidatesData : public rtc::MessageData {
31 CandidatesData(const std::string& transport_name, 31 CandidatesData(const std::string& transport_name,
32 const Candidates& candidates) 32 const cricket::Candidates& candidates)
33 : transport_name(transport_name), candidates(candidates) {} 33 : transport_name(transport_name), candidates(candidates) {}
34 34
35 std::string transport_name; 35 std::string transport_name;
36 Candidates candidates; 36 cricket::Candidates candidates;
37 };
38
39 } // namespace {
40
41 namespace cricket {
42
43 // This class groups the DTLS and ICE channels, and helps keep track of
44 // how many external objects (BaseChannels) reference each channel.
45 class TransportController::ChannelPair {
46 public:
47 // TODO(deadbeef): Change the types of |dtls| and |ice| to
48 // DtlsTransportChannelWrapper and P2PTransportChannelWrapper,
49 // once TransportChannelImpl is removed.
50 ChannelPair(TransportChannelImpl* dtls, TransportChannelImpl* ice)
51 : ice_(ice), dtls_(dtls) {}
52
53 // Currently, all ICE-related calls still go through this DTLS channel. But
54 // that will change once we get rid of TransportChannelImpl, and the DTLS
55 // channel interface no longer includes ICE-specific methods.
56 const TransportChannelImpl* dtls() const { return dtls_.get(); }
57 TransportChannelImpl* dtls() { return dtls_.get(); }
58 const TransportChannelImpl* ice() const { return ice_.get(); }
59 TransportChannelImpl* ice() { return ice_.get(); }
60
61 private:
62 std::unique_ptr<TransportChannelImpl> ice_;
63 std::unique_ptr<TransportChannelImpl> dtls_;
64
65 RTC_DISALLOW_COPY_AND_ASSIGN(ChannelPair);
37 }; 66 };
38 67
39 TransportController::TransportController(rtc::Thread* signaling_thread, 68 TransportController::TransportController(rtc::Thread* signaling_thread,
40 rtc::Thread* network_thread, 69 rtc::Thread* network_thread,
41 PortAllocator* port_allocator, 70 PortAllocator* port_allocator,
42 bool redetermine_role_on_ice_restart) 71 bool redetermine_role_on_ice_restart)
43 : signaling_thread_(signaling_thread), 72 : signaling_thread_(signaling_thread),
44 network_thread_(network_thread), 73 network_thread_(network_thread),
45 port_allocator_(port_allocator), 74 port_allocator_(port_allocator),
46 redetermine_role_on_ice_restart_(redetermine_role_on_ice_restart) {} 75 redetermine_role_on_ice_restart_(redetermine_role_on_ice_restart) {}
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 dtls->SignalCandidateGathered.connect( 247 dtls->SignalCandidateGathered.connect(
219 this, &TransportController::OnChannelCandidateGathered_n); 248 this, &TransportController::OnChannelCandidateGathered_n);
220 dtls->SignalCandidatesRemoved.connect( 249 dtls->SignalCandidatesRemoved.connect(
221 this, &TransportController::OnChannelCandidatesRemoved_n); 250 this, &TransportController::OnChannelCandidatesRemoved_n);
222 dtls->SignalRoleConflict.connect( 251 dtls->SignalRoleConflict.connect(
223 this, &TransportController::OnChannelRoleConflict_n); 252 this, &TransportController::OnChannelRoleConflict_n);
224 dtls->SignalStateChanged.connect( 253 dtls->SignalStateChanged.connect(
225 this, &TransportController::OnChannelStateChanged_n); 254 this, &TransportController::OnChannelStateChanged_n);
226 dtls->SignalDtlsHandshakeError.connect( 255 dtls->SignalDtlsHandshakeError.connect(
227 this, &TransportController::OnDtlsHandshakeError); 256 this, &TransportController::OnDtlsHandshakeError);
228 channels_.insert(channels_.end(), RefCountedChannel(dtls, ice))->AddRef(); 257 RefCountedChannel* new_pair = new RefCountedChannel(dtls, ice);
258 new_pair->AddRef();
259 channels_.insert(channels_.end(), new_pair);
229 bool channel_added = transport->AddChannel(dtls, component); 260 bool channel_added = transport->AddChannel(dtls, component);
230 RTC_DCHECK(channel_added); 261 RTC_DCHECK(channel_added);
231 // Adding a channel could cause aggregate state to change. 262 // Adding a channel could cause aggregate state to change.
232 UpdateAggregateStates_n(); 263 UpdateAggregateStates_n();
233 return dtls; 264 return dtls;
234 } 265 }
235 266
236 void TransportController::DestroyTransportChannel_n( 267 void TransportController::DestroyTransportChannel_n(
237 const std::string& transport_name, 268 const std::string& transport_name,
238 int component) { 269 int component) {
239 RTC_DCHECK(network_thread_->IsCurrent()); 270 RTC_DCHECK(network_thread_->IsCurrent());
240 271
241 auto it = GetChannelIterator_n(transport_name, component); 272 auto it = GetChannelIterator_n(transport_name, component);
242 if (it == channels_.end()) { 273 if (it == channels_.end()) {
243 LOG(LS_WARNING) << "Attempting to delete " << transport_name 274 LOG(LS_WARNING) << "Attempting to delete " << transport_name
244 << " TransportChannel " << component 275 << " TransportChannel " << component
245 << ", which doesn't exist."; 276 << ", which doesn't exist.";
246 return; 277 return;
247 } 278 }
248 it->DecRef(); 279 if ((*it)->Release() > 0) {
249 if (it->ref() > 0) {
250 return; 280 return;
251 } 281 }
252 channels_.erase(it); 282 channels_.erase(it);
253 283
254 JsepTransport* t = GetJsepTransport_n(transport_name); 284 JsepTransport* t = GetJsepTransport_n(transport_name);
255 bool channel_removed = t->RemoveChannel(component); 285 bool channel_removed = t->RemoveChannel(component);
256 RTC_DCHECK(channel_removed); 286 RTC_DCHECK(channel_removed);
257 // Just as we create a Transport when its first channel is created, 287 // Just as we create a Transport when its first channel is created,
258 // we delete it when its last channel is deleted. 288 // we delete it when its last channel is deleted.
259 if (!t->HasChannels()) { 289 if (!t->HasChannels()) {
260 transports_.erase(transport_name); 290 transports_.erase(transport_name);
261 } 291 }
262 292
263 // Removing a channel could cause aggregate state to change. 293 // Removing a channel could cause aggregate state to change.
264 UpdateAggregateStates_n(); 294 UpdateAggregateStates_n();
265 } 295 }
266 296
267 std::vector<std::string> TransportController::transport_names_for_testing() { 297 std::vector<std::string> TransportController::transport_names_for_testing() {
268 std::vector<std::string> ret; 298 std::vector<std::string> ret;
269 for (const auto& kv : transports_) { 299 for (const auto& kv : transports_) {
270 ret.push_back(kv.first); 300 ret.push_back(kv.first);
271 } 301 }
272 return ret; 302 return ret;
273 } 303 }
274 304
275 std::vector<TransportChannelImpl*> TransportController::channels_for_testing() { 305 std::vector<TransportChannelImpl*> TransportController::channels_for_testing() {
276 std::vector<TransportChannelImpl*> ret; 306 std::vector<TransportChannelImpl*> ret;
277 for (RefCountedChannel& channel : channels_) { 307 for (RefCountedChannel* channel : channels_) {
278 ret.push_back(channel.dtls()); 308 ret.push_back(channel->dtls());
279 } 309 }
280 return ret; 310 return ret;
281 } 311 }
282 312
283 TransportChannelImpl* TransportController::get_channel_for_testing( 313 TransportChannelImpl* TransportController::get_channel_for_testing(
284 const std::string& transport_name, 314 const std::string& transport_name,
285 int component) { 315 int component) {
286 RefCountedChannel* ch = GetChannel_n(transport_name, component); 316 RefCountedChannel* ch = GetChannel_n(transport_name, component);
287 return ch ? ch->dtls() : nullptr; 317 return ch ? ch->dtls() : nullptr;
288 } 318 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 CandidatesData* data = static_cast<CandidatesData*>(pmsg->pdata); 361 CandidatesData* data = static_cast<CandidatesData*>(pmsg->pdata);
332 SignalCandidatesGathered(data->transport_name, data->candidates); 362 SignalCandidatesGathered(data->transport_name, data->candidates);
333 delete data; 363 delete data;
334 break; 364 break;
335 } 365 }
336 default: 366 default:
337 ASSERT(false); 367 ASSERT(false);
338 } 368 }
339 } 369 }
340 370
341 std::vector<TransportController::RefCountedChannel>::iterator 371 std::vector<TransportController::RefCountedChannel*>::iterator
342 TransportController::GetChannelIterator_n(const std::string& transport_name, 372 TransportController::GetChannelIterator_n(const std::string& transport_name,
343 int component) { 373 int component) {
344 RTC_DCHECK(network_thread_->IsCurrent()); 374 RTC_DCHECK(network_thread_->IsCurrent());
345 return std::find_if( 375 return std::find_if(channels_.begin(), channels_.end(),
346 channels_.begin(), channels_.end(), 376 [transport_name, component](RefCountedChannel* channel) {
347 [transport_name, component](const RefCountedChannel& channel) { 377 return channel->dtls()->transport_name() ==
348 return channel.dtls()->transport_name() == transport_name && 378 transport_name &&
349 channel.dtls()->component() == component; 379 channel->dtls()->component() == component;
350 }); 380 });
351 } 381 }
352 382
353 std::vector<TransportController::RefCountedChannel>::const_iterator 383 std::vector<TransportController::RefCountedChannel*>::const_iterator
354 TransportController::GetChannelIterator_n(const std::string& transport_name, 384 TransportController::GetChannelIterator_n(const std::string& transport_name,
355 int component) const { 385 int component) const {
356 RTC_DCHECK(network_thread_->IsCurrent()); 386 RTC_DCHECK(network_thread_->IsCurrent());
357 return std::find_if( 387 return std::find_if(
358 channels_.begin(), channels_.end(), 388 channels_.begin(), channels_.end(),
359 [transport_name, component](const RefCountedChannel& channel) { 389 [transport_name, component](const RefCountedChannel* channel) {
360 return channel.dtls()->transport_name() == transport_name && 390 return channel->dtls()->transport_name() == transport_name &&
361 channel.dtls()->component() == component; 391 channel->dtls()->component() == component;
362 }); 392 });
363 } 393 }
364 394
365 const JsepTransport* TransportController::GetJsepTransport_n( 395 const JsepTransport* TransportController::GetJsepTransport_n(
366 const std::string& transport_name) const { 396 const std::string& transport_name) const {
367 RTC_DCHECK(network_thread_->IsCurrent()); 397 RTC_DCHECK(network_thread_->IsCurrent());
368 auto it = transports_.find(transport_name); 398 auto it = transports_.find(transport_name);
369 return (it == transports_.end()) ? nullptr : it->second.get(); 399 return (it == transports_.end()) ? nullptr : it->second.get();
370 } 400 }
371 401
372 JsepTransport* TransportController::GetJsepTransport_n( 402 JsepTransport* TransportController::GetJsepTransport_n(
373 const std::string& transport_name) { 403 const std::string& transport_name) {
374 RTC_DCHECK(network_thread_->IsCurrent()); 404 RTC_DCHECK(network_thread_->IsCurrent());
375 auto it = transports_.find(transport_name); 405 auto it = transports_.find(transport_name);
376 return (it == transports_.end()) ? nullptr : it->second.get(); 406 return (it == transports_.end()) ? nullptr : it->second.get();
377 } 407 }
378 408
379 const TransportController::RefCountedChannel* TransportController::GetChannel_n( 409 const TransportController::RefCountedChannel* TransportController::GetChannel_n(
380 const std::string& transport_name, 410 const std::string& transport_name,
381 int component) const { 411 int component) const {
382 RTC_DCHECK(network_thread_->IsCurrent()); 412 RTC_DCHECK(network_thread_->IsCurrent());
383 auto it = GetChannelIterator_n(transport_name, component); 413 auto it = GetChannelIterator_n(transport_name, component);
384 return (it == channels_.end()) ? nullptr : &(*it); 414 return (it == channels_.end()) ? nullptr : *it;
385 } 415 }
386 416
387 TransportController::RefCountedChannel* TransportController::GetChannel_n( 417 TransportController::RefCountedChannel* TransportController::GetChannel_n(
388 const std::string& transport_name, 418 const std::string& transport_name,
389 int component) { 419 int component) {
390 RTC_DCHECK(network_thread_->IsCurrent()); 420 RTC_DCHECK(network_thread_->IsCurrent());
391 auto it = GetChannelIterator_n(transport_name, component); 421 auto it = GetChannelIterator_n(transport_name, component);
392 return (it == channels_.end()) ? nullptr : &(*it); 422 return (it == channels_.end()) ? nullptr : *it;
393 } 423 }
394 424
395 JsepTransport* TransportController::GetOrCreateJsepTransport_n( 425 JsepTransport* TransportController::GetOrCreateJsepTransport_n(
396 const std::string& transport_name) { 426 const std::string& transport_name) {
397 RTC_DCHECK(network_thread_->IsCurrent()); 427 RTC_DCHECK(network_thread_->IsCurrent());
398 428
399 JsepTransport* transport = GetJsepTransport_n(transport_name); 429 JsepTransport* transport = GetJsepTransport_n(transport_name);
400 if (transport) { 430 if (transport) {
401 return transport; 431 return transport;
402 } 432 }
403 433
404 transport = new JsepTransport(transport_name, certificate_); 434 transport = new JsepTransport(transport_name, certificate_);
405 transports_[transport_name] = std::unique_ptr<JsepTransport>(transport); 435 transports_[transport_name] = std::unique_ptr<JsepTransport>(transport);
406 return transport; 436 return transport;
407 } 437 }
408 438
409 void TransportController::DestroyAllChannels_n() { 439 void TransportController::DestroyAllChannels_n() {
410 RTC_DCHECK(network_thread_->IsCurrent()); 440 RTC_DCHECK(network_thread_->IsCurrent());
411 transports_.clear(); 441 transports_.clear();
442 for (RefCountedChannel* channel : channels_) {
443 // Even though these objects are normally ref-counted, if
444 // TransportController is deleted while they still have references, just
445 // remove all references.
446 while (channel->Release() > 0) {
447 }
pthatcher1 2016/12/13 23:36:56 Look at at refcountedobject.h, that does that exac
Taylor Brandstetter 2016/12/13 23:50:50 The destructor isn't public, it's expected to only
448 }
412 channels_.clear(); 449 channels_.clear();
413 } 450 }
414 451
415 bool TransportController::SetSslMaxProtocolVersion_n( 452 bool TransportController::SetSslMaxProtocolVersion_n(
416 rtc::SSLProtocolVersion version) { 453 rtc::SSLProtocolVersion version) {
417 RTC_DCHECK(network_thread_->IsCurrent()); 454 RTC_DCHECK(network_thread_->IsCurrent());
418 455
419 // Max SSL version can only be set before transports are created. 456 // Max SSL version can only be set before transports are created.
420 if (!transports_.empty()) { 457 if (!transports_.empty()) {
421 return false; 458 return false;
422 } 459 }
423 460
424 ssl_max_version_ = version; 461 ssl_max_version_ = version;
425 return true; 462 return true;
426 } 463 }
427 464
428 void TransportController::SetIceConfig_n(const IceConfig& config) { 465 void TransportController::SetIceConfig_n(const IceConfig& config) {
429 RTC_DCHECK(network_thread_->IsCurrent()); 466 RTC_DCHECK(network_thread_->IsCurrent());
430 467
431 ice_config_ = config; 468 ice_config_ = config;
432 for (auto& channel : channels_) { 469 for (auto& channel : channels_) {
433 channel.dtls()->SetIceConfig(ice_config_); 470 channel->dtls()->SetIceConfig(ice_config_);
434 } 471 }
435 } 472 }
436 473
437 void TransportController::SetIceRole_n(IceRole ice_role) { 474 void TransportController::SetIceRole_n(IceRole ice_role) {
438 RTC_DCHECK(network_thread_->IsCurrent()); 475 RTC_DCHECK(network_thread_->IsCurrent());
439 476
440 ice_role_ = ice_role; 477 ice_role_ = ice_role;
441 for (auto& channel : channels_) { 478 for (auto& channel : channels_) {
442 channel.dtls()->SetIceRole(ice_role_); 479 channel->dtls()->SetIceRole(ice_role_);
443 } 480 }
444 } 481 }
445 482
446 bool TransportController::GetSslRole_n(const std::string& transport_name, 483 bool TransportController::GetSslRole_n(const std::string& transport_name,
447 rtc::SSLRole* role) const { 484 rtc::SSLRole* role) const {
448 RTC_DCHECK(network_thread_->IsCurrent()); 485 RTC_DCHECK(network_thread_->IsCurrent());
449 486
450 const JsepTransport* t = GetJsepTransport_n(transport_name); 487 const JsepTransport* t = GetJsepTransport_n(transport_name);
451 if (!t) { 488 if (!t) {
452 return false; 489 return false;
(...skipping 12 matching lines...) Expand all
465 } 502 }
466 certificate_ = certificate; 503 certificate_ = certificate;
467 504
468 // Set certificate both for Transport, which verifies it matches the 505 // Set certificate both for Transport, which verifies it matches the
469 // fingerprint in SDP... 506 // fingerprint in SDP...
470 for (auto& kv : transports_) { 507 for (auto& kv : transports_) {
471 kv.second->SetLocalCertificate(certificate_); 508 kv.second->SetLocalCertificate(certificate_);
472 } 509 }
473 // ... and for the DTLS channel, which needs it for the DTLS handshake. 510 // ... and for the DTLS channel, which needs it for the DTLS handshake.
474 for (auto& channel : channels_) { 511 for (auto& channel : channels_) {
475 bool set_cert_success = channel.dtls()->SetLocalCertificate(certificate); 512 bool set_cert_success = channel->dtls()->SetLocalCertificate(certificate);
476 RTC_DCHECK(set_cert_success); 513 RTC_DCHECK(set_cert_success);
477 } 514 }
478 return true; 515 return true;
479 } 516 }
480 517
481 bool TransportController::GetLocalCertificate_n( 518 bool TransportController::GetLocalCertificate_n(
482 const std::string& transport_name, 519 const std::string& transport_name,
483 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const { 520 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const {
484 RTC_DCHECK(network_thread_->IsCurrent()); 521 RTC_DCHECK(network_thread_->IsCurrent());
485 522
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 // description on a deleted transport. 601 // description on a deleted transport.
565 return true; 602 return true;
566 } 603 }
567 604
568 LOG(LS_INFO) << "Set remote transport description on " << transport_name; 605 LOG(LS_INFO) << "Set remote transport description on " << transport_name;
569 return transport->SetRemoteTransportDescription(tdesc, action, err); 606 return transport->SetRemoteTransportDescription(tdesc, action, err);
570 } 607 }
571 608
572 void TransportController::MaybeStartGathering_n() { 609 void TransportController::MaybeStartGathering_n() {
573 for (auto& channel : channels_) { 610 for (auto& channel : channels_) {
574 channel.dtls()->MaybeStartGathering(); 611 channel->dtls()->MaybeStartGathering();
575 } 612 }
576 } 613 }
577 614
578 bool TransportController::AddRemoteCandidates_n( 615 bool TransportController::AddRemoteCandidates_n(
579 const std::string& transport_name, 616 const std::string& transport_name,
580 const Candidates& candidates, 617 const Candidates& candidates,
581 std::string* err) { 618 std::string* err) {
582 RTC_DCHECK(network_thread_->IsCurrent()); 619 RTC_DCHECK(network_thread_->IsCurrent());
583 620
584 // Verify each candidate before passing down to the transport layer. 621 // Verify each candidate before passing down to the transport layer.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 return false; 699 return false;
663 } 700 }
664 return transport->GetStats(stats); 701 return transport->GetStats(stats);
665 } 702 }
666 703
667 void TransportController::SetMetricsObserver_n( 704 void TransportController::SetMetricsObserver_n(
668 webrtc::MetricsObserverInterface* metrics_observer) { 705 webrtc::MetricsObserverInterface* metrics_observer) {
669 RTC_DCHECK(network_thread_->IsCurrent()); 706 RTC_DCHECK(network_thread_->IsCurrent());
670 metrics_observer_ = metrics_observer; 707 metrics_observer_ = metrics_observer;
671 for (auto& channel : channels_) { 708 for (auto& channel : channels_) {
672 channel.dtls()->SetMetricsObserver(metrics_observer); 709 channel->dtls()->SetMetricsObserver(metrics_observer);
673 } 710 }
674 } 711 }
675 712
676 void TransportController::OnChannelWritableState_n( 713 void TransportController::OnChannelWritableState_n(
677 rtc::PacketTransportInterface* transport) { 714 rtc::PacketTransportInterface* transport) {
678 RTC_DCHECK(network_thread_->IsCurrent()); 715 RTC_DCHECK(network_thread_->IsCurrent());
679 LOG(LS_INFO) << " TransportChannel " << transport->debug_name() 716 LOG(LS_INFO) << " TransportChannel " << transport->debug_name()
680 << " writability changed to " << transport->writable() << "."; 717 << " writability changed to " << transport->writable() << ".";
681 UpdateAggregateStates_n(); 718 UpdateAggregateStates_n();
682 } 719 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 792
756 IceConnectionState new_connection_state = kIceConnectionConnecting; 793 IceConnectionState new_connection_state = kIceConnectionConnecting;
757 IceGatheringState new_gathering_state = kIceGatheringNew; 794 IceGatheringState new_gathering_state = kIceGatheringNew;
758 bool any_receiving = false; 795 bool any_receiving = false;
759 bool any_failed = false; 796 bool any_failed = false;
760 bool all_connected = !channels_.empty(); 797 bool all_connected = !channels_.empty();
761 bool all_completed = !channels_.empty(); 798 bool all_completed = !channels_.empty();
762 bool any_gathering = false; 799 bool any_gathering = false;
763 bool all_done_gathering = !channels_.empty(); 800 bool all_done_gathering = !channels_.empty();
764 for (const auto& channel : channels_) { 801 for (const auto& channel : channels_) {
765 any_receiving = any_receiving || channel.dtls()->receiving(); 802 any_receiving = any_receiving || channel->dtls()->receiving();
766 any_failed = 803 any_failed =
767 any_failed || 804 any_failed ||
768 channel.dtls()->GetState() == TransportChannelState::STATE_FAILED; 805 channel->dtls()->GetState() == TransportChannelState::STATE_FAILED;
769 all_connected = all_connected && channel.dtls()->writable(); 806 all_connected = all_connected && channel->dtls()->writable();
770 all_completed = 807 all_completed =
771 all_completed && channel.dtls()->writable() && 808 all_completed && channel->dtls()->writable() &&
772 channel.dtls()->GetState() == TransportChannelState::STATE_COMPLETED && 809 channel->dtls()->GetState() == TransportChannelState::STATE_COMPLETED &&
773 channel.dtls()->GetIceRole() == ICEROLE_CONTROLLING && 810 channel->dtls()->GetIceRole() == ICEROLE_CONTROLLING &&
774 channel.dtls()->gathering_state() == kIceGatheringComplete; 811 channel->dtls()->gathering_state() == kIceGatheringComplete;
775 any_gathering = 812 any_gathering =
776 any_gathering || channel.dtls()->gathering_state() != kIceGatheringNew; 813 any_gathering || channel->dtls()->gathering_state() != kIceGatheringNew;
777 all_done_gathering = 814 all_done_gathering =
778 all_done_gathering && 815 all_done_gathering &&
779 channel.dtls()->gathering_state() == kIceGatheringComplete; 816 channel->dtls()->gathering_state() == kIceGatheringComplete;
780 } 817 }
781 818
782 if (any_failed) { 819 if (any_failed) {
783 new_connection_state = kIceConnectionFailed; 820 new_connection_state = kIceConnectionFailed;
784 } else if (all_completed) { 821 } else if (all_completed) {
785 new_connection_state = kIceConnectionCompleted; 822 new_connection_state = kIceConnectionCompleted;
786 } else if (all_connected) { 823 } else if (all_connected) {
787 new_connection_state = kIceConnectionConnected; 824 new_connection_state = kIceConnectionConnected;
788 } 825 }
789 if (connection_state_ != new_connection_state) { 826 if (connection_state_ != new_connection_state) {
(...skipping 20 matching lines...) Expand all
810 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE, 847 RTC_FROM_HERE, this, MSG_ICEGATHERINGSTATE,
811 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state)); 848 new rtc::TypedMessageData<IceGatheringState>(new_gathering_state));
812 } 849 }
813 } 850 }
814 851
815 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { 852 void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) {
816 SignalDtlsHandshakeError(error); 853 SignalDtlsHandshakeError(error);
817 } 854 }
818 855
819 } // namespace cricket 856 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/transportcontroller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698