Remove unused RemoveRemoteCandidates and RemoveCandidates methods

Bug: webrtc:42233526
Change-Id: I8bc3f16cf6d96c53fd0665269ceeef2cc07c5eed
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/402061
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45222}
diff --git a/api/jsep.cc b/api/jsep.cc
index 337531e..26b8958 100644
--- a/api/jsep.cc
+++ b/api/jsep.cc
@@ -13,19 +13,9 @@
 #include <cstddef>
 #include <optional>
 #include <string>
-#include <vector>
-
-#include "absl/strings/string_view.h"
-#include "api/candidate.h"
 
 namespace webrtc {
 
-size_t SessionDescriptionInterface::RemoveCandidates(
-    absl::string_view mid,
-    const std::vector<Candidate>& /* candidates */) {
-  return 0;
-}
-
 const char SessionDescriptionInterface::kOffer[] = "offer";
 const char SessionDescriptionInterface::kPrAnswer[] = "pranswer";
 const char SessionDescriptionInterface::kAnswer[] = "answer";
diff --git a/api/jsep.h b/api/jsep.h
index 2061845..bd32144 100644
--- a/api/jsep.h
+++ b/api/jsep.h
@@ -157,11 +157,6 @@
   // Removes the candidate that has a matching address and protocol.
   //
   // Returns the number of candidates that were removed.
-  size_t remove(const Candidate& candidate);
-
-  // Removes the candidate that has a matching address and protocol.
-  //
-  // Returns the number of candidates that were removed.
   size_t remove(const IceCandidate* candidate);
 
   const std::vector<std::unique_ptr<IceCandidate>>& candidates() const {
@@ -268,14 +263,6 @@
   // Returns false if no matching candidate was found (and removed).
   virtual bool RemoveCandidate(const IceCandidate* candidate) = 0;
 
-  // Removes the candidates from the description, if found.
-  //
-  // Returns the number of candidates removed.
-  // TODO: webrtc:42233526 - Deprecate and eventually remove this method in
-  // favor of the IceCandidate version.
-  virtual size_t RemoveCandidates(absl::string_view mid,
-                                  const std::vector<Candidate>& candidates);
-
   // Returns the number of m= sections in the session description.
   virtual size_t number_of_mediasections() const = 0;
 
diff --git a/api/jsep_ice_candidate.cc b/api/jsep_ice_candidate.cc
index 0e7db64..49c7fb7 100644
--- a/api/jsep_ice_candidate.cc
+++ b/api/jsep_ice_candidate.cc
@@ -73,18 +73,6 @@
       });
 }
 
