Chromium Code Reviews| Index: webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| index 7e65b4baba93d22a4cac78b71b31705229006f04..76e2a57f3543b7a5b86a26708109de107811c15e 100644 |
| --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc |
| @@ -13,6 +13,7 @@ |
| #include "webrtc/api/fakemetricsobserver.h" |
| #include "webrtc/p2p/base/fakeportallocator.h" |
| +#include "webrtc/p2p/base/packettransportinterface.h" |
| #include "webrtc/p2p/base/p2ptransportchannel.h" |
| #include "webrtc/p2p/base/testrelayserver.h" |
| #include "webrtc/p2p/base/teststunserver.h" |
| @@ -280,12 +281,16 @@ class P2PTransportChannelTestBase : public testing::Test, |
| tiebreaker_(0), |
| role_conflict_(false), |
| save_candidates_(false) {} |
| - bool HasChannel(TransportChannel* ch) { |
| - return (ch == cd1_.ch_.get() || ch == cd2_.ch_.get()); |
| + bool HasChannel(TransportChannel const* const ch) { |
|
Taylor Brandstetter
2016/10/17 23:24:50
nit: It seems we could just get rid of this method
johan
2016/10/18 09:17:08
Acknowledged.
|
| + return HasTransport(ch); |
| } |
| - ChannelData* GetChannelData(TransportChannel* ch) { |
| - if (!HasChannel(ch)) return NULL; |
| - if (cd1_.ch_.get() == ch) |
| + bool HasTransport(rtc::PacketTransportInterface const* const transport) { |
|
Taylor Brandstetter
2016/10/17 23:24:50
nit: Our style is "const Foo*" rather than "Foo co
johan
2016/10/18 09:17:08
Acknowledged.
|
| + return (transport == cd1_.ch_.get() || transport == cd2_.ch_.get()); |
| + } |
| + ChannelData* GetChannelData(rtc::PacketTransportInterface* transport) { |
| + if (!HasTransport(transport)) |
| + return NULL; |
| + if (cd1_.ch_.get() == transport) |
| return &cd1_; |
| else |
| return &cd2_; |
| @@ -319,11 +324,11 @@ class P2PTransportChannelTestBase : public testing::Test, |
| bool ready_to_send_ = false; |
| }; |
| - ChannelData* GetChannelData(TransportChannel* channel) { |
| - if (ep1_.HasChannel(channel)) |
| - return ep1_.GetChannelData(channel); |
| + ChannelData* GetChannelData(rtc::PacketTransportInterface* transport) { |
| + if (ep1_.HasTransport(transport)) |
| + return ep1_.GetChannelData(transport); |
| else |
| - return ep2_.GetChannelData(channel); |
| + return ep2_.GetChannelData(transport); |
| } |
| IceParameters IceParamsWithRenomination(const IceParameters& ice, |
| @@ -670,8 +675,8 @@ class P2PTransportChannelTestBase : public testing::Test, |
| TestSendRecv(); |
| } |
| - void OnReadyToSend(TransportChannel* ch) { |
| - GetEndpoint(ch)->ready_to_send_ = true; |
| + void OnReadyToSend(rtc::PacketTransportInterface* transport) { |
| + GetEndpoint(transport)->ready_to_send_ = true; |
| } |
| // We pass the candidates directly to the other side. |
| @@ -777,14 +782,16 @@ class P2PTransportChannelTestBase : public testing::Test, |
| } |
| } |
| } |
| - void OnReadPacket(TransportChannel* channel, |
| + |
| + void OnReadPacket(rtc::PacketTransportInterface* transport, |
| const char* data, |
| size_t len, |
| const rtc::PacketTime& packet_time, |
| int flags) { |
| - std::list<std::string>& packets = GetPacketList(channel); |
| + std::list<std::string>& packets = GetPacketList(transport); |
| packets.push_front(std::string(data, len)); |
| } |
| + |
| void OnRoleConflict(TransportChannelImpl* channel) { |
| GetEndpoint(channel)->OnRoleConflict(true); |
| IceRole new_role = GetEndpoint(channel)->ice_role() == ICEROLE_CONTROLLING |
| @@ -812,10 +819,10 @@ class P2PTransportChannelTestBase : public testing::Test, |
| ? &ch->selected_connection()->remote_candidate() |
| : NULL; |
| } |
| - Endpoint* GetEndpoint(TransportChannel* ch) { |
| - if (ep1_.HasChannel(ch)) { |
| + Endpoint* GetEndpoint(rtc::PacketTransportInterface* transport) { |
| + if (ep1_.HasTransport(transport)) { |
| return &ep1_; |
| - } else if (ep2_.HasChannel(ch)) { |
| + } else if (ep2_.HasTransport(transport)) { |
| return &ep2_; |
| } else { |
| return NULL; |
| @@ -833,8 +840,9 @@ class P2PTransportChannelTestBase : public testing::Test, |
| else |
| return NULL; |
| } |
| - std::list<std::string>& GetPacketList(TransportChannel* ch) { |
| - return GetChannelData(ch)->ch_packets_; |
| + std::list<std::string>& GetPacketList( |
| + rtc::PacketTransportInterface* transport) { |
| + return GetChannelData(transport)->ch_packets_; |
| } |
| enum RemoteIceParameterSource { FROM_CANDIDATE, FROM_SETICEPARAMETERS }; |
| @@ -2909,7 +2917,7 @@ class P2PTransportChannelPingTest : public testing::Test, |
| conn->OnReadPacket(buf.Data(), buf.Length(), rtc::CreatePacketTime(0)); |
| } |
| - void OnReadyToSend(TransportChannel* channel) { |
| + void OnReadyToSend(rtc::PacketTransportInterface* transport) { |
| channel_ready_to_send_ = true; |
| } |
| void OnChannelStateChanged(TransportChannelImpl* channel) { |