Reland "Remove thread hops from events provided by JsepTransportController."

This reverts commit 6e4fcac31312f2dda5b60d33874ff0cd62f94321.

Reason for revert: Parent CL issue has been resolved.

Original change's description:
> Revert "Remove thread hops from events provided by JsepTransportController."
>
> This reverts commit f554b3c577f69fa9ffad5c07155898c2d985ac76.
>
> Reason for revert: Parent CL breaks FYI bots.
> See https://webrtc-review.googlesource.com/c/src/+/206466
>
> Original change's description:
> > Remove thread hops from events provided by JsepTransportController.
> >
> > Events associated with Subscribe* methods in JTC had trampolines that
> > would use an async invoker to fire the events on the signaling thread.
> > This was being done for the purposes of PeerConnection but the concept
> > of a signaling thread is otherwise not applicable to JTC and use of
> > JTC from PC is inconsistent across threads (as has been flagged in
> > webrtc:9987).
> >
> > This change makes all CallbackList members only accessible from the
> > network thread and moves the signaling thread related work over to
> > PeerConnection, which makes hops there more visible as well as making
> > that class easier to refactor for thread efficiency.
> >
> > This CL removes the AsyncInvoker from JTC (webrtc:12339)
> >
> > The signaling_thread_ variable is also removed from JTC and more thread
> > checks added to catch errors.
> >
> > Bug: webrtc:12427, webrtc:11988, webrtc:12339
> > Change-Id: Id232aedd00dfd5403b2ba0ca147d3eca7c12c7c5
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206062
> > Commit-Queue: Tommi <tommi@webrtc.org>
> > Reviewed-by: Niels Moller <nisse@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#33195}
>
> TBR=nisse@webrtc.org,tommi@webrtc.org
>
> Change-Id: I6134b71b74a9408854b79d44506d513519e9cf4d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:12427
> Bug: webrtc:11988
> Bug: webrtc:12339
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206467
> Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
> Commit-Queue: Guido Urdaneta <guidou@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#33203}

TBR=nisse@webrtc.org,tommi@webrtc.org,guidou@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: webrtc:12427
Bug: webrtc:11988
Bug: webrtc:12339
Change-Id: I4e2e1490e1f9a87ed6ac4d722fd3c442e3059ae0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206809
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33225}
diff --git a/pc/peer_connection.h b/pc/peer_connection.h
index 80259d4..6833c58 100644
--- a/pc/peer_connection.h
+++ b/pc/peer_connection.h
@@ -456,7 +456,8 @@
                  bool is_unified_plan,
                  std::unique_ptr<RtcEventLog> event_log,
                  std::unique_ptr<Call> call,
-                 PeerConnectionDependencies& dependencies);
+                 PeerConnectionDependencies& dependencies,
+                 bool dtls_enabled);
 
   ~PeerConnection() override;
 
@@ -464,6 +465,10 @@
   RTCError Initialize(
       const PeerConnectionInterface::RTCConfiguration& configuration,
       PeerConnectionDependencies dependencies);
+  void InitializeTransportController_n(
+      const RTCConfiguration& configuration,
+      const PeerConnectionDependencies& dependencies)
+      RTC_RUN_ON(network_thread());
 
   rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
   FindTransceiverBySender(rtc::scoped_refptr<RtpSenderInterface> sender)
@@ -574,11 +579,12 @@
   void ReportTransportStats() RTC_RUN_ON(signaling_thread());
 
   // Gather the usage of IPv4/IPv6 as best connection.
-  void ReportBestConnectionState(const cricket::TransportStats& stats);
+  static void ReportBestConnectionState(const cricket::TransportStats& stats);
 
-  void ReportNegotiatedCiphers(const cricket::TransportStats& stats,
-                               const std::set<cricket::MediaType>& media_types)
-      RTC_RUN_ON(signaling_thread());
+  static void ReportNegotiatedCiphers(
+      bool dtls_enabled,
+      const cricket::TransportStats& stats,
+      const std::set<cricket::MediaType>& media_types);
   void ReportIceCandidateCollected(const cricket::Candidate& candidate)
       RTC_RUN_ON(signaling_thread());
 
@@ -628,8 +634,9 @@
 
   // TODO(zstein): |async_resolver_factory_| can currently be nullptr if it
   // is not injected. It should be required once chromium supplies it.
-  const std::unique_ptr<AsyncResolverFactory> async_resolver_factory_
-      RTC_GUARDED_BY(signaling_thread());
+  // This member variable is only used by JsepTransportController so we should
+  // consider moving ownership to there.
+  const std::unique_ptr<AsyncResolverFactory> async_resolver_factory_;
   std::unique_ptr<cricket::PortAllocator>
       port_allocator_;  // TODO(bugs.webrtc.org/9987): Accessed on both
                         // signaling and network thread.
@@ -647,8 +654,7 @@
   std::unique_ptr<Call> call_ RTC_GUARDED_BY(worker_thread());
   ScopedTaskSafety signaling_thread_safety_;
   rtc::scoped_refptr<PendingTaskSafetyFlag> network_thread_safety_;
-  std::unique_ptr<ScopedTaskSafety> call_safety_
-      RTC_GUARDED_BY(worker_thread());
+  rtc::scoped_refptr<PendingTaskSafetyFlag> worker_thread_safety_;
 
   // Points to the same thing as `call_`. Since it's const, we may read the
   // pointer from any thread.
@@ -682,7 +688,7 @@
   std::unique_ptr<SdpOfferAnswerHandler> sdp_handler_
       RTC_GUARDED_BY(signaling_thread());
 
-  bool dtls_enabled_ RTC_GUARDED_BY(signaling_thread()) = false;
+  const bool dtls_enabled_;
 
   UsagePattern usage_pattern_ RTC_GUARDED_BY(signaling_thread());
   bool return_histogram_very_quickly_ RTC_GUARDED_BY(signaling_thread()) =