| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 explicit FakeTransportController(rtc::Thread* worker_thread) | 504 explicit FakeTransportController(rtc::Thread* worker_thread) |
| 505 : TransportController(rtc::Thread::Current(), worker_thread, nullptr), | 505 : TransportController(rtc::Thread::Current(), worker_thread, nullptr), |
| 506 fail_create_channel_(false) {} | 506 fail_create_channel_(false) {} |
| 507 | 507 |
| 508 FakeTransportController(rtc::Thread* worker_thread, IceRole role) | 508 FakeTransportController(rtc::Thread* worker_thread, IceRole role) |
| 509 : TransportController(rtc::Thread::Current(), worker_thread, nullptr), | 509 : TransportController(rtc::Thread::Current(), worker_thread, nullptr), |
| 510 fail_create_channel_(false) { | 510 fail_create_channel_(false) { |
| 511 SetIceRole(role); | 511 SetIceRole(role); |
| 512 } | 512 } |
| 513 | 513 |
| 514 FakeTransport* GetTransport_w(const std::string& transport_name) { | 514 FakeTransport* GetTransport_n(const std::string& transport_name) { |
| 515 return static_cast<FakeTransport*>( | 515 return static_cast<FakeTransport*>( |
| 516 TransportController::GetTransport_w(transport_name)); | 516 TransportController::GetTransport_n(transport_name)); |
| 517 } | 517 } |
| 518 | 518 |
| 519 void Connect(FakeTransportController* dest) { | 519 void Connect(FakeTransportController* dest) { |
| 520 worker_thread()->Invoke<void>( | 520 network_thread()->Invoke<void>( |
| 521 rtc::Bind(&FakeTransportController::Connect_w, this, dest)); | 521 rtc::Bind(&FakeTransportController::Connect_n, this, dest)); |
| 522 } | 522 } |
| 523 | 523 |
| 524 TransportChannel* CreateTransportChannel_w(const std::string& transport_name, | 524 TransportChannel* CreateTransportChannel_n(const std::string& transport_name, |
| 525 int component) override { | 525 int component) override { |
| 526 if (fail_create_channel_) { | 526 if (fail_create_channel_) { |
| 527 return nullptr; | 527 return nullptr; |
| 528 } | 528 } |
| 529 return TransportController::CreateTransportChannel_w(transport_name, | 529 return TransportController::CreateTransportChannel_n(transport_name, |
| 530 component); | 530 component); |
| 531 } | 531 } |
| 532 | 532 |
| 533 FakeCandidatePair* CreateFakeCandidatePair( | 533 FakeCandidatePair* CreateFakeCandidatePair( |
| 534 const rtc::SocketAddress& local_address, | 534 const rtc::SocketAddress& local_address, |
| 535 int16_t local_network_id, | 535 int16_t local_network_id, |
| 536 const rtc::SocketAddress& remote_address, | 536 const rtc::SocketAddress& remote_address, |
| 537 int16_t remote_network_id) { | 537 int16_t remote_network_id) { |
| 538 Candidate local_candidate(0, "udp", local_address, 0u, "", "", "local", 0, | 538 Candidate local_candidate(0, "udp", local_address, 0u, "", "", "local", 0, |
| 539 "foundation", local_network_id, 0); | 539 "foundation", local_network_id, 0); |
| 540 Candidate remote_candidate(0, "udp", remote_address, 0u, "", "", "local", 0, | 540 Candidate remote_candidate(0, "udp", remote_address, 0u, "", "", "local", 0, |
| 541 "foundation", remote_network_id, 0); | 541 "foundation", remote_network_id, 0); |
| 542 return new FakeCandidatePair(local_candidate, remote_candidate); | 542 return new FakeCandidatePair(local_candidate, remote_candidate); |
| 543 } | 543 } |
| 544 | 544 |
| 545 void set_fail_channel_creation(bool fail_channel_creation) { | 545 void set_fail_channel_creation(bool fail_channel_creation) { |
| 546 fail_create_channel_ = fail_channel_creation; | 546 fail_create_channel_ = fail_channel_creation; |
| 547 } | 547 } |
| 548 | 548 |
| 549 protected: | 549 protected: |
| 550 Transport* CreateTransport_w(const std::string& transport_name) override { | 550 Transport* CreateTransport_n(const std::string& transport_name) override { |
| 551 return new FakeTransport(transport_name); | 551 return new FakeTransport(transport_name); |
| 552 } | 552 } |
| 553 | 553 |
| 554 void Connect_w(FakeTransportController* dest) { | 554 void Connect_n(FakeTransportController* dest) { |
| 555 // Simulate the exchange of candidates. | 555 // Simulate the exchange of candidates. |
| 556 ConnectChannels_w(); | 556 ConnectChannels_n(); |
| 557 dest->ConnectChannels_w(); | 557 dest->ConnectChannels_n(); |
| 558 for (auto& kv : transports()) { | 558 for (auto& kv : transports()) { |
| 559 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); | 559 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); |
| 560 transport->SetDestination(dest->GetTransport_w(kv.first)); | 560 transport->SetDestination(dest->GetTransport_n(kv.first)); |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 | 563 |
| 564 void ConnectChannels_w() { | 564 void ConnectChannels_n() { |
| 565 TransportDescription faketransport_desc( | 565 TransportDescription faketransport_desc( |
| 566 std::vector<std::string>(), | 566 std::vector<std::string>(), |
| 567 rtc::CreateRandomString(cricket::ICE_UFRAG_LENGTH), | 567 rtc::CreateRandomString(cricket::ICE_UFRAG_LENGTH), |
| 568 rtc::CreateRandomString(cricket::ICE_PWD_LENGTH), cricket::ICEMODE_FULL, | 568 rtc::CreateRandomString(cricket::ICE_PWD_LENGTH), cricket::ICEMODE_FULL, |
| 569 cricket::CONNECTIONROLE_NONE, nullptr); | 569 cricket::CONNECTIONROLE_NONE, nullptr); |
| 570 for (auto& kv : transports()) { | 570 for (auto& kv : transports()) { |
| 571 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); | 571 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); |
| 572 // Set local transport description for FakeTransport before connecting. | 572 // Set local transport description for FakeTransport before connecting. |
| 573 // Otherwise, the RTC_CHECK in Transport.ConnectChannel will fail. | 573 // Otherwise, the RTC_CHECK in Transport.ConnectChannel will fail. |
| 574 if (!transport->local_description()) { | 574 if (!transport->local_description()) { |
| 575 transport->SetLocalTransportDescription(faketransport_desc, | 575 transport->SetLocalTransportDescription(faketransport_desc, |
| 576 cricket::CA_OFFER, nullptr); | 576 cricket::CA_OFFER, nullptr); |
| 577 } | 577 } |
| 578 transport->ConnectChannels(); | 578 transport->ConnectChannels(); |
| 579 transport->MaybeStartGathering(); | 579 transport->MaybeStartGathering(); |
| 580 } | 580 } |
| 581 } | 581 } |
| 582 | 582 |
| 583 private: | 583 private: |
| 584 bool fail_create_channel_; | 584 bool fail_create_channel_; |
| 585 }; | 585 }; |
| 586 | 586 |
| 587 } // namespace cricket | 587 } // namespace cricket |
| 588 | 588 |
| 589 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ | 589 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ |
| OLD | NEW |