Reland of Make the default ctor of rtc::Thread, protected
This is a partial re-land. The change doesn't make the default Thread ctor protected anymore but it does mark it as deprecated and updates all use of it in WebRTC.
Original issue's description:
Make the default ctor of rtc::Thread, protected.
The goal is to force use of Thread::Create or Thread::CreateWithSocketServer.
The default constructor constructs a 'default' socket server, which is usually a 'physical' socket server, but not always. Not every instance of Thread actually needs to have network support, so it's better to have this be explicit instead of unknowingly instantiate one.
BUG=none
Review-Url: https://codereview.webrtc.org/2977953002
Cr-Commit-Position: refs/heads/master@{#19031}
diff --git a/webrtc/pc/rtcstats_integrationtest.cc b/webrtc/pc/rtcstats_integrationtest.cc
index ea1f8df..a385d6c 100644
--- a/webrtc/pc/rtcstats_integrationtest.cc
+++ b/webrtc/pc/rtcstats_integrationtest.cc
@@ -34,14 +34,15 @@
class RTCStatsIntegrationTest : public testing::Test {
public:
RTCStatsIntegrationTest()
- : network_thread_(&virtual_socket_server_), worker_thread_() {
- RTC_CHECK(network_thread_.Start());
- RTC_CHECK(worker_thread_.Start());
+ : network_thread_(new rtc::Thread(&virtual_socket_server_)),
+ worker_thread_(rtc::Thread::Create()) {
+ RTC_CHECK(network_thread_->Start());
+ RTC_CHECK(worker_thread_->Start());
caller_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>(
- "caller", &network_thread_, &worker_thread_);
+ "caller", network_thread_.get(), worker_thread_.get());
callee_ = new rtc::RefCountedObject<PeerConnectionTestWrapper>(
- "callee", &network_thread_, &worker_thread_);
+ "callee", network_thread_.get(), worker_thread_.get());
}
void StartCall() {
@@ -96,8 +97,8 @@
// |network_thread_| uses |virtual_socket_server_| so they must be
// constructed/destructed in the correct order.
rtc::VirtualSocketServer virtual_socket_server_;
- rtc::Thread network_thread_;
- rtc::Thread worker_thread_;
+ std::unique_ptr<rtc::Thread> network_thread_;
+ std::unique_ptr<rtc::Thread> worker_thread_;
rtc::scoped_refptr<PeerConnectionTestWrapper> caller_;
rtc::scoped_refptr<PeerConnectionTestWrapper> callee_;
};