From 27c3d5b65202255b3d9a253872917b504d1ed408 Mon Sep 17 00:00:00 2001 From: johan Date: Mon, 17 Oct 2016 00:54:57 -0700 Subject: [PATCH] Restore thread name consistency for webrtc/p2p/ . Thread variables were named worker_thread, while they actually reference the network_thread introduced with the CLs below. Original introduction of network_thread: https://codereview.webrtc.org/1895813003 https://codereview.webrtc.org/1903393004 Renming of woker_thread_ to network_thread_ in P2PTransportChannel: https://codereview.webrtc.org/2378573003 BUG=webrtc:6432 Review-Url: https://codereview.webrtc.org/2396513003 Cr-Commit-Position: refs/heads/master@{#14646} --- webrtc/p2p/base/dtlstransport.h | 2 +- webrtc/p2p/base/dtlstransportchannel.cc | 12 +++++----- webrtc/p2p/base/dtlstransportchannel.h | 2 +- webrtc/p2p/base/faketransportcontroller.h | 8 +++---- webrtc/p2p/base/p2ptransport.h | 2 +- webrtc/p2p/base/relayserver.h | 2 +- webrtc/p2p/base/stunserver_unittest.cc | 6 ++--- webrtc/p2p/base/transport.h | 4 ++-- .../p2p/base/transportcontroller_unittest.cc | 20 ++++++++--------- webrtc/p2p/client/socketmonitor.cc | 22 +++++++++---------- webrtc/p2p/client/socketmonitor.h | 4 ++-- webrtc/p2p/quic/quictransportchannel.cc | 14 ++++++------ webrtc/p2p/quic/quictransportchannel.h | 2 +- 13 files changed, 50 insertions(+), 50 deletions(-) diff --git a/webrtc/p2p/base/dtlstransport.h b/webrtc/p2p/base/dtlstransport.h index a4bf383f0a..e59472d7f9 100644 --- a/webrtc/p2p/base/dtlstransport.h +++ b/webrtc/p2p/base/dtlstransport.h @@ -27,7 +27,7 @@ class PortAllocator; // Base should be a descendant of cricket::Transport and have a constructor // that takes a transport name and PortAllocator. // -// Everything in this class should be called on the worker thread. +// Everything in this class should be called on the network thread. template class DtlsTransport : public Base { public: diff --git a/webrtc/p2p/base/dtlstransportchannel.cc b/webrtc/p2p/base/dtlstransportchannel.cc index d95bdcd916..de543d6483 100644 --- a/webrtc/p2p/base/dtlstransportchannel.cc +++ b/webrtc/p2p/base/dtlstransportchannel.cc @@ -104,7 +104,7 @@ void StreamInterfaceChannel::Close() { DtlsTransportChannelWrapper::DtlsTransportChannelWrapper( TransportChannelImpl* channel) : TransportChannelImpl(channel->transport_name(), channel->component()), - worker_thread_(rtc::Thread::Current()), + network_thread_(rtc::Thread::Current()), channel_(channel), downward_(NULL), ssl_role_(rtc::SSL_CLIENT), @@ -438,7 +438,7 @@ bool DtlsTransportChannelWrapper::IsDtlsConnected() { // - Once the DTLS handshake completes, the state is that of the // impl again void DtlsTransportChannelWrapper::OnWritableState(TransportChannel* channel) { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); ASSERT(channel == channel_); LOG_J(LS_VERBOSE, this) << "DTLSTransportChannelWrapper: channel writable state changed to " @@ -470,7 +470,7 @@ void DtlsTransportChannelWrapper::OnWritableState(TransportChannel* channel) { } void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); ASSERT(channel == channel_); LOG_J(LS_VERBOSE, this) << "DTLSTransportChannelWrapper: channel receiving state changed to " @@ -484,7 +484,7 @@ void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { void DtlsTransportChannelWrapper::OnReadPacket( TransportChannel* channel, const char* data, size_t size, const rtc::PacketTime& packet_time, int flags) { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); ASSERT(channel == channel_); ASSERT(flags == 0); @@ -560,7 +560,7 @@ void DtlsTransportChannelWrapper::OnReadPacket( void DtlsTransportChannelWrapper::OnSentPacket( TransportChannel* channel, const rtc::SentPacket& sent_packet) { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); SignalSentPacket(this, sent_packet); } @@ -573,7 +573,7 @@ void DtlsTransportChannelWrapper::OnReadyToSend(TransportChannel* channel) { void DtlsTransportChannelWrapper::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); ASSERT(dtls == dtls_.get()); if (sig & rtc::SE_OPEN) { // This is the first time. diff --git a/webrtc/p2p/base/dtlstransportchannel.h b/webrtc/p2p/base/dtlstransportchannel.h index 5ab3dca771..81802fd21d 100644 --- a/webrtc/p2p/base/dtlstransportchannel.h +++ b/webrtc/p2p/base/dtlstransportchannel.h @@ -228,7 +228,7 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { void OnChannelStateChanged(TransportChannelImpl* channel); void OnDtlsHandshakeError(rtc::SSLHandshakeError error); - rtc::Thread* worker_thread_; // Everything should occur on this thread. + rtc::Thread* network_thread_; // Everything should occur on this thread. // Underlying channel, not owned by this class. TransportChannelImpl* const channel_; std::unique_ptr dtls_; // The DTLS stream diff --git a/webrtc/p2p/base/faketransportcontroller.h b/webrtc/p2p/base/faketransportcontroller.h index 573d571102..9598b822ce 100644 --- a/webrtc/p2p/base/faketransportcontroller.h +++ b/webrtc/p2p/base/faketransportcontroller.h @@ -530,12 +530,12 @@ class FakeTransportController : public TransportController { SetIceRole(role); } - explicit FakeTransportController(rtc::Thread* worker_thread) - : TransportController(rtc::Thread::Current(), worker_thread, nullptr), + explicit FakeTransportController(rtc::Thread* network_thread) + : TransportController(rtc::Thread::Current(), network_thread, nullptr), fail_create_channel_(false) {} - FakeTransportController(rtc::Thread* worker_thread, IceRole role) - : TransportController(rtc::Thread::Current(), worker_thread, nullptr), + FakeTransportController(rtc::Thread* network_thread, IceRole role) + : TransportController(rtc::Thread::Current(), network_thread, nullptr), fail_create_channel_(false) { SetIceRole(role); } diff --git a/webrtc/p2p/base/p2ptransport.h b/webrtc/p2p/base/p2ptransport.h index d4da224f97..87353356e2 100644 --- a/webrtc/p2p/base/p2ptransport.h +++ b/webrtc/p2p/base/p2ptransport.h @@ -18,7 +18,7 @@ namespace cricket { -// Everything in this class should be called on the worker thread. +// Everything in this class should be called on the network thread. class P2PTransport : public Transport { public: P2PTransport(const std::string& name, PortAllocator* allocator); diff --git a/webrtc/p2p/base/relayserver.h b/webrtc/p2p/base/relayserver.h index 7ee71d9f21..c60e2710b5 100644 --- a/webrtc/p2p/base/relayserver.h +++ b/webrtc/p2p/base/relayserver.h @@ -115,7 +115,7 @@ class RelayServer : public rtc::MessageHandler, void RemoveConnection(RelayServerConnection* conn); void RemoveBinding(RelayServerBinding* binding); - // Handle messages in our worker thread. + // Handle messages in our thread. void OnMessage(rtc::Message *pmsg); // Called when the timer for checking lifetime times out. diff --git a/webrtc/p2p/base/stunserver_unittest.cc b/webrtc/p2p/base/stunserver_unittest.cc index e468447005..553ad8a0a7 100644 --- a/webrtc/p2p/base/stunserver_unittest.cc +++ b/webrtc/p2p/base/stunserver_unittest.cc @@ -29,7 +29,7 @@ class StunServerTest : public testing::Test { StunServerTest() : pss_(new rtc::PhysicalSocketServer), ss_(new rtc::VirtualSocketServer(pss_.get())), - worker_(ss_.get()) { + network_(ss_.get()) { } virtual void SetUp() { server_.reset(new StunServer( @@ -37,7 +37,7 @@ class StunServerTest : public testing::Test { client_.reset(new rtc::TestClient( rtc::AsyncUDPSocket::Create(ss_.get(), client_addr))); - worker_.Start(); + network_.Start(); } void Send(const StunMessage& msg) { rtc::ByteBufferWriter buf; @@ -65,7 +65,7 @@ class StunServerTest : public testing::Test { private: std::unique_ptr pss_; std::unique_ptr ss_; - rtc::Thread worker_; + rtc::Thread network_; std::unique_ptr server_; std::unique_ptr client_; }; diff --git a/webrtc/p2p/base/transport.h b/webrtc/p2p/base/transport.h index c2767fb6f0..adef6533ea 100644 --- a/webrtc/p2p/base/transport.h +++ b/webrtc/p2p/base/transport.h @@ -15,8 +15,8 @@ // state changes (in order to update the manager's state), and forwards // requests to begin connecting or to reset to each of the channels. // -// On Threading: Transport performs work solely on the worker thread, and so -// its methods should only be called on the worker thread. +// On Threading: Transport performs work solely on the network thread, and so +// its methods should only be called on the network thread. // // Note: Subclasses must call DestroyChannels() in their own destructors. // It is not possible to do so here because the subclass destructor will diff --git a/webrtc/p2p/base/transportcontroller_unittest.cc b/webrtc/p2p/base/transportcontroller_unittest.cc index f44f831b0e..d1f3816af9 100644 --- a/webrtc/p2p/base/transportcontroller_unittest.cc +++ b/webrtc/p2p/base/transportcontroller_unittest.cc @@ -50,13 +50,13 @@ class TransportControllerTest : public testing::Test, ConnectTransportControllerSignals(); } - void CreateTransportControllerWithWorkerThread() { - if (!worker_thread_) { - worker_thread_.reset(new rtc::Thread()); - worker_thread_->Start(); + void CreateTransportControllerWithNetworkThread() { + if (!network_thread_) { + network_thread_ = rtc::Thread::CreateWithSocketServer(); + network_thread_->Start(); } transport_controller_.reset( - new TransportControllerForTest(worker_thread_.get())); + new TransportControllerForTest(network_thread_.get())); ConnectTransportControllerSignals(); } @@ -92,8 +92,8 @@ class TransportControllerTest : public testing::Test, } // Used for thread hopping test. - void CreateChannelsAndCompleteConnectionOnWorkerThread() { - worker_thread_->Invoke( + void CreateChannelsAndCompleteConnectionOnNetworkThread() { + network_thread_->Invoke( RTC_FROM_HERE, rtc::Bind( &TransportControllerTest::CreateChannelsAndCompleteConnection_w, @@ -174,7 +174,7 @@ class TransportControllerTest : public testing::Test, ++candidates_signal_count_; } - std::unique_ptr worker_thread_; // Not used for most tests. + std::unique_ptr network_thread_; // Not used for most tests. std::unique_ptr transport_controller_; // Information received from signals from transport controller. @@ -662,8 +662,8 @@ TEST_F(TransportControllerTest, TestSignalCandidatesGathered) { } TEST_F(TransportControllerTest, TestSignalingOccursOnSignalingThread) { - CreateTransportControllerWithWorkerThread(); - CreateChannelsAndCompleteConnectionOnWorkerThread(); + CreateTransportControllerWithNetworkThread(); + CreateChannelsAndCompleteConnectionOnNetworkThread(); // connecting --> connected --> completed EXPECT_EQ_WAIT(kIceConnectionCompleted, connection_state_, kTimeout); diff --git a/webrtc/p2p/client/socketmonitor.cc b/webrtc/p2p/client/socketmonitor.cc index 7975514d7e..7d553b93f6 100644 --- a/webrtc/p2p/client/socketmonitor.cc +++ b/webrtc/p2p/client/socketmonitor.cc @@ -22,16 +22,16 @@ enum { }; ConnectionMonitor::ConnectionMonitor(ConnectionStatsGetter* stats_getter, - rtc::Thread* worker_thread, + rtc::Thread* network_thread, rtc::Thread* monitoring_thread) { stats_getter_ = stats_getter; - worker_thread_ = worker_thread; + network_thread_ = network_thread; monitoring_thread_ = monitoring_thread; monitoring_ = false; } ConnectionMonitor::~ConnectionMonitor() { - worker_thread_->Clear(this); + network_thread_->Clear(this); monitoring_thread_->Clear(this); } @@ -39,18 +39,18 @@ void ConnectionMonitor::Start(int milliseconds) { rate_ = milliseconds; if (rate_ < 250) rate_ = 250; - worker_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_START); + network_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_START); } void ConnectionMonitor::Stop() { - worker_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_STOP); + network_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_STOP); } void ConnectionMonitor::OnMessage(rtc::Message *message) { rtc::CritScope cs(&crit_); switch (message->message_id) { case MSG_MONITOR_START: - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); if (!monitoring_) { monitoring_ = true; PollConnectionStats_w(); @@ -58,15 +58,15 @@ void ConnectionMonitor::OnMessage(rtc::Message *message) { break; case MSG_MONITOR_STOP: - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); if (monitoring_) { monitoring_ = false; - worker_thread_->Clear(this); + network_thread_->Clear(this); } break; case MSG_MONITOR_POLL: - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); PollConnectionStats_w(); break; @@ -82,7 +82,7 @@ void ConnectionMonitor::OnMessage(rtc::Message *message) { } void ConnectionMonitor::PollConnectionStats_w() { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); rtc::CritScope cs(&crit_); // Gather connection infos @@ -90,7 +90,7 @@ void ConnectionMonitor::PollConnectionStats_w() { // Signal the monitoring thread, start another poll timer monitoring_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_SIGNAL); - worker_thread_->PostDelayed(RTC_FROM_HERE, rate_, this, MSG_MONITOR_POLL); + network_thread_->PostDelayed(RTC_FROM_HERE, rate_, this, MSG_MONITOR_POLL); } } // namespace cricket diff --git a/webrtc/p2p/client/socketmonitor.h b/webrtc/p2p/client/socketmonitor.h index eb11516002..00190d9d44 100644 --- a/webrtc/p2p/client/socketmonitor.h +++ b/webrtc/p2p/client/socketmonitor.h @@ -33,7 +33,7 @@ class ConnectionMonitor : public rtc::MessageHandler, public sigslot::has_slots<> { public: ConnectionMonitor(ConnectionStatsGetter* stats_getter, - rtc::Thread* worker_thread, + rtc::Thread* network_thread, rtc::Thread* monitoring_thread); ~ConnectionMonitor(); @@ -50,7 +50,7 @@ public: std::vector connection_infos_; ConnectionStatsGetter* stats_getter_; - rtc::Thread* worker_thread_; + rtc::Thread* network_thread_; rtc::Thread* monitoring_thread_; rtc::CriticalSection crit_; uint32_t rate_; diff --git a/webrtc/p2p/quic/quictransportchannel.cc b/webrtc/p2p/quic/quictransportchannel.cc index 29819c6269..da0531aa77 100644 --- a/webrtc/p2p/quic/quictransportchannel.cc +++ b/webrtc/p2p/quic/quictransportchannel.cc @@ -126,9 +126,9 @@ namespace cricket { QuicTransportChannel::QuicTransportChannel(TransportChannelImpl* channel) : TransportChannelImpl(channel->transport_name(), channel->component()), - worker_thread_(rtc::Thread::Current()), + network_thread_(rtc::Thread::Current()), channel_(channel), - helper_(worker_thread_) { + helper_(network_thread_) { channel_->SignalWritableState.connect(this, &QuicTransportChannel::OnWritableState); channel_->SignalReadPacket.connect(this, &QuicTransportChannel::OnReadPacket); @@ -273,7 +273,7 @@ int QuicTransportChannel::SendPacket(const char* data, // - Once the QUIC handshake completes, the state is that of the // |channel_| again. void QuicTransportChannel::OnWritableState(TransportChannel* channel) { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); ASSERT(channel == channel_.get()); LOG_J(LS_VERBOSE, this) << "QuicTransportChannel: channel writable state changed to " @@ -307,7 +307,7 @@ void QuicTransportChannel::OnWritableState(TransportChannel* channel) { } void QuicTransportChannel::OnReceivingState(TransportChannel* channel) { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); ASSERT(channel == channel_.get()); LOG_J(LS_VERBOSE, this) << "QuicTransportChannel: channel receiving state changed to " @@ -323,7 +323,7 @@ void QuicTransportChannel::OnReadPacket(TransportChannel* channel, size_t size, const rtc::PacketTime& packet_time, int flags) { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); ASSERT(channel == channel_.get()); ASSERT(flags == 0); @@ -360,7 +360,7 @@ void QuicTransportChannel::OnReadPacket(TransportChannel* channel, void QuicTransportChannel::OnSentPacket(TransportChannel* channel, const rtc::SentPacket& sent_packet) { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); SignalSentPacket(this, sent_packet); } @@ -506,7 +506,7 @@ bool QuicTransportChannel::StartQuicHandshake() { } bool QuicTransportChannel::HandleQuicPacket(const char* data, size_t size) { - ASSERT(rtc::Thread::Current() == worker_thread_); + ASSERT(rtc::Thread::Current() == network_thread_); return quic_->OnReadPacket(data, size); } diff --git a/webrtc/p2p/quic/quictransportchannel.h b/webrtc/p2p/quic/quictransportchannel.h index f5a7910721..0e5af88e13 100644 --- a/webrtc/p2p/quic/quictransportchannel.h +++ b/webrtc/p2p/quic/quictransportchannel.h @@ -271,7 +271,7 @@ class QuicTransportChannel : public TransportChannelImpl, void set_quic_state(QuicTransportState state); // Everything should occur on this thread. - rtc::Thread* worker_thread_; + rtc::Thread* network_thread_; // Underlying channel which is responsible for connecting with the remote peer // and sending/receiving packets across the network. std::unique_ptr channel_;