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/rtc_base/timeutils_unittest.cc b/webrtc/rtc_base/timeutils_unittest.cc index 5fd9436..a409fb6 100644 --- a/webrtc/rtc_base/timeutils_unittest.cc +++ b/webrtc/rtc_base/timeutils_unittest.cc
@@ -349,8 +349,8 @@ FakeClock clock; SetClockForTesting(&clock); - Thread worker; - worker.Start(); + std::unique_ptr<Thread> worker(Thread::CreateWithSocketServer()); + worker->Start(); // Post an event that won't be executed for 10 seconds. Event message_handler_dispatched(false, false); @@ -358,7 +358,7 @@ message_handler_dispatched.Set(); }; FunctorMessageHandler<void, decltype(functor)> handler(functor); - worker.PostDelayed(RTC_FROM_HERE, 60000, &handler); + worker->PostDelayed(RTC_FROM_HERE, 60000, &handler); // Wait for a bit for the worker thread to be started and enter its socket // select(). Otherwise this test would be trivial since the worker thread @@ -369,7 +369,7 @@ // and dispatch the message instantly. clock.AdvanceTime(TimeDelta::FromSeconds(60u)); EXPECT_TRUE(message_handler_dispatched.Wait(0)); - worker.Stop(); + worker->Stop(); SetClockForTesting(nullptr);