Delete deprecated CreatePeerConnection functions

Bug: webrtc:41480877
Change-Id: I6bc64031187d6cba8a66a97984bd92ae29521ebe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/376420
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43886}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 6b82e90..010695a 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -1338,9 +1338,7 @@
       ":rtc_error",
       ":rtp_parameters",
       ":scoped_refptr",
-      "../p2p:port_allocator",
       "../rtc_base:refcount",
-      "../rtc_base:rtc_certificate_generator",
       "../test:test_support",
       "//third_party/abseil-cpp/absl/strings:string_view",
     ]
diff --git a/api/peer_connection_interface.cc b/api/peer_connection_interface.cc
index 695267c..947ecc6 100644
--- a/api/peer_connection_interface.cc
+++ b/api/peer_connection_interface.cc
@@ -10,16 +10,7 @@
 
 #include "api/peer_connection_interface.h"
 
-#include <memory>
-#include <utility>
-
-#include "api/media_types.h"
-#include "api/rtc_error.h"
-#include "api/rtp_parameters.h"
-#include "api/scoped_refptr.h"
-#include "p2p/base/port_allocator.h"
 #include "pc/media_factory.h"
-#include "rtc_base/rtc_certificate_generator.h"
 
 namespace webrtc {
 
@@ -78,40 +69,4 @@
 PeerConnectionFactoryDependencies::~PeerConnectionFactoryDependencies() =
     default;
 
-rtc::scoped_refptr<PeerConnectionInterface>
-PeerConnectionFactoryInterface::CreatePeerConnection(
-    const PeerConnectionInterface::RTCConfiguration& configuration,
-    std::unique_ptr<cricket::PortAllocator> allocator,
-    std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
-    PeerConnectionObserver* observer) {
-  PeerConnectionDependencies dependencies(observer);
-  dependencies.allocator = std::move(allocator);
-  dependencies.cert_generator = std::move(cert_generator);
-  auto result =
-      CreatePeerConnectionOrError(configuration, std::move(dependencies));
-  if (!result.ok()) {
-    return nullptr;
-  }
-  return result.MoveValue();
-}
-
-rtc::scoped_refptr<PeerConnectionInterface>
-PeerConnectionFactoryInterface::CreatePeerConnection(
-    const PeerConnectionInterface::RTCConfiguration& configuration,
-    PeerConnectionDependencies dependencies) {
-  auto result =
-      CreatePeerConnectionOrError(configuration, std::move(dependencies));
-  if (!result.ok()) {
-    return nullptr;
-  }
-  return result.MoveValue();
-}
-
-RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>>
-PeerConnectionFactoryInterface::CreatePeerConnectionOrError(
-    const PeerConnectionInterface::RTCConfiguration& /* configuration */,
-    PeerConnectionDependencies /* dependencies */) {
-  return RTCError(RTCErrorType::INTERNAL_ERROR);
-}
-
 }  // namespace webrtc
diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h
index 9bd250e..4b9d6e1 100644
--- a/api/peer_connection_interface.h
+++ b/api/peer_connection_interface.h
@@ -1539,34 +1539,10 @@
 
   // The preferred way to create a new peer connection. Simply provide the
   // configuration and a PeerConnectionDependencies structure.
-  // TODO(benwright): Make pure virtual once downstream mock PC factory classes
-  // are updated.
   virtual RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>>
   CreatePeerConnectionOrError(
       const PeerConnectionInterface::RTCConfiguration& configuration,
-      PeerConnectionDependencies dependencies);
-  // Deprecated creator - does not return an error code on error.
-  // TODO(bugs.webrtc.org:12238): Deprecate and remove.
-  ABSL_DEPRECATED("Use CreatePeerConnectionOrError")
-  virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
-      const PeerConnectionInterface::RTCConfiguration& configuration,
-      PeerConnectionDependencies dependencies);
-
-  // Deprecated; `allocator` and `cert_generator` may be null, in which case
-  // default implementations will be used.
-  //
-  // `observer` must not be null.
-  //
-  // Note that this method does not take ownership of `observer`; it's the
-  // responsibility of the caller to delete it. It can be safely deleted after
-  // Close has been called on the returned PeerConnection, which ensures no
-  // more observer callbacks will be invoked.
-  ABSL_DEPRECATED("Use CreatePeerConnectionOrError")
-  virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
-      const PeerConnectionInterface::RTCConfiguration& configuration,
-      std::unique_ptr<cricket::PortAllocator> allocator,
-      std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
-      PeerConnectionObserver* observer);
+      PeerConnectionDependencies dependencies) = 0;
 
   // Returns the capabilities of an RTP sender of type `kind`.
   // If for some reason you pass in MEDIA_TYPE_DATA, returns an empty structure.
diff --git a/api/test/mock_peer_connection_factory_interface.h b/api/test/mock_peer_connection_factory_interface.h
index 4551266..2d46fe6 100644
--- a/api/test/mock_peer_connection_factory_interface.h
+++ b/api/test/mock_peer_connection_factory_interface.h
@@ -13,7 +13,6 @@
 
 #include <cstdint>
 #include <cstdio>
-#include <memory>
 #include <string>
 
 #include "absl/strings/string_view.h"
@@ -24,9 +23,7 @@
 #include "api/rtc_error.h"
 #include "api/rtp_parameters.h"
 #include "api/scoped_refptr.h"
-#include "p2p/base/port_allocator.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/rtc_certificate_generator.h"
 #include "test/gmock.h"
 
 namespace webrtc {
@@ -40,23 +37,11 @@
   }
 
   MOCK_METHOD(void, SetOptions, (const Options&), (override));
-  MOCK_METHOD(rtc::scoped_refptr<PeerConnectionInterface>,
-              CreatePeerConnection,
-              (const PeerConnectionInterface::RTCConfiguration&,
-               PeerConnectionDependencies),
-              (override));
   MOCK_METHOD(RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>>,
               CreatePeerConnectionOrError,
               (const PeerConnectionInterface::RTCConfiguration&,
                PeerConnectionDependencies),
               (override));
-  MOCK_METHOD(rtc::scoped_refptr<PeerConnectionInterface>,
-              CreatePeerConnection,
-              (const PeerConnectionInterface::RTCConfiguration&,
-               std::unique_ptr<cricket::PortAllocator>,
-               std::unique_ptr<rtc::RTCCertificateGeneratorInterface>,
-               PeerConnectionObserver*),
-              (override));
   MOCK_METHOD(RtpCapabilities,
               GetRtpSenderCapabilities,
               (cricket::MediaType),