Cleanup ConnectionContext dependency on field trials

ConntectionContext now keeps and expose field trials as part of the
Environment, and do not need to be aware about field trials specifically

Bug: webrtc:15656
Change-Id: Ib78694a65a9ca7c8bf273eeaf9334323ddb841c7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/329420
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41328}
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 51a55ab..b83978f 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -929,7 +929,6 @@
   ]
   deps = [
     ":media_factory",
-    "../api:field_trials_view",
     "../api:libjingle_peerconnection_api",
     "../api:media_stream_interface",
     "../api:refcountedbase",
@@ -937,7 +936,6 @@
     "../api:sequence_checker",
     "../api/environment",
     "../api/neteq:neteq_api",
-    "../api/transport:field_trial_based_config",
     "../api/transport:sctp_transport_factory_interface",
     "../media:rtc_data_sctp_transport_factory",
     "../media:rtc_media_base",
diff --git a/pc/connection_context.cc b/pc/connection_context.cc
index df4522b..56a6e91 100644
--- a/pc/connection_context.cc
+++ b/pc/connection_context.cc
@@ -15,7 +15,6 @@
 #include <vector>
 
 #include "api/environment/environment.h"
-#include "api/transport/field_trial_based_config.h"
 #include "media/base/media_engine.h"
 #include "media/sctp/sctp_transport_factory.h"
 #include "pc/media_factory.h"
@@ -63,8 +62,7 @@
 
 std::unique_ptr<SctpTransportFactoryInterface> MaybeCreateSctpFactory(
     std::unique_ptr<SctpTransportFactoryInterface> factory,
-    rtc::Thread* network_thread,
-    const FieldTrialsView& field_trials) {
+    rtc::Thread* network_thread) {
   if (factory) {
     return factory;
   }
@@ -113,8 +111,7 @@
       default_socket_factory_(std::move(dependencies->packet_socket_factory)),
       sctp_factory_(
           MaybeCreateSctpFactory(std::move(dependencies->sctp_factory),
-                                 network_thread(),
-                                 env_.field_trials())),
+                                 network_thread())),
       use_rtx_(true) {
   RTC_DCHECK_RUN_ON(signaling_thread_);
   RTC_DCHECK(!(default_network_manager_ && network_monitor_factory_))
diff --git a/pc/connection_context.h b/pc/connection_context.h
index 232d8e3..28b2d1c 100644
--- a/pc/connection_context.h
+++ b/pc/connection_context.h
@@ -15,7 +15,6 @@
 #include <string>
 
 #include "api/environment/environment.h"
-#include "api/field_trials_view.h"
 #include "api/media_stream_interface.h"
 #include "api/peer_connection_interface.h"
 #include "api/ref_counted_base.h"
@@ -80,12 +79,6 @@
   // but they are not supposed to change after creating the PeerConnection.
   const Environment& env() const { return env_; }
 
-  // Field trials associated with the PeerConnectionFactory.
-  // Note: that there can be different field trials for different
-  // PeerConnections (but they are not supposed change after creating the
-  // PeerConnection).
-  const FieldTrialsView& field_trials() const { return env_.field_trials(); }
-
   // Accessors only used from the PeerConnectionFactory class
   rtc::NetworkManager* default_network_manager() {
     RTC_DCHECK_RUN_ON(signaling_thread_);
diff --git a/pc/peer_connection_factory.h b/pc/peer_connection_factory.h
index 66f6725..66afebb 100644
--- a/pc/peer_connection_factory.h
+++ b/pc/peer_connection_factory.h
@@ -109,7 +109,7 @@
   }
 
   const FieldTrialsView& field_trials() const {
-    return context_->field_trials();
+    return context_->env().field_trials();
   }
 
   cricket::MediaEngineInterface* media_engine() const;