| 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 11 matching lines...) Expand all Loading... |
| 22 #include "webrtc/p2p/base/transportcontroller.h" | 22 #include "webrtc/p2p/base/transportcontroller.h" |
| 23 #include "webrtc/p2p/base/transportchannelimpl.h" | 23 #include "webrtc/p2p/base/transportchannelimpl.h" |
| 24 #include "webrtc/base/bind.h" | 24 #include "webrtc/base/bind.h" |
| 25 #include "webrtc/base/buffer.h" | 25 #include "webrtc/base/buffer.h" |
| 26 #include "webrtc/base/fakesslidentity.h" | 26 #include "webrtc/base/fakesslidentity.h" |
| 27 #include "webrtc/base/messagequeue.h" | 27 #include "webrtc/base/messagequeue.h" |
| 28 #include "webrtc/base/sigslot.h" | 28 #include "webrtc/base/sigslot.h" |
| 29 #include "webrtc/base/sslfingerprint.h" | 29 #include "webrtc/base/sslfingerprint.h" |
| 30 #include "webrtc/base/thread.h" | 30 #include "webrtc/base/thread.h" |
| 31 | 31 |
| 32 #ifdef HAVE_QUIC | |
| 33 #include "webrtc/p2p/quic/quictransport.h" | |
| 34 #endif | |
| 35 | |
| 36 namespace cricket { | 32 namespace cricket { |
| 37 | 33 |
| 38 class FakeTransport; | 34 class FakeTransport; |
| 39 | 35 |
| 40 namespace { | 36 namespace { |
| 41 struct PacketMessageData : public rtc::MessageData { | 37 struct PacketMessageData : public rtc::MessageData { |
| 42 PacketMessageData(const char* data, size_t len) : packet(data, len) {} | 38 PacketMessageData(const char* data, size_t len) : packet(data, len) {} |
| 43 rtc::Buffer packet; | 39 rtc::Buffer packet; |
| 44 }; | 40 }; |
| 45 } // namespace | 41 } // namespace |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 // This map just tracks the FakeTransportChannels created by this class. | 446 // This map just tracks the FakeTransportChannels created by this class. |
| 451 // It's mainly needed so that we can access a FakeTransportChannel directly, | 447 // It's mainly needed so that we can access a FakeTransportChannel directly, |
| 452 // even if wrapped by a DtlsTransportChannelWrapper. | 448 // even if wrapped by a DtlsTransportChannelWrapper. |
| 453 ChannelMap channels_; | 449 ChannelMap channels_; |
| 454 FakeTransport* dest_ = nullptr; | 450 FakeTransport* dest_ = nullptr; |
| 455 bool async_ = false; | 451 bool async_ = false; |
| 456 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; | 452 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; |
| 457 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; | 453 rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12; |
| 458 }; | 454 }; |
| 459 | 455 |
| 460 #ifdef HAVE_QUIC | |
| 461 class FakeQuicTransport : public QuicTransport { | |
| 462 public: | |
| 463 FakeQuicTransport(const std::string& transport_name) | |
| 464 : QuicTransport(transport_name, nullptr, nullptr) {} | |
| 465 | |
| 466 protected: | |
| 467 QuicTransportChannel* CreateTransportChannel(int component) override { | |
| 468 FakeTransportChannel* fake_ice_transport_channel = | |
| 469 new FakeTransportChannel(name(), component); | |
| 470 return new QuicTransportChannel(fake_ice_transport_channel); | |
| 471 } | |
| 472 }; | |
| 473 #endif | |
| 474 | |
| 475 // Fake candidate pair class, which can be passed to BaseChannel for testing | 456 // Fake candidate pair class, which can be passed to BaseChannel for testing |
| 476 // purposes. | 457 // purposes. |
| 477 class FakeCandidatePair : public CandidatePairInterface { | 458 class FakeCandidatePair : public CandidatePairInterface { |
| 478 public: | 459 public: |
| 479 FakeCandidatePair(const Candidate& local_candidate, | 460 FakeCandidatePair(const Candidate& local_candidate, |
| 480 const Candidate& remote_candidate) | 461 const Candidate& remote_candidate) |
| 481 : local_candidate_(local_candidate), | 462 : local_candidate_(local_candidate), |
| 482 remote_candidate_(remote_candidate) {} | 463 remote_candidate_(remote_candidate) {} |
| 483 const Candidate& local_candidate() const override { return local_candidate_; } | 464 const Candidate& local_candidate() const override { return local_candidate_; } |
| 484 const Candidate& remote_candidate() const override { | 465 const Candidate& remote_candidate() const override { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 "foundation", remote_network_id, 0); | 534 "foundation", remote_network_id, 0); |
| 554 return new FakeCandidatePair(local_candidate, remote_candidate); | 535 return new FakeCandidatePair(local_candidate, remote_candidate); |
| 555 } | 536 } |
| 556 | 537 |
| 557 void set_fail_channel_creation(bool fail_channel_creation) { | 538 void set_fail_channel_creation(bool fail_channel_creation) { |
| 558 fail_create_channel_ = fail_channel_creation; | 539 fail_create_channel_ = fail_channel_creation; |
| 559 } | 540 } |
| 560 | 541 |
| 561 protected: | 542 protected: |
| 562 Transport* CreateTransport_n(const std::string& transport_name) override { | 543 Transport* CreateTransport_n(const std::string& transport_name) override { |
| 563 #ifdef HAVE_QUIC | |
| 564 if (quic()) { | |
| 565 return new FakeQuicTransport(transport_name); | |
| 566 } | |
| 567 #endif | |
| 568 return new FakeTransport(transport_name); | 544 return new FakeTransport(transport_name); |
| 569 } | 545 } |
| 570 | 546 |
| 571 void Connect_n(FakeTransportController* dest) { | 547 void Connect_n(FakeTransportController* dest) { |
| 572 // Simulate the exchange of candidates. | 548 // Simulate the exchange of candidates. |
| 573 ConnectChannels_n(); | 549 ConnectChannels_n(); |
| 574 dest->ConnectChannels_n(); | 550 dest->ConnectChannels_n(); |
| 575 for (auto& kv : transports()) { | 551 for (auto& kv : transports()) { |
| 576 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); | 552 FakeTransport* transport = static_cast<FakeTransport*>(kv.second); |
| 577 transport->SetDestination(dest->GetTransport_n(kv.first)); | 553 transport->SetDestination(dest->GetTransport_n(kv.first)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 596 } | 572 } |
| 597 } | 573 } |
| 598 | 574 |
| 599 private: | 575 private: |
| 600 bool fail_create_channel_; | 576 bool fail_create_channel_; |
| 601 }; | 577 }; |
| 602 | 578 |
| 603 } // namespace cricket | 579 } // namespace cricket |
| 604 | 580 |
| 605 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ | 581 #endif // WEBRTC_P2P_BASE_FAKETRANSPORTCONTROLLER_H_ |
| OLD | NEW |