Revert "Delete deprecated rtc::Thread default constructor"
This reverts commit fdd6d3e46e22e1242aa4acd7aa0271a7562fb0ac.
Reason for revert: Seems to be be breaking downstream project.
Original change's description:
> Delete deprecated rtc::Thread default constructor
>
> Bug: None
> Change-Id: Ic0e2e94b174a49e5d20ebdea90568473e1b71d62
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/134640
> Reviewed-by: Tommi <tommi@webrtc.org>
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#27958}
TBR=nisse@webrtc.org,tommi@webrtc.org
Change-Id: Id8015805c28c08e5e5d97c0cdef3c17d6d281fb5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: None
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137042
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27959}
diff --git a/examples/unityplugin/simple_peer_connection.cc b/examples/unityplugin/simple_peer_connection.cc
index ed89489..536bf86 100644
--- a/examples/unityplugin/simple_peer_connection.cc
+++ b/examples/unityplugin/simple_peer_connection.cc
@@ -122,9 +122,9 @@
RTC_DCHECK(peer_connection_.get() == nullptr);
if (g_peer_connection_factory == nullptr) {
- g_worker_thread = rtc::Thread::Create();
+ g_worker_thread.reset(new rtc::Thread());
g_worker_thread->Start();
- g_signaling_thread = rtc::Thread::Create();
+ g_signaling_thread.reset(new rtc::Thread());
g_signaling_thread->Start();
g_peer_connection_factory = webrtc::CreatePeerConnectionFactory(
diff --git a/rtc_base/signal_thread_unittest.cc b/rtc_base/signal_thread_unittest.cc
index f03991b..c333ff7 100644
--- a/rtc_base/signal_thread_unittest.cc
+++ b/rtc_base/signal_thread_unittest.cc
@@ -10,11 +10,10 @@
#include <memory>
-#include "absl/memory/memory.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/gunit.h"
-#include "rtc_base/null_socket_server.h"
#include "rtc_base/signal_thread.h"
+#include "rtc_base/socket_server.h"
#include "rtc_base/thread.h"
#include "test/gtest.h"
@@ -130,9 +129,7 @@
class OwnerThread : public Thread, public sigslot::has_slots<> {
public:
explicit OwnerThread(SignalThreadTest* harness)
- : Thread(absl::make_unique<NullSocketServer>()),
- harness_(harness),
- has_run_(false) {}
+ : harness_(harness), has_run_(false) {}
~OwnerThread() override { Stop(); }
diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc
index be0d15d..936871c 100644
--- a/rtc_base/thread.cc
+++ b/rtc_base/thread.cc
@@ -155,6 +155,9 @@
thread_->SetAllowBlockingCalls(previous_state_);
}
+// DEPRECATED.
+Thread::Thread() : Thread(SocketServer::CreateDefault()) {}
+
Thread::Thread(SocketServer* ss) : Thread(ss, /*do_init=*/true) {}
Thread::Thread(std::unique_ptr<SocketServer> ss)
diff --git a/rtc_base/thread.h b/rtc_base/thread.h
index 738a243..80720e0 100644
--- a/rtc_base/thread.h
+++ b/rtc_base/thread.h
@@ -128,6 +128,13 @@
class RTC_LOCKABLE Thread : public MessageQueue {
public:
+ // DEPRECATED.
+ // The default constructor should not be used because it hides whether or
+ // not a socket server will be associated with the thread. Most instances
+ // of Thread do actually not need one, so please use either of the Create*
+ // methods to construct an instance of Thread.
+ Thread();
+
explicit Thread(SocketServer* ss);
explicit Thread(std::unique_ptr<SocketServer> ss);
// Constructors meant for subclasses; they should call DoInit themselves and
diff --git a/rtc_base/thread_unittest.cc b/rtc_base/thread_unittest.cc
index c4b6143..800f1b1 100644
--- a/rtc_base/thread_unittest.cc
+++ b/rtc_base/thread_unittest.cc
@@ -10,7 +10,6 @@
#include <memory>
-#include "absl/memory/memory.h"
#include "rtc_base/async_invoker.h"
#include "rtc_base/async_udp_socket.h"
#include "rtc_base/event.h"
@@ -514,7 +513,7 @@
bool reentrant_functor_run = false;
Thread* main = Thread::Current();
- Thread thread(absl::make_unique<NullSocketServer>());
+ Thread thread;
thread.Start();
{
AsyncInvoker invoker;