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}
This commit is contained in:
johan 2016-10-17 00:54:57 -07:00 committed by Commit bot
parent 883ad662f4
commit 27c3d5b652
13 changed files with 50 additions and 50 deletions

View File

@ -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 Base>
class DtlsTransport : public Base {
public:

View File

@ -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.

View File

@ -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<rtc::SSLStreamAdapter> dtls_; // The DTLS stream

View File

@ -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);
}

View File

@ -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);

View File

@ -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.

View File

@ -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<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
rtc::Thread worker_;
rtc::Thread network_;
std::unique_ptr<StunServer> server_;
std::unique_ptr<rtc::TestClient> client_;
};

View File

@ -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

View File

@ -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>(
void CreateChannelsAndCompleteConnectionOnNetworkThread() {
network_thread_->Invoke<void>(
RTC_FROM_HERE,
rtc::Bind(
&TransportControllerTest::CreateChannelsAndCompleteConnection_w,
@ -174,7 +174,7 @@ class TransportControllerTest : public testing::Test,
++candidates_signal_count_;
}
std::unique_ptr<rtc::Thread> worker_thread_; // Not used for most tests.
std::unique_ptr<rtc::Thread> network_thread_; // Not used for most tests.
std::unique_ptr<TransportControllerForTest> 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);

View File

@ -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

View File

@ -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<ConnectionInfo> connection_infos_;
ConnectionStatsGetter* stats_getter_;
rtc::Thread* worker_thread_;
rtc::Thread* network_thread_;
rtc::Thread* monitoring_thread_;
rtc::CriticalSection crit_;
uint32_t rate_;

View File

@ -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);
}

View File

@ -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<TransportChannelImpl> channel_;