Revert "Using simulated rtc::Thread for peer connection scenario tests."

This reverts commit b70c5c5ce97e7dcf2e1d8453f5ea0639d4b60453.

Reason for revert: Interferes with other tests in same binary.

Original change's description:
> Using simulated rtc::Thread for peer connection scenario tests.
> 
> Bug: webrtc:11255
> Change-Id: I5d29e997a7209ffc64595082358cca9b2115d07a
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165689
> Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> Reviewed-by: Steve Anton <steveanton@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#30258}

TBR=steveanton@webrtc.org,srte@webrtc.org

Change-Id: If2e60edae264a4bb0dee3abf66ba2078fd85f493
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:11255
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166045
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30259}
diff --git a/api/DEPS b/api/DEPS
index bac4232..a86b42f 100644
--- a/api/DEPS
+++ b/api/DEPS
@@ -265,10 +265,6 @@
     "+rtc_base/thread_checker.h",
   ],
 
-  "time_controller\.h": [
-    "+rtc_base/thread.h",
-  ],
-
   "videocodec_test_fixture\.h": [
     "+modules/video_coding/include/video_codec_interface.h"
   ],
diff --git a/api/test/time_controller.h b/api/test/time_controller.h
index dab44be..70aabda 100644
--- a/api/test/time_controller.h
+++ b/api/test/time_controller.h
@@ -12,14 +12,12 @@
 
 #include <functional>
 #include <memory>
-#include <string>
 
 #include "api/task_queue/task_queue_factory.h"
 #include "api/units/time_delta.h"
 #include "api/units/timestamp.h"
 #include "modules/utility/include/process_thread.h"
 #include "rtc_base/synchronization/yield_policy.h"
