diff --git a/webrtc/p2p/base/dtlstransport.h b/webrtc/p2p/base/dtlstransport.h index 9f2903e1d7..276b05f786 100644 --- a/webrtc/p2p/base/dtlstransport.h +++ b/webrtc/p2p/base/dtlstransport.h @@ -199,7 +199,7 @@ class DtlsTransport : public Base { DtlsTransportChannelWrapper* CreateTransportChannel(int component) override { DtlsTransportChannelWrapper* channel = new DtlsTransportChannelWrapper( - this, Base::CreateTransportChannel(component)); + Base::CreateTransportChannel(component)); channel->SetSslMaxProtocolVersion(ssl_max_version_); return channel; } diff --git a/webrtc/p2p/base/dtlstransportchannel.cc b/webrtc/p2p/base/dtlstransportchannel.cc index d6b5bce723..59ef2bc41e 100644 --- a/webrtc/p2p/base/dtlstransportchannel.cc +++ b/webrtc/p2p/base/dtlstransportchannel.cc @@ -89,10 +89,8 @@ bool StreamInterfaceChannel::OnPacketReceived(const char* data, size_t size) { } DtlsTransportChannelWrapper::DtlsTransportChannelWrapper( - Transport* transport, TransportChannelImpl* channel) : TransportChannelImpl(channel->transport_name(), channel->component()), - transport_(transport), worker_thread_(rtc::Thread::Current()), channel_(channel), downward_(NULL), diff --git a/webrtc/p2p/base/dtlstransportchannel.h b/webrtc/p2p/base/dtlstransportchannel.h index 955b963a36..f396a57d30 100644 --- a/webrtc/p2p/base/dtlstransportchannel.h +++ b/webrtc/p2p/base/dtlstransportchannel.h @@ -82,10 +82,8 @@ class StreamInterfaceChannel : public rtc::StreamInterface { class DtlsTransportChannelWrapper : public TransportChannelImpl { public: // The parameters here are: - // transport -- the DtlsTransport that created us // channel -- the TransportChannel we are wrapping - DtlsTransportChannelWrapper(Transport* transport, - TransportChannelImpl* channel); + explicit DtlsTransportChannelWrapper(TransportChannelImpl* channel); ~DtlsTransportChannelWrapper() override; void SetIceRole(IceRole role) override { channel_->SetIceRole(role); } @@ -159,8 +157,6 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { } // TransportChannelImpl calls. - Transport* GetTransport() override { return transport_; } - TransportChannelState GetState() const override { return channel_->GetState(); } @@ -218,9 +214,8 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { void OnConnectionRemoved(TransportChannelImpl* channel); void Reconnect(); - Transport* transport_; // The transport_ that created us. rtc::Thread* worker_thread_; // Everything should occur on this thread. - // Underlying channel, owned by transport_. + // Underlying channel, not owned by this class. TransportChannelImpl* const channel_; rtc::scoped_ptr dtls_; // The DTLS stream StreamInterfaceChannel* downward_; // Wrapper for channel_, owned by dtls_. diff --git a/webrtc/p2p/base/faketransportcontroller.h b/webrtc/p2p/base/faketransportcontroller.h index 65c59be98d..63e8fd3124 100644 --- a/webrtc/p2p/base/faketransportcontroller.h +++ b/webrtc/p2p/base/faketransportcontroller.h @@ -45,11 +45,8 @@ struct PacketMessageData : public rtc::MessageData { class FakeTransportChannel : public TransportChannelImpl, public rtc::MessageHandler { public: - explicit FakeTransportChannel(Transport* transport, - const std::string& name, - int component) + explicit FakeTransportChannel(const std::string& name, int component) : TransportChannelImpl(name, component), - transport_(transport), dtls_fingerprint_("", nullptr, 0) {} ~FakeTransportChannel() { Reset(); } @@ -67,8 +64,6 @@ class FakeTransportChannel : public TransportChannelImpl, // synchronously "Send"-ing. void SetAsync(bool async) { async_ = async; } - Transport* GetTransport() override { return transport_; } - TransportChannelState GetState() const override { if (connection_count_ == 0) { return had_connection_ ? TransportChannelState::STATE_FAILED @@ -313,7 +308,6 @@ class FakeTransportChannel : public TransportChannelImpl, private: enum State { STATE_INIT, STATE_CONNECTING, STATE_CONNECTED }; - Transport* transport_; FakeTransportChannel* dest_ = nullptr; State state_ = STATE_INIT; bool async_ = false; @@ -414,8 +408,7 @@ class FakeTransport : public Transport { if (channels_.find(component) != channels_.end()) { return nullptr; } - FakeTransportChannel* channel = - new FakeTransportChannel(this, name(), component); + FakeTransportChannel* channel = new FakeTransportChannel(name(), component); channel->set_ssl_max_protocol_version(ssl_max_version_); channel->SetAsync(async_); SetChannelDestination(component, channel); diff --git a/webrtc/p2p/base/p2ptransport.cc b/webrtc/p2p/base/p2ptransport.cc index abc4c14504..1ad2a6faa3 100644 --- a/webrtc/p2p/base/p2ptransport.cc +++ b/webrtc/p2p/base/p2ptransport.cc @@ -28,7 +28,7 @@ P2PTransport::~P2PTransport() { } TransportChannelImpl* P2PTransport::CreateTransportChannel(int component) { - return new P2PTransportChannel(name(), component, this, port_allocator()); + return new P2PTransportChannel(name(), component, port_allocator()); } void P2PTransport::DestroyTransportChannel(TransportChannelImpl* channel) { diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc index 74f1392b1b..e7788e733a 100644 --- a/webrtc/p2p/base/p2ptransportchannel.cc +++ b/webrtc/p2p/base/p2ptransportchannel.cc @@ -219,8 +219,12 @@ P2PTransportChannel::P2PTransportChannel(const std::string& transport_name, int component, P2PTransport* transport, PortAllocator* allocator) + : P2PTransportChannel(transport_name, component, allocator) {} + +P2PTransportChannel::P2PTransportChannel(const std::string& transport_name, + int component, + PortAllocator* allocator) : TransportChannelImpl(transport_name, component), - transport_(transport), allocator_(allocator), worker_thread_(rtc::Thread::Current()), incoming_only_(false), diff --git a/webrtc/p2p/base/p2ptransportchannel.h b/webrtc/p2p/base/p2ptransportchannel.h index fde00263d0..60ce973054 100644 --- a/webrtc/p2p/base/p2ptransportchannel.h +++ b/webrtc/p2p/base/p2ptransportchannel.h @@ -27,7 +27,6 @@ #include "webrtc/p2p/base/p2ptransport.h" #include "webrtc/p2p/base/portallocator.h" #include "webrtc/p2p/base/portinterface.h" -#include "webrtc/p2p/base/transport.h" #include "webrtc/p2p/base/transportchannelimpl.h" #include "webrtc/base/asyncpacketsocket.h" #include "webrtc/base/sigslot.h" @@ -65,6 +64,11 @@ class RemoteCandidate : public Candidate { class P2PTransportChannel : public TransportChannelImpl, public rtc::MessageHandler { public: + P2PTransportChannel(const std::string& transport_name, + int component, + PortAllocator* allocator); + // TODO(mikescarlett): Deprecated. Remove when Chromium's + // IceTransportChannel does not depend on this. P2PTransportChannel(const std::string& transport_name, int component, P2PTransport* transport, @@ -72,7 +76,6 @@ class P2PTransportChannel : public TransportChannelImpl, virtual ~P2PTransportChannel(); // From TransportChannelImpl: - Transport* GetTransport() override { return transport_; } TransportChannelState GetState() const override; void SetIceRole(IceRole role) override; IceRole GetIceRole() const override { return ice_role_; } @@ -265,7 +268,6 @@ class P2PTransportChannel : public TransportChannelImpl, : static_cast(remote_ice_parameters_.size() - 1); } - P2PTransport* transport_; PortAllocator* allocator_; rtc::Thread* worker_thread_; bool incoming_only_; diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc index 38f12fa7ff..74b96a3532 100644 --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc @@ -306,7 +306,7 @@ class P2PTransportChannelTestBase : public testing::Test, const std::string& remote_ice_ufrag, const std::string& remote_ice_pwd) { cricket::P2PTransportChannel* channel = new cricket::P2PTransportChannel( - "test content name", component, NULL, GetAllocator(endpoint)); + "test content name", component, GetAllocator(endpoint)); channel->SignalCandidateGathered.connect( this, &P2PTransportChannelTestBase::OnCandidate); channel->SignalReadPacket.connect( @@ -1910,7 +1910,7 @@ class P2PTransportChannelPingTest : public testing::Test, TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("trigger checks", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("trigger checks", 1, &pa); PrepareChannel(&ch); ch.Connect(); ch.MaybeStartGathering(); @@ -1935,7 +1935,7 @@ TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) { TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("trigger checks", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("trigger checks", 1, &pa); PrepareChannel(&ch); ch.Connect(); ch.MaybeStartGathering(); @@ -1966,7 +1966,7 @@ TEST_F(P2PTransportChannelPingTest, TestNoTriggeredChecksWhenWritable) { // ufrag, its pwd and generation will be set properly. TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("add candidate", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("add candidate", 1, &pa); PrepareChannel(&ch); ch.Connect(); ch.MaybeStartGathering(); @@ -2016,7 +2016,7 @@ TEST_F(P2PTransportChannelPingTest, TestAddRemoteCandidateWithVariousUfrags) { TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("connection resurrection", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("connection resurrection", 1, &pa); PrepareChannel(&ch); ch.Connect(); ch.MaybeStartGathering(); @@ -2069,7 +2069,7 @@ TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) { TEST_F(P2PTransportChannelPingTest, TestReceivingStateChange) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("receiving state change", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("receiving state change", 1, &pa); PrepareChannel(&ch); // Default receiving timeout and checking receiving delay should not be too // small. @@ -2097,7 +2097,7 @@ TEST_F(P2PTransportChannelPingTest, TestReceivingStateChange) { // "best connection". TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("receiving state change", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("receiving state change", 1, &pa); PrepareChannel(&ch); ch.SetIceRole(cricket::ICEROLE_CONTROLLED); ch.Connect(); @@ -2154,7 +2154,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBeforeNomination) { // a ping response and set the ICE pwd in the remote candidate appropriately. TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("receiving state change", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("receiving state change", 1, &pa); PrepareChannel(&ch); ch.SetIceRole(cricket::ICEROLE_CONTROLLED); ch.Connect(); @@ -2236,7 +2236,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) { // the "best connection". TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("receiving state change", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("receiving state change", 1, &pa); PrepareChannel(&ch); ch.SetIceRole(cricket::ICEROLE_CONTROLLED); ch.Connect(); @@ -2294,7 +2294,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) { // be pruned. Otherwise, lower-priority connections are kept. TEST_F(P2PTransportChannelPingTest, TestDontPruneWhenWeak) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("test channel", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("test channel", 1, &pa); PrepareChannel(&ch); ch.SetIceRole(cricket::ICEROLE_CONTROLLED); ch.Connect(); @@ -2332,7 +2332,7 @@ TEST_F(P2PTransportChannelPingTest, TestDontPruneWhenWeak) { // Test that GetState returns the state correctly. TEST_F(P2PTransportChannelPingTest, TestGetState) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("test channel", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("test channel", 1, &pa); PrepareChannel(&ch); ch.Connect(); ch.MaybeStartGathering(); @@ -2359,7 +2359,7 @@ TEST_F(P2PTransportChannelPingTest, TestGetState) { // right away, and it can become active and be pruned again. TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("test channel", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("test channel", 1, &pa); PrepareChannel(&ch); ch.SetIceConfig(CreateIceConfig(1000, false)); ch.Connect(); @@ -2402,7 +2402,7 @@ TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) { // will all be deleted. We use Prune to simulate write_time_out. TEST_F(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("test channel", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("test channel", 1, &pa); PrepareChannel(&ch); ch.Connect(); ch.MaybeStartGathering(); @@ -2434,7 +2434,7 @@ TEST_F(P2PTransportChannelPingTest, TestDeleteConnectionsIfAllWriteTimedout) { // holds even if the transport channel did not lose the writability. TEST_F(P2PTransportChannelPingTest, TestStopPortAllocatorSessions) { cricket::FakePortAllocator pa(rtc::Thread::Current(), nullptr); - cricket::P2PTransportChannel ch("test channel", 1, nullptr, &pa); + cricket::P2PTransportChannel ch("test channel", 1, &pa); PrepareChannel(&ch); ch.SetIceConfig(CreateIceConfig(2000, false)); ch.Connect(); diff --git a/webrtc/p2p/base/transportchannelimpl.h b/webrtc/p2p/base/transportchannelimpl.h index 8d4d4bb728..1fa088a30d 100644 --- a/webrtc/p2p/base/transportchannelimpl.h +++ b/webrtc/p2p/base/transportchannelimpl.h @@ -12,7 +12,6 @@ #define WEBRTC_P2P_BASE_TRANSPORTCHANNELIMPL_H_ #include -#include "webrtc/p2p/base/transport.h" #include "webrtc/p2p/base/transportchannel.h" namespace buzz { class XmlElement; } @@ -36,9 +35,6 @@ class TransportChannelImpl : public TransportChannel { int component) : TransportChannel(transport_name, component) {} - // Returns the transport that created this channel. - virtual Transport* GetTransport() = 0; - // For ICE channels. virtual IceRole GetIceRole() const = 0; virtual void SetIceRole(IceRole role) = 0; diff --git a/webrtc/p2p/quic/quicsession_unittest.cc b/webrtc/p2p/quic/quicsession_unittest.cc index 6733796127..765a47f0c2 100644 --- a/webrtc/p2p/quic/quicsession_unittest.cc +++ b/webrtc/p2p/quic/quicsession_unittest.cc @@ -286,9 +286,9 @@ class QuicSessionTest : public ::testing::Test, // establishes encryption with client. void QuicSessionTest::CreateClientAndServerSessions() { scoped_ptr channel1( - new FakeTransportChannel(nullptr, "channel1", 0)); + new FakeTransportChannel("channel1", 0)); scoped_ptr channel2( - new FakeTransportChannel(nullptr, "channel2", 0)); + new FakeTransportChannel("channel2", 0)); // Prevent channel1->OnReadPacket and channel2->OnReadPacket from calling // themselves in a loop, which causes to future packets to be recursively