Moves ownership of time controller into NetworkEmulationManager.

This makes it easier to maintain consistency between real time
and simulated time modes.

The RealTimeController is updated to use an explicit main thread,
this ensures that pending destruction tasks are run as the network
emulator goes out of scope.

Bug: webrtc:11255
Change-Id: Ie73ab778c78a68d7c58c0f857f14a8d8ac027c67
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166164
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30342}
diff --git a/api/test/time_controller.h b/api/test/time_controller.h
index 6c47e91..6d09481 100644
--- a/api/test/time_controller.h
+++ b/api/test/time_controller.h
@@ -23,7 +23,6 @@
 #include "system_wrappers/include/clock.h"
 
 namespace webrtc {
-
 // Interface for controlling time progress. This allows us to execute test code
 // in either real time or simulated time by using different implementation of
 // this interface.
@@ -51,6 +50,10 @@
   // Allow task queues and process threads created by this instance to execute
   // for the given |duration|.
   virtual void AdvanceTime(TimeDelta duration) = 0;
+
+  // Waits until done() == true, polling done() in small time intervals.
+  bool Wait(const std::function<bool()>& done,
+            TimeDelta max_duration = TimeDelta::seconds(5));
 };
 
 // Interface for telling time, scheduling an event to fire at a particular time,