-#include "rtc_base/thread.h"
 #include "system_wrappers/include/clock.h"
 
 namespace webrtc {
@@ -39,11 +37,6 @@
   // Creates a process thread.
   virtual std::unique_ptr<ProcessThread> CreateProcessThread(
       const char* thread_name) = 0;
-  // Creates an rtc::Thread instance. If |socket_server| is nullptr, a default
-  // noop socket server is created.
-  virtual std::unique_ptr<rtc::Thread> CreateThread(
-      const std::string& name,
-      std::unique_ptr<rtc::SocketServer> socket_server = nullptr) = 0;
   // Allow task queues and process threads created by this instance to execute
   // for the given |duration|.
   virtual void AdvanceTime(TimeDelta duration) = 0;
diff --git a/test/network/emulated_network_manager.cc b/test/network/emulated_network_manager.cc
index 2dc2fad..a3b1691 100644
--- a/test/network/emulated_network_manager.cc
+++ b/test/network/emulated_network_manager.cc
@@ -20,16 +20,18 @@
 namespace test {
 
 EmulatedNetworkManager::EmulatedNetworkManager(
-    TimeController* time_controller,
+    Clock* clock,
     TaskQueueForTest* task_queue,
     EndpointsContainer* endpoints_container)
     : task_queue_(task_queue),
       endpoints_container_(endpoints_container),
-      network_thread_(time_controller->CreateThread(
-          "net_thread",
+      network_thread_(std::make_unique<rtc::Thread>(
           std::make_unique<FakeNetworkSocketServer>(endpoints_container))),
       sent_first_update_(false),
-      start_count_(0) {}
+      start_count_(0) {
+  network_thread_->SetName("net_thread", nullptr);
+  network_thread_->Start();
+}
 
 void EmulatedNetworkManager::EnableEndpoint(EmulatedEndpointImpl* endpoint) {
   RTC_CHECK(endpoints_container_->HasEndpoint(endpoint))
diff --git a/test/network/emulated_network_manager.h b/test/network/emulated_network_manager.h
index 92555ee..951ed91 100644
--- a/test/network/emulated_network_manager.h
+++ b/test/network/emulated_network_manager.h
@@ -15,7 +15,6 @@
 #include <vector>
 
 #include "api/test/network_emulation_manager.h"
-#include "api/test/time_controller.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/ip_address.h"
 #include "rtc_base/network.h"
@@ -32,7 +31,7 @@
                                public sigslot::has_slots<>,
                                public EmulatedNetworkManagerInterface {
  public:
-  EmulatedNetworkManager(TimeController* time_controller,
+  EmulatedNetworkManager(Clock* clock,
                          TaskQueueForTest* task_queue,
                          EndpointsContainer* endpoints_container);
 
diff --git a/test/network/network_emulation_manager.cc b/test/network/network_emulation_manager.cc
index 494e885..77ac460 100644
--- a/test/network/network_emulation_manager.cc
+++ b/test/network/network_emulation_manager.cc
@@ -34,8 +34,7 @@
 
 NetworkEmulationManagerImpl::NetworkEmulationManagerImpl(
     TimeController* time_controller)
-    : time_controller_(time_controller),
-      clock_(time_controller->GetClock()),
+    : clock_(time_controller->GetClock()),
       next_node_id_(1),
       next_ip4_address_(kMinIPv4Address),
       task_queue_(time_controller->GetTaskQueueFactory()->CreateTaskQueue(
@@ -266,7 +265,7 @@
   auto endpoints_container =
       std::make_unique<EndpointsContainer>(endpoint_impls);
   auto network_manager = std::make_unique<EmulatedNetworkManager>(
-      time_controller_, &task_queue_, endpoints_container.get());
+      clock_, &task_queue_, endpoints_container.get());
   for (auto* endpoint : endpoints) {
     // Associate endpoint with network manager.
     bool insertion_result =
diff --git a/test/network/network_emulation_manager.h b/test/network/network_emulation_manager.h
index 25c8050..d640ea2 100644
--- a/test/network/network_emulation_manager.h
+++ b/test/network/network_emulation_manager.h
@@ -88,7 +88,6 @@
   absl::optional<rtc::IPAddress> GetNextIPv4Address();
   Timestamp Now() const;
 
-  TimeController* const time_controller_;
   Clock* const clock_;
   int next_node_id_;
 
diff --git a/test/peer_scenario/BUILD.gn b/test/peer_scenario/BUILD.gn
index 9faff92..a4e2c79 100644
--- a/test/peer_scenario/BUILD.gn
+++ b/test/peer_scenario/BUILD.gn
@@ -30,14 +30,12 @@
       "../../api:libjingle_peerconnection_api",
       "../../api:network_emulation_manager_api",
       "../../api:rtc_stats_api",
-      "../../api:time_controller",
       "../../api/audio_codecs:builtin_audio_decoder_factory",
       "../../api/audio_codecs:builtin_audio_encoder_factory",
       "../../api/rtc_event_log:rtc_event_log_factory",
       "../../api/task_queue:default_task_queue_factory",
       "../../api/video_codecs:builtin_video_decoder_factory",
       "../../api/video_codecs:builtin_video_encoder_factory",
-      "../../call:call_interfaces",
       "../../media:rtc_audio_video",
       "../../media:rtc_media_base",
       "../../modules/audio_device:audio_device_impl",
@@ -45,12 +43,10 @@
       "../../p2p:rtc_p2p",
       "../../pc:pc_test_utils",
       "../../pc:rtc_pc_base",
-      "../../rtc_base",
       "../../rtc_base:stringutils",
       "..//network:emulated_network",
       "../logging:log_writer",
       "../scenario",
-      "../time_controller",
       "//third_party/abseil-cpp/absl/flags:flag",
       "//third_party/abseil-cpp/absl/memory",
     ]
diff --git a/test/peer_scenario/peer_scenario.cc b/test/peer_scenario/peer_scenario.cc
index 31c23e6..098971c 100644
--- a/test/peer_scenario/peer_scenario.cc
+++ b/test/peer_scenario/peer_scenario.cc
@@ -11,13 +11,10 @@
 
 #include "absl/flags/flag.h"
 #include "absl/memory/memory.h"
-#include "rtc_base/null_socket_server.h"
 #include "rtc_base/string_encode.h"
 #include "rtc_base/strings/string_builder.h"
 #include "test/logging/file_log_writer.h"
 #include "test/testsupport/file_utils.h"
-#include "test/time_controller/real_time_controller.h"
-#include "test/time_controller/simulated_time_controller.h"
 
 ABSL_FLAG(bool, peer_logs, false, "Save logs from peer scenario framework.");
 ABSL_FLAG(std::string,
@@ -41,44 +38,19 @@
   }
   return nullptr;
 }
-
-std::unique_ptr<TimeController> CreateTimeController(bool real_time) {
-  if (real_time) {
-    return std::make_unique<RealTimeController>();
-  } else {
-    // Using an offset of 100000 to get nice fixed width and readable timestamps
-    // in typical test scenarios.
-    const Timestamp kSimulatedStartTime = Timestamp::seconds(100000);
-    return std::make_unique<GlobalSimulatedTimeController>(kSimulatedStartTime);
-  }
-}
 }  // namespace
 
-PeerScenario::PeerScenario(const testing::TestInfo& test_info, bool real_time)
-    : PeerScenario(
-          std::string(test_info.test_suite_name()) + "/" + test_info.name(),
-          real_time) {}
+PeerScenario::PeerScenario(const testing::TestInfo& test_info)
+    : PeerScenario(std::string(test_info.test_suite_name()) + "/" +
+                   test_info.name()) {}
 
-PeerScenario::PeerScenario(std::string file_name, bool real_time)
-    : PeerScenario(GetPeerScenarioLogManager(file_name), real_time) {}
+PeerScenario::PeerScenario(std::string file_name)
+    : PeerScenario(GetPeerScenarioLogManager(file_name)) {}
 
 PeerScenario::PeerScenario(
-    std::unique_ptr<LogWriterFactoryInterface> log_writer_manager,
-    bool real_time)
-    : time_controller_(CreateTimeController(real_time)),
-      simulated_thread_(
-          // Using main thread for signaling in real time tests simplifies
-          // access in test body.
-          real_time ? nullptr : time_controller_->CreateThread("SigThread")),
-      signaling_thread_(simulated_thread_ ? simulated_thread_.get()
-                                          : rtc::Thread::Current()),
-      current_task_queue_setter_(signaling_thread_),
-      log_writer_manager_(std::move(log_writer_manager)),
-      net_(time_controller_.get()) {
-  if (simulated_thread_)
-    rtc::ThreadManager::Instance()->ChangeCurrentThreadForTest(
-        signaling_thread_);
-}
+    std::unique_ptr<LogWriterFactoryInterface> log_writer_manager)
+    : signaling_thread_(rtc::Thread::Current()),
+      log_writer_manager_(std::move(log_writer_manager)) {}
 
 PeerScenarioClient* PeerScenario::CreateClient(
     PeerScenarioClient::Config config) {
@@ -89,8 +61,8 @@
 PeerScenarioClient* PeerScenario::CreateClient(
     std::string name,
     PeerScenarioClient::Config config) {
-  peer_clients_.emplace_back(net(), time_controller_.get(), thread(),
-                             GetLogWriterFactory(name), config);
+  peer_clients_.emplace_back(net(), thread(), GetLogWriterFactory(name),
+                             config);
   return &peer_clients_.back();
 }
 
@@ -134,11 +106,7 @@
     return true;
   for (auto elapsed = TimeDelta::Zero(); elapsed < max_duration;
        elapsed += kStep) {
-    if (simulated_thread_) {
-      time_controller_->AdvanceTime(kStep);
-    } else {
-      thread()->ProcessMessages(kStep.ms());
-    }
+    thread()->ProcessMessages(kStep.ms());
     if (*event)
       return true;
   }
@@ -146,11 +114,7 @@
 }
 
 void PeerScenario::ProcessMessages(TimeDelta duration) {
-  if (simulated_thread_) {
-    time_controller_->AdvanceTime(duration);
-  } else {
-    thread()->ProcessMessages(duration.ms());
-  }
+  thread()->ProcessMessages(duration.ms());
 }
 
 std::unique_ptr<LogWriterFactoryInterface> PeerScenario::GetLogWriterFactory(
diff --git a/test/peer_scenario/peer_scenario.h b/test/peer_scenario/peer_scenario.h
index 3127a3a..4a1759a 100644
--- a/test/peer_scenario/peer_scenario.h
+++ b/test/peer_scenario/peer_scenario.h
@@ -21,7 +21,6 @@
 #include <list>
 #include <vector>
 
-#include "api/test/time_controller.h"
 #include "test/gtest.h"
 #include "test/logging/log_writer.h"
 #include "test/network/network_emulation_manager.h"
@@ -32,6 +31,7 @@
 
 namespace webrtc {
 namespace test {
+
 // The PeerScenario class represents a PeerConnection simulation scenario. The
 // main purpose is to maintain ownership and ensure safe destruction order of
 // clients and network emulation. Additionally it reduces the amount of boiler
@@ -46,12 +46,10 @@
   // The name is used for log output when those are enabled by the --peer_logs
   // command line flag. Optionally, the TestInfo struct available in gtest can
   // be used to automatically generate a path based on the test name.
-  explicit PeerScenario(const testing::TestInfo& test_info,
-                        bool real_time = false);
-  explicit PeerScenario(std::string file_name, bool real_time = false);
+  explicit PeerScenario(const testing::TestInfo& test_info);
+  explicit PeerScenario(std::string file_name);
   explicit PeerScenario(
-      std::unique_ptr<LogWriterFactoryInterface> log_writer_manager,
-      bool real_time = false);
+      std::unique_ptr<LogWriterFactoryInterface> log_writer_manager);
 
   NetworkEmulationManagerImpl* net() { return &net_; }
   rtc::Thread* thread() { return signaling_thread_; }
@@ -104,24 +102,12 @@
     CapturedFrameTap capture_tap_;
     DecodedFrameTap decode_tap_;
   };
-  // Workaround to allow overriding the task queue, this is needed to satisfy
-  // thread checkers that might be accessed both from the main thread for
-  // instance in the test body and from a a task running on the main
-  // rtc::Thread.
-  class Exposer : TaskQueueBase {
-   public:
-    using TaskQueueBase::CurrentTaskQueueSetter;
-  };
-
   Clock* clock() { return Clock::GetRealTimeClock(); }
 
   std::unique_ptr<LogWriterFactoryInterface> GetLogWriterFactory(
       std::string name);
 
-  const std::unique_ptr<TimeController> time_controller_;
-  const std::unique_ptr<rtc::Thread> simulated_thread_;
   rtc::Thread* const signaling_thread_;
-  Exposer::CurrentTaskQueueSetter current_task_queue_setter_;
   const std::unique_ptr<LogWriterFactoryInterface> log_writer_manager_;
   std::list<PeerVideoQualityPair> video_quality_pairs_;
   NetworkEmulationManagerImpl net_;
diff --git a/test/peer_scenario/peer_scenario_client.cc b/test/peer_scenario/peer_scenario_client.cc
index 0ee709e..782cd21 100644
--- a/test/peer_scenario/peer_scenario_client.cc
+++ b/test/peer_scenario/peer_scenario_client.cc
@@ -19,7 +19,6 @@
 #include "api/task_queue/default_task_queue_factory.h"
 #include "api/video_codecs/builtin_video_decoder_factory.h"
 #include "api/video_codecs/builtin_video_encoder_factory.h"
-#include "call/call.h"
 #include "media/engine/webrtc_media_engine.h"
 #include "modules/audio_device/include/test_audio_device.h"
 #include "p2p/client/basic_port_allocator.h"
@@ -113,51 +112,22 @@
  private:
   PeerScenarioClient::CallbackHandlers* handlers_;
 };
-
-// Used to supply a unique_ptr for an unowned TaskQueueFactory.
-class TaskQueueFactoryWrapper final : public TaskQueueFactory {
- public:
-  explicit TaskQueueFactoryWrapper(TaskQueueFactory* inner_factory)
-      : inner_factory_(inner_factory) {}
-  std::unique_ptr<TaskQueueBase, TaskQueueDeleter> CreateTaskQueue(
-      absl::string_view name,
-      Priority priority) const override {
-    return inner_factory_->CreateTaskQueue(name, priority);
-  }
-
- private:
-  TaskQueueFactory* const inner_factory_;
-};
-
-class TimeControllerBasedCallFactory : public CallFactoryInterface {
- public:
-  explicit TimeControllerBasedCallFactory(TimeController* time_controller)
-      : time_controller_(time_controller) {}
-  Call* CreateCall(const Call::Config& config) override {
-    return Call::Create(config, time_controller_->GetClock(),
-                        time_controller_->CreateProcessThread("CallModules"),
-                        time_controller_->CreateProcessThread("Pacer"));
-  }
-
- private:
-  TimeController* time_controller_;
-};
-
 }  // namespace
 
 PeerScenarioClient::PeerScenarioClient(
     NetworkEmulationManager* net,
-    TimeController* time_controller,
     rtc::Thread* signaling_thread,
     std::unique_ptr<LogWriterFactoryInterface> log_writer_factory,
     PeerScenarioClient::Config config)
     : endpoints_(CreateEndpoints(net, config.endpoints)),
-      task_queue_factory_(time_controller->GetTaskQueueFactory()),
       signaling_thread_(signaling_thread),
       log_writer_factory_(std::move(log_writer_factory)),
-      worker_thread_(time_controller->CreateThread("worker")),
+      worker_thread_(rtc::Thread::Create()),
       handlers_(config.handlers),
       observer_(new LambdaPeerConnectionObserver(&handlers_)) {
+  worker_thread_->SetName("worker", this);
+  worker_thread_->Start();
+
   handlers_.on_track.push_back(
       [this](rtc::scoped_refptr<RtpTransceiverInterface> transceiver) {
         auto track = transceiver->receiver()->track().get();
@@ -190,10 +160,9 @@
   pcf_deps.network_thread = manager->network_thread();
   pcf_deps.signaling_thread = signaling_thread_;
   pcf_deps.worker_thread = worker_thread_.get();
-  pcf_deps.call_factory =
-      std::make_unique<TimeControllerBasedCallFactory>(time_controller);
-  pcf_deps.task_queue_factory =
-      std::make_unique<TaskQueueFactoryWrapper>(task_queue_factory_);
+  pcf_deps.call_factory = CreateCallFactory();
+  pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory();
+  task_queue_factory_ = pcf_deps.task_queue_factory.get();
   pcf_deps.event_log_factory =
       std::make_unique<RtcEventLogFactory>(task_queue_factory_);
 
diff --git a/test/peer_scenario/peer_scenario_client.h b/test/peer_scenario/peer_scenario_client.h
index e9b86e2..61a7741 100644
--- a/test/peer_scenario/peer_scenario_client.h
+++ b/test/peer_scenario/peer_scenario_client.h
@@ -20,7 +20,6 @@
 #include "absl/memory/memory.h"
 #include "api/peer_connection_interface.h"
 #include "api/test/network_emulation_manager.h"
-#include "api/test/time_controller.h"
 #include "pc/test/frame_generator_capturer_video_track_source.h"
 #include "test/logging/log_writer.h"
 
@@ -108,7 +107,6 @@
 
   PeerScenarioClient(
       NetworkEmulationManager* net,
-      TimeController* time_controller,
       rtc::Thread* signaling_thread,
       std::unique_ptr<LogWriterFactoryInterface> log_writer_factory,
       Config config);
@@ -149,7 +147,7 @@
 
  private:
   const std::map<int, EmulatedEndpoint*> endpoints_;
-  TaskQueueFactory* const task_queue_factory_;
+  TaskQueueFactory* task_queue_factory_;
   rtc::Thread* const signaling_thread_;
   const std::unique_ptr<LogWriterFactoryInterface> log_writer_factory_;
   const std::unique_ptr<rtc::Thread> worker_thread_;
diff --git a/test/time_controller/BUILD.gn b/test/time_controller/BUILD.gn
index 5a159c7..acb2ccb 100644
--- a/test/time_controller/BUILD.gn
+++ b/test/time_controller/BUILD.gn
@@ -20,8 +20,6 @@
       "simulated_process_thread.h",
       "simulated_task_queue.cc",
       "simulated_task_queue.h",
-      "simulated_thread.cc",
-      "simulated_thread.h",
       "simulated_time_controller.cc",
       "simulated_time_controller.h",
     ]
@@ -35,7 +33,6 @@
       "../../modules:module_api",
       "../../modules/utility:utility",
       "../../rtc_base",
-      "../../rtc_base:checks",
       "../../rtc_base:rtc_base_tests_utils",
       "../../rtc_base:rtc_event",
       "../../rtc_base/synchronization:sequence_checker",
diff --git a/test/time_controller/external_time_controller.cc b/test/time_controller/external_time_controller.cc
index 2984caa..bb60d89 100644
--- a/test/time_controller/external_time_controller.cc
+++ b/test/time_controller/external_time_controller.cc
@@ -21,7 +21,6 @@
 #include "api/units/timestamp.h"
 #include "modules/include/module.h"
 #include "modules/utility/include/process_thread.h"
-#include "rtc_base/checks.h"
 #include "rtc_base/synchronization/yield_policy.h"
 #include "test/time_controller/simulated_time_controller.h"
 
@@ -185,13 +184,6 @@
   alarm_->Sleep(duration);
 }
 
-std::unique_ptr<rtc::Thread> ExternalTimeController::CreateThread(
-    const std::string& name,
-    std::unique_ptr<rtc::SocketServer> socket_server) {
-  RTC_NOTREACHED();
-  return nullptr;
-}
-
 std::unique_ptr<TaskQueueBase, TaskQueueDeleter>
 ExternalTimeController::CreateTaskQueue(
     absl::string_view name,
diff --git a/test/time_controller/external_time_controller.h b/test/time_controller/external_time_controller.h
index d4cfa90..869a78f 100644
--- a/test/time_controller/external_time_controller.h
+++ b/test/time_controller/external_time_controller.h
@@ -38,9 +38,6 @@
   std::unique_ptr<ProcessThread> CreateProcessThread(
       const char* thread_name) override;
   void AdvanceTime(TimeDelta duration) override;
-  std::unique_ptr<rtc::Thread> CreateThread(
-      const std::string& name,
-      std::unique_ptr<rtc::SocketServer> socket_server) override;
 
   // Implementation of TaskQueueFactory.
   std::unique_ptr<TaskQueueBase, TaskQueueDeleter> CreateTaskQueue(
diff --git a/test/time_controller/real_time_controller.cc b/test/time_controller/real_time_controller.cc
index e792ef9..732f1bd 100644
--- a/test/time_controller/real_time_controller.cc
+++ b/test/time_controller/real_time_controller.cc
@@ -10,7 +10,6 @@
 #include "test/time_controller/real_time_controller.h"
 
 #include "api/task_queue/default_task_queue_factory.h"
-#include "rtc_base/null_socket_server.h"
 #include "system_wrappers/include/sleep.h"
 
 namespace webrtc {
@@ -31,17 +30,6 @@
   return ProcessThread::Create(thread_name);
 }
 
-std::unique_ptr<rtc::Thread> RealTimeController::CreateThread(
-    const std::string& name,
-    std::unique_ptr<rtc::SocketServer> socket_server) {
-  if (!socket_server)
-    socket_server = std::make_unique<rtc::NullSocketServer>();
-  auto res = std::make_unique<rtc::Thread>(std::move(socket_server));
-  res->SetName(name, nullptr);
-  res->Start();
-  return res;
-}
-
 void RealTimeController::AdvanceTime(TimeDelta duration) {
   SleepMs(duration.ms());
 }
diff --git a/test/time_controller/real_time_controller.h b/test/time_controller/real_time_controller.h
index a85a4c4..873ef90 100644
--- a/test/time_controller/real_time_controller.h
+++ b/test/time_controller/real_time_controller.h
@@ -28,9 +28,6 @@
   TaskQueueFactory* GetTaskQueueFactory() override;
   std::unique_ptr<ProcessThread> CreateProcessThread(
       const char* thread_name) override;
-  std::unique_ptr<rtc::Thread> CreateThread(
-      const std::string& name,
-      std::unique_ptr<rtc::SocketServer> socket_server) override;
   void AdvanceTime(TimeDelta duration) override;
 
  private:
diff --git a/test/time_controller/simulated_thread.cc b/test/time_controller/simulated_thread.cc
deleted file mode 100644
index c18d8bf..0000000
--- a/test/time_controller/simulated_thread.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- *  Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-#include "test/time_controller/simulated_thread.h"
-
-#include <algorithm>
-#include <utility>
-
-#include "rtc_base/task_utils/to_queued_task.h"
-
-namespace webrtc {
-namespace {
-
-// A socket server that does nothing. It's different from NullSocketServer in
-// that it does allow sleep/wakeup. This avoids usage of an Event instance which
-// otherwise would cause issues with the simulated Yeild behavior.
-class DummySocketServer : public rtc::SocketServer {
- public:
-  rtc::Socket* CreateSocket(int family, int type) override {
-    RTC_NOTREACHED();
-    return nullptr;
-  }
-  rtc::AsyncSocket* CreateAsyncSocket(int family, int type) override {
-    RTC_NOTREACHED();
-    return nullptr;
-  }
-  bool Wait(int cms, bool process_io) override {
-    RTC_CHECK_EQ(cms, 0);
-    return true;
-  }
-  void WakeUp() override {}
-};
-
-}  // namespace
-
-SimulatedThread::SimulatedThread(
-    sim_time_impl::SimulatedTimeControllerImpl* handler,
-    absl::string_view name,
-    std::unique_ptr<rtc::SocketServer> socket_server)
-    : rtc::Thread(socket_server ? std::move(socket_server)
-                                : std::make_unique<DummySocketServer>()),
-      handler_(handler),
-      name_(new char[name.size()]) {
-  std::copy_n(name.begin(), name.size(), name_);
-}
-
-SimulatedThread::~SimulatedThread() {
-  handler_->Unregister(this);
-  delete[] name_;
-}
-
-void SimulatedThread::RunReady(Timestamp at_time) {
-  CurrentThreadSetter set_current(this);
-  ProcessMessages(0);
-  int delay_ms = GetDelay();
-  rtc::CritScope lock(&lock_);
-  if (delay_ms == kForever) {
-    next_run_time_ = Timestamp::PlusInfinity();
-  } else {
-    next_run_time_ = at_time + TimeDelta::ms(delay_ms);
-  }
-}
-
-void SimulatedThread::Send(const rtc::Location& posted_from,
-                           rtc::MessageHandler* phandler,
-                           uint32_t id,
-                           rtc::MessageData* pdata) {
-  if (IsQuitting())
-    return;
-  rtc::Message msg;
-  msg.posted_from = posted_from;
-  msg.phandler = phandler;
-  msg.message_id = id;
-  msg.pdata = pdata;
-  if (IsCurrent()) {
-    msg.phandler->OnMessage(&msg);
-  } else {
-    CurrentThreadSetter set_current(this);
-    msg.phandler->OnMessage(&msg);
-  }
-}
-
-void SimulatedThread::Post(const rtc::Location& posted_from,
-                           rtc::MessageHandler* phandler,
-                           uint32_t id,
-                           rtc::MessageData* pdata,
-                           bool time_sensitive) {
-  rtc::Thread::Post(posted_from, phandler, id, pdata, time_sensitive);
-  rtc::CritScope lock(&lock_);
-  next_run_time_ = Timestamp::MinusInfinity();
-}
-
-void SimulatedThread::PostDelayed(const rtc::Location& posted_from,
-                                  int delay_ms,
-                                  rtc::MessageHandler* phandler,
-                                  uint32_t id,
-                                  rtc::MessageData* pdata) {
-  rtc::Thread::PostDelayed(posted_from, delay_ms, phandler, id, pdata);
-  rtc::CritScope lock(&lock_);
-  next_run_time_ =
-      std::min(next_run_time_, Timestamp::ms(rtc::TimeMillis() + delay_ms));
-}
-
-void SimulatedThread::PostAt(const rtc::Location& posted_from,
-                             int64_t target_time_ms,
-                             rtc::MessageHandler* phandler,
-                             uint32_t id,
-                             rtc::MessageData* pdata) {
-  rtc::Thread::PostAt(posted_from, target_time_ms, phandler, id, pdata);
-  rtc::CritScope lock(&lock_);
-  next_run_time_ = std::min(next_run_time_, Timestamp::ms(target_time_ms));
-}
-
-void SimulatedThread::Stop() {
-  Thread::Quit();
-}
-
-}  // namespace webrtc
diff --git a/test/time_controller/simulated_thread.h b/test/time_controller/simulated_thread.h
deleted file mode 100644
index df4ca2e..0000000
--- a/test/time_controller/simulated_thread.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- *  Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-#ifndef TEST_TIME_CONTROLLER_SIMULATED_THREAD_H_
-#define TEST_TIME_CONTROLLER_SIMULATED_THREAD_H_
-
-#include <memory>
-
-#include "test/time_controller/simulated_time_controller.h"
-
-namespace webrtc {
-
-class SimulatedThread : public rtc::Thread,
-                        public sim_time_impl::SimulatedSequenceRunner {
- public:
-  class CurrentThreadSetter : CurrentTaskQueueSetter {
-   public:
-    explicit CurrentThreadSetter(rtc::Thread* thread)
-        : CurrentTaskQueueSetter(thread),
-          manager_(rtc::ThreadManager::Instance()),
-          previous_(manager_->CurrentThread()) {
-      manager_->ChangeCurrentThreadForTest(thread);
-    }
-    ~CurrentThreadSetter() { manager_->ChangeCurrentThreadForTest(previous_); }
-
-   private:
-    rtc::ThreadManager* const manager_;
-    rtc::Thread* const previous_;
-  };
-  SimulatedThread(sim_time_impl::SimulatedTimeControllerImpl* handler,
-                  absl::string_view name,
-                  std::unique_ptr<rtc::SocketServer> socket_server);
-  ~SimulatedThread() override;
-
-  void RunReady(Timestamp at_time) override;
-
-  Timestamp GetNextRunTime() const override {
-    rtc::CritScope lock(&lock_);
-    return next_run_time_;
-  }
-
-  TaskQueueBase* GetAsTaskQueue() override { return this; }
-
-  // Thread interface
-  void Send(const rtc::Location& posted_from,
-            rtc::MessageHandler* phandler,
-            uint32_t id,
-            rtc::MessageData* pdata) override;
-  void Post(const rtc::Location& posted_from,
-            rtc::MessageHandler* phandler,
-            uint32_t id,
-            rtc::MessageData* pdata,
-            bool time_sensitive) override;
-  void PostDelayed(const rtc::Location& posted_from,
-                   int delay_ms,
-                   rtc::MessageHandler* phandler,
-                   uint32_t id,
-                   rtc::MessageData* pdata) override;
-  void PostAt(const rtc::Location& posted_from,
-              int64_t target_time_ms,
-              rtc::MessageHandler* phandler,
-              uint32_t id,
-              rtc::MessageData* pdata) override;
-
-  void Stop() override;
-
- private:
-  sim_time_impl::SimulatedTimeControllerImpl* const handler_;
-  // Using char* to be debugger friendly.
-  char* name_;
-  rtc::CriticalSection lock_;
-  Timestamp next_run_time_ RTC_GUARDED_BY(lock_) = Timestamp::PlusInfinity();
-};
-
-}  // namespace webrtc
-#endif  // TEST_TIME_CONTROLLER_SIMULATED_THREAD_H_
diff --git a/test/time_controller/simulated_time_controller.cc b/test/time_controller/simulated_time_controller.cc
index 9235441..3bdce8d 100644
--- a/test/time_controller/simulated_time_controller.cc
+++ b/test/time_controller/simulated_time_controller.cc
@@ -20,7 +20,6 @@
 #include "absl/strings/string_view.h"
 #include "test/time_controller/simulated_process_thread.h"
 #include "test/time_controller/simulated_task_queue.h"
-#include "test/time_controller/simulated_thread.h"
 
 namespace webrtc {
 namespace {
@@ -64,16 +63,6 @@
   return process_thread;
 }
 
-std::unique_ptr<rtc::Thread> SimulatedTimeControllerImpl::CreateThread(
-    const std::string& name,
-    std::unique_ptr<rtc::SocketServer> socket_server) {
-  rtc::CritScope lock(&lock_);
-  auto thread =
-      std::make_unique<SimulatedThread>(this, name, std::move(socket_server));
-  runners_.push_back(thread.get());
-  return thread;
-}
-
 void SimulatedTimeControllerImpl::YieldExecution() {
   if (rtc::CurrentThreadId() == thread_id_) {
     TaskQueueBase* yielding_from = TaskQueueBase::Current();
@@ -94,9 +83,6 @@
 }
 
 void SimulatedTimeControllerImpl::RunReadyRunners() {
-  // Using a dummy thread rather than nullptr to avoid implicit thread creation
-  // by Thread::Current().
-  SimulatedThread::CurrentThreadSetter set_current(dummy_thread_.get());
   rtc::CritScope lock(&lock_);
   RTC_DCHECK_EQ(rtc::CurrentThreadId(), thread_id_);
   Timestamp current_time = CurrentTime();
@@ -179,12 +165,6 @@
   return impl_.CreateProcessThread(thread_name);
 }
 
-std::unique_ptr<rtc::Thread> GlobalSimulatedTimeController::CreateThread(
-    const std::string& name,
-    std::unique_ptr<rtc::SocketServer> socket_server) {
-  return impl_.CreateThread(name, std::move(socket_server));
-}
-
 void GlobalSimulatedTimeController::AdvanceTime(TimeDelta duration) {
   rtc::ScopedYieldPolicy yield_policy(&impl_);
   Timestamp current_time = impl_.CurrentTime();
diff --git a/test/time_controller/simulated_time_controller.h b/test/time_controller/simulated_time_controller.h
index 4a81c8b..e9f91b6 100644
--- a/test/time_controller/simulated_time_controller.h
+++ b/test/time_controller/simulated_time_controller.h
@@ -60,10 +60,6 @@
   void YieldExecution() override;
   // Create process thread with the name |thread_name|.
   std::unique_ptr<ProcessThread> CreateProcessThread(const char* thread_name);
-  // Create thread using provided |socket_server|.
-  std::unique_ptr<rtc::Thread> CreateThread(
-      const std::string& name,
-      std::unique_ptr<rtc::SocketServer> socket_server);
 
   // Runs all runners in |runners_| that has tasks or modules ready for
   // execution.
@@ -79,7 +75,6 @@
 
  private:
   const rtc::PlatformThreadId thread_id_;
-  std::unique_ptr<rtc::Thread> dummy_thread_ = rtc::Thread::Create();
   rtc::CriticalSection time_lock_;
   Timestamp current_time_ RTC_GUARDED_BY(time_lock_);
   rtc::CriticalSection lock_;
@@ -124,9 +119,6 @@
   TaskQueueFactory* GetTaskQueueFactory() override;
   std::unique_ptr<ProcessThread> CreateProcessThread(
       const char* thread_name) override;
-  std::unique_ptr<rtc::Thread> CreateThread(
-      const std::string& name,
-      std::unique_ptr<rtc::SocketServer> socket_server) override;
 
   void AdvanceTime(TimeDelta duration) override;