Remove CreateModularPeerConnectionFactory from peer_connection_interface.h

build target with peer_connection_interface.h doesn't have definition
of that symbols, which is confusing.

Users are updated to depend on create_modular_peer_connection_factory
instead that does include the definition.

Bug: webrtc:42220069
Change-Id: I881c0ceb71afe2fec70dbe68b2392e42d9ad6cbd
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/400520
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45418}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 5b25a93..fa772e5 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -70,14 +70,20 @@
   ]
 }
 
-rtc_source_set("create_modular_peer_connection_factory") {
+rtc_library("create_modular_peer_connection_factory") {
   visibility = [ "*" ]
   allow_poison = [ "environment_construction" ]
-  sources = [ "create_modular_peer_connection_factory.h" ]
+  sources = [
+    "create_modular_peer_connection_factory.cc",
+    "create_modular_peer_connection_factory.h",
+  ]
   deps = [
     ":libjingle_peerconnection_api",
     ":scoped_refptr",
+    ":sequence_checker",
     "../pc:peer_connection_factory",
+    "../pc:peer_connection_factory_proxy",
+    "../rtc_base:threading",
     "../rtc_base/system:rtc_export",
     "../stats:rtc_stats",
   ]
@@ -289,17 +295,6 @@
   ]
 }
 