-size_t JsepCandidateCollection::remove(const Candidate& candidate) {
-  auto iter =
-      absl::c_find_if(candidates_, [&](const std::unique_ptr<IceCandidate>& c) {
-        return candidate.MatchesForRemoval(c->candidate());
-      });
-  if (iter != candidates_.end()) {
-    candidates_.erase(iter);
-    return 1;
-  }
-  return 0;
-}
-
 size_t JsepCandidateCollection::remove(const IceCandidate* candidate) {
   RTC_DCHECK(candidate);
   auto iter =
diff --git a/api/jsep_session_description.h b/api/jsep_session_description.h
index acd82d1..357ed78 100644
--- a/api/jsep_session_description.h
+++ b/api/jsep_session_description.h
@@ -20,7 +20,6 @@
 #include <vector>
 
 #include "absl/strings/string_view.h"
-#include "api/candidate.h"
 #include "api/jsep.h"
 
 namespace webrtc {
@@ -60,10 +59,7 @@
   // Allows changing the type. Used for testing.
   virtual bool AddCandidate(const IceCandidate* candidate);
   virtual bool RemoveCandidate(const IceCandidate* candidate);
-  // TODO: https://issues.webrtc.org/42233526 - Remove this method in favor of
-  // the IceCandidate version.
-  virtual size_t RemoveCandidates(absl::string_view mid,
-                                  const std::vector<Candidate>& candidates);
+
   virtual size_t number_of_mediasections() const;
   virtual const IceCandidateCollection* candidates(
       size_t mediasection_index) const;
diff --git a/api/test/mock_session_description_interface.h b/api/test/mock_session_description_interface.h
index a0b94df..e2ff56c 100644
--- a/api/test/mock_session_description_interface.h
+++ b/api/test/mock_session_description_interface.h
@@ -15,10 +15,7 @@
 #include <memory>
 #include <string>
 #include <type_traits>
-#include <vector>
 
-#include "absl/strings/string_view.h"
-#include "api/candidate.h"
 #include "api/jsep.h"
 #include "test/gmock.h"
 
@@ -38,10 +35,6 @@
   MOCK_METHOD(std::string, type, (), (const, override));
   MOCK_METHOD(bool, AddCandidate, (const IceCandidate*), (override));
   MOCK_METHOD(bool, RemoveCandidate, (const IceCandidate*), (override));
-  MOCK_METHOD(size_t,
-              RemoveCandidates,
-              (absl::string_view, const std::vector<Candidate>&),
-              (override));
   MOCK_METHOD(size_t, number_of_mediasections, (), (const, override));
   MOCK_METHOD(const IceCandidateCollection*,
               candidates,
diff --git a/pc/jsep_session_description.cc b/pc/jsep_session_description.cc
index 96de928..f4a955e 100644
--- a/pc/jsep_session_description.cc
+++ b/pc/jsep_session_description.cc
@@ -279,24 +279,6 @@
   return true;
 }
 
-size_t JsepSessionDescription::RemoveCandidates(
-    absl::string_view mid,
-    const std::vector<Candidate>& candidates) {
-  int mediasection_index = GetMediasectionIndex(mid);
-  if (mediasection_index < 0) {
-    return 0u;
-  }
-
-  size_t num_removed = 0u;
-  for (auto& candidate : candidates) {
-    num_removed += candidate_collection_[mediasection_index].remove(candidate);
-    UpdateConnectionAddress(
-        candidate_collection_[mediasection_index],
-        description_->contents()[mediasection_index].media_description());
-  }
-  return num_removed;
-}
-
 size_t JsepSessionDescription::number_of_mediasections() const {
   if (!description_)
     return 0;
diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc
index 17d1124..6c7e539 100644
--- a/pc/jsep_transport_controller.cc
+++ b/pc/jsep_transport_controller.cc
@@ -407,54 +407,6 @@
   return jsep_transport->AddRemoteCandidates(candidates);
 }
 
-RTCError JsepTransportController::RemoveRemoteCandidates(
-    const Candidates& candidates) {
-  if (!network_thread_->IsCurrent()) {
-    return network_thread_->BlockingCall(
-        [&] { return RemoveRemoteCandidates(candidates); });
-  }
-
-  RTC_DCHECK_RUN_ON(network_thread_);
-
-  // Verify each candidate before passing down to the transport layer.
-  RTCError error = VerifyCandidates(candidates);
-  if (!error.ok()) {
-    return error;
-  }
-
-  std::map<std::string, Candidates> candidates_by_transport_name;
-  for (const Candidate& cand : candidates) {
-    if (!cand.transport_name().empty()) {
-      candidates_by_transport_name[cand.transport_name()].push_back(cand);
-    } else {
-      RTC_LOG(LS_ERROR) << "Not removing candidate because it does not have a "
-                           "transport name set: "
-                        << cand.ToSensitiveString();
-    }
-  }
-
-  for (const auto& kv : candidates_by_transport_name) {
-    const std::string& transport_name = kv.first;
-    const Candidates& transport_candidates = kv.second;
-    JsepTransport* jsep_transport = GetJsepTransportByName(transport_name);
-    if (!jsep_transport) {
-      RTC_LOG(LS_WARNING)
-          << "Not removing candidate because the JsepTransport doesn't exist.";
-      continue;
-    }
-    for (const Candidate& candidate : transport_candidates) {
-      DtlsTransportInternal* dtls =
-          candidate.component() == ICE_CANDIDATE_COMPONENT_RTP
-              ? jsep_transport->rtp_dtls_transport()
-              : jsep_transport->rtcp_dtls_transport();
-      if (dtls) {
-        dtls->ice_transport()->RemoveRemoteCandidate(candidate);
-      }
-    }
-  }
-  return RTCError::OK();
-}
-
 bool JsepTransportController::RemoveRemoteCandidate(const IceCandidate* c) {
   if (!network_thread_->IsCurrent()) {
     return network_thread_->BlockingCall(
diff --git a/pc/jsep_transport_controller.h b/pc/jsep_transport_controller.h
index fdf3f1e..374334c 100644
--- a/pc/jsep_transport_controller.h
+++ b/pc/jsep_transport_controller.h
@@ -210,7 +210,6 @@
   void MaybeStartGathering();
   RTCError AddRemoteCandidates(const std::string& mid,
                                const std::vector<Candidate>& candidates);
-  RTCError RemoveRemoteCandidates(const std::vector<Candidate>& candidates);
   bool RemoveRemoteCandidate(const IceCandidate* candidate);
 
   /**********************