-# TODO: bugs.webrtc.org/42220069 - Remove when downstream has been updated
-# to depend on `create_modular_peer_connection_factory` instead.
-rtc_source_set("create_modular_peer_connection_factory_internal") {
-  visibility = [ ":libjingle_peerconnection_api" ]
-  sources = [ "create_modular_peer_connection_factory_internal.h" ]
-  deps = [
-    ":scoped_refptr",
-    "../rtc_base/system:rtc_export",
-  ]
-}
-
 rtc_library("libjingle_peerconnection_api") {
   visibility = [ "*" ]
   cflags = []
@@ -340,7 +335,6 @@
     ":async_dns_resolver",
     ":audio_options_api",
     ":candidate",
-    ":create_modular_peer_connection_factory_internal",
     ":data_channel_event_observer_interface",
     ":dtls_transport_interface",
     ":fec_controller_api",
diff --git a/api/create_modular_peer_connection_factory.cc b/api/create_modular_peer_connection_factory.cc
new file mode 100644
index 0000000..1b43eae
--- /dev/null
+++ b/api/create_modular_peer_connection_factory.cc
@@ -0,0 +1,46 @@
+/*
+ *  Copyright 2025 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 "api/create_modular_peer_connection_factory.h"
+
+#include <utility>
+
+#include "api/peer_connection_interface.h"
+#include "api/scoped_refptr.h"
+#include "api/sequence_checker.h"
+#include "pc/peer_connection_factory.h"
+#include "pc/peer_connection_factory_proxy.h"
+#include "rtc_base/thread.h"
+
+namespace webrtc {
+
+scoped_refptr<PeerConnectionFactoryInterface>
+CreateModularPeerConnectionFactory(
+    PeerConnectionFactoryDependencies dependencies) {
+  // The PeerConnectionFactory must be created on the signaling thread.
+  if (dependencies.signaling_thread &&
+      !dependencies.signaling_thread->IsCurrent()) {
+    return dependencies.signaling_thread->BlockingCall([&dependencies] {
+      return CreateModularPeerConnectionFactory(std::move(dependencies));
+    });
+  }
+
+  auto pc_factory = PeerConnectionFactory::Create(std::move(dependencies));
+  if (!pc_factory) {
+    return nullptr;
+  }
+  // Verify that the invocation and the initialization ended up agreeing on the
+  // thread.
+  RTC_DCHECK_RUN_ON(pc_factory->signaling_thread());
+  return PeerConnectionFactoryProxy::Create(
+      pc_factory->signaling_thread(), pc_factory->worker_thread(), pc_factory);
+}
+
+}  // namespace webrtc
diff --git a/api/create_modular_peer_connection_factory_internal.h b/api/create_modular_peer_connection_factory_internal.h
deleted file mode 100644
index 370c148..0000000
--- a/api/create_modular_peer_connection_factory_internal.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *  Copyright 2025 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.
- */
-
-// This temporary header is here to steer users of the
-// CreateModularPeerConnectionFactory to include
-// `create_modular_peer_connection_factory.h` and thus depend on
-// `create_modular_peer_connection_factory` build target. Once users are
-// migrated this file can be deleted.
-
-// IWYU pragma: private, include "api/create_modular_peer_connection_factory.h"
-
-#ifndef API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_INTERNAL_H_
-#define API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_INTERNAL_H_
-
-#include "api/scoped_refptr.h"
-#include "rtc_base/system/rtc_export.h"
-
-namespace webrtc {
-
-// Forward declare to avoid circular dependencies with
-// `api/peer_connection_interface.h`. This file exists to be included from that
-// header, and same time requires classes defined in that header.
-class PeerConnectionFactoryInterface;
-struct PeerConnectionFactoryDependencies;
-
-RTC_EXPORT scoped_refptr<PeerConnectionFactoryInterface>
-CreateModularPeerConnectionFactory(
-    PeerConnectionFactoryDependencies dependencies);
-
-}  // namespace webrtc
-
-#endif  // API_CREATE_MODULAR_PEER_CONNECTION_FACTORY_INTERNAL_H_
diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h
index 032320a..d80f545 100644
--- a/api/peer_connection_interface.h
+++ b/api/peer_connection_interface.h
@@ -148,10 +148,6 @@
 #include "rtc_base/system/rtc_export.h"
 #include "rtc_base/thread.h"
 
-// TODO: bugs.webrtc.org/42220069 - Remove this include when users of this
-// function include "create_modular_peer_connection_factory.h" instead.
-#include "api/create_modular_peer_connection_factory_internal.h"  // IWYU pragma: keep
-
 namespace webrtc {
 // IWYU pragma: begin_keep
 // MediaFactory class definition is not part of the api.
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index f48ba6e..a197ff8 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -476,7 +476,7 @@
 }
 
 rtc_source_set("peer_connection_factory_proxy") {
-  visibility = [ ":*" ]
+  visibility = [ "../api:create_modular_peer_connection_factory" ]
   sources = [ "peer_connection_factory_proxy.h" ]
   deps = [
     ":proxy",
@@ -1550,7 +1550,6 @@
     ":media_stream_proxy",
     ":media_stream_track_proxy",
     ":peer_connection",
-    ":peer_connection_factory_proxy",
     ":peer_connection_proxy",
     ":rtp_parameters_conversion",
     ":video_track",
@@ -2440,7 +2439,6 @@
       ":pc_test_utils",
       ":peer_connection",
       ":peer_connection_factory",
-      ":peer_connection_factory_proxy",
       ":peer_connection_internal",
       ":peer_connection_proxy",
       ":peerconnection_wrapper",
diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc
index 39038d5..df3a417 100644
--- a/pc/peer_connection_factory.cc
+++ b/pc/peer_connection_factory.cc
@@ -54,7 +54,6 @@
 #include "pc/media_stream_proxy.h"
 #include "pc/media_stream_track_proxy.h"
 #include "pc/peer_connection.h"
-#include "pc/peer_connection_factory_proxy.h"
 #include "pc/peer_connection_proxy.h"
 #include "pc/rtp_parameters_conversion.h"
 #include "pc/video_track.h"
@@ -86,31 +85,6 @@
 
 }  // namespace
 
-// TODO: bugs.webrtc.org/42220069 - Move this function to
-// 'create_modular_peer_connection_factory' build target when all users of this
-// function would depend on that build target.
-scoped_refptr<PeerConnectionFactoryInterface>
-CreateModularPeerConnectionFactory(
-    PeerConnectionFactoryDependencies dependencies) {
-  // The PeerConnectionFactory must be created on the signaling thread.
-  if (dependencies.signaling_thread &&
-      !dependencies.signaling_thread->IsCurrent()) {
-    return dependencies.signaling_thread->BlockingCall([&dependencies] {
-      return CreateModularPeerConnectionFactory(std::move(dependencies));
-    });
-  }
-
-  auto pc_factory = PeerConnectionFactory::Create(std::move(dependencies));
-  if (!pc_factory) {
-    return nullptr;
-  }
-  // Verify that the invocation and the initialization ended up agreeing on the
-  // thread.
-  RTC_DCHECK_RUN_ON(pc_factory->signaling_thread());
-  return PeerConnectionFactoryProxy::Create(
-      pc_factory->signaling_thread(), pc_factory->worker_thread(), pc_factory);
-}
-
 // Static
 scoped_refptr<PeerConnectionFactory> PeerConnectionFactory::Create(
     PeerConnectionFactoryDependencies dependencies) {