Add 2 new virtual methods to IceTransportInternal

This will allow the blink-layer ICE-transport handling code
to use the virtual interface class rather than the concrete
implementation class.

Bug: chromium:864871
Change-Id: I5dfd1f266b3f3eabe42e09ba35afe218d25634b1
Reviewed-on: https://webrtc-review.googlesource.com/c/118360
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26333}
diff --git a/p2p/base/fake_ice_transport.h b/p2p/base/fake_ice_transport.h
index 8bcd723..45fe6f3 100644
--- a/p2p/base/fake_ice_transport.h
+++ b/p2p/base/fake_ice_transport.h
@@ -191,6 +191,8 @@
     remote_candidates_.erase(it);
   }
 
+  void RemoveAllRemoteCandidates() override { remote_candidates_.clear(); }
+
   bool GetStats(ConnectionInfos* candidate_pair_stats_list,
                 CandidateStatsList* candidate_stats_list) override {
     CandidateStats candidate_stats;
@@ -204,6 +206,8 @@
 
   absl::optional<int> GetRttEstimate() override { return absl::nullopt; }
 
+  const Connection* selected_connection() const override { return nullptr; }
+
   // Fake PacketTransportInternal implementation.
   bool writable() const override { return writable_; }
   bool receiving() const override { return receiving_; }
diff --git a/p2p/base/ice_transport_internal.h b/p2p/base/ice_transport_internal.h
index f3da45a..8f21673 100644
--- a/p2p/base/ice_transport_internal.h
+++ b/p2p/base/ice_transport_internal.h
@@ -242,6 +242,8 @@
 
   virtual void RemoveRemoteCandidate(const Candidate& candidate) = 0;
 
+  virtual void RemoveAllRemoteCandidates() = 0;
+
   virtual IceGatheringState gathering_state() const = 0;
 
   // Returns the current stats for this connection.
@@ -252,6 +254,8 @@
   // absl::optional if there is none.
   virtual absl::optional<int> GetRttEstimate() = 0;
 
+  virtual const Connection* selected_connection() const = 0;
+
   sigslot::signal1<IceTransportInternal*> SignalGatheringState;
 
   // Handles sending and receiving of candidates.
diff --git a/p2p/base/mock_ice_transport.h b/p2p/base/mock_ice_transport.h
index e0ad1e2..77716b2 100644
--- a/p2p/base/mock_ice_transport.h
+++ b/p2p/base/mock_ice_transport.h
@@ -62,9 +62,11 @@
   void SetRemoteIceMode(IceMode mode) override {}
   void SetIceConfig(const IceConfig& config) override {}
   absl::optional<int> GetRttEstimate() override { return absl::nullopt; }
+  const Connection* selected_connection() const override { return nullptr; }
   void MaybeStartGathering() override {}
   void AddRemoteCandidate(const Candidate& candidate) override {}
   void RemoveRemoteCandidate(const Candidate& candidate) override {}
+  void RemoveAllRemoteCandidates() override {}
   IceGatheringState gathering_state() const override {
     return IceGatheringState::kIceGatheringComplete;
   }
diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc
index b12bd0c..212ed30 100644
--- a/p2p/base/p2p_transport_channel.cc
+++ b/p2p/base/p2p_transport_channel.cc
@@ -714,6 +714,10 @@
   return RTCError::OK();
 }
 
+const Connection* P2PTransportChannel::selected_connection() const {
+  return selected_connection_;
+}
+
 int P2PTransportChannel::check_receiving_interval() const {
   return std::max(MIN_CHECK_RECEIVING_INTERVAL,
                   config_.receiving_timeout_or_default() / 10);
@@ -1180,6 +1184,10 @@
   }
 }
 
+void P2PTransportChannel::RemoveAllRemoteCandidates() {
+  remote_candidates_.clear();
+}
+
 // Creates connections from all of the ports that we care about to the given
 // remote candidate.  The return value is true if we created a connection from
 // the origin port.
diff --git a/p2p/base/p2p_transport_channel.h b/p2p/base/p2p_transport_channel.h
index f9b4c7dc..467ef25 100644
--- a/p2p/base/p2p_transport_channel.h
+++ b/p2p/base/p2p_transport_channel.h
@@ -112,6 +112,7 @@
   void ResolveHostnameCandidate(const Candidate& candidate);
   void AddRemoteCandidate(const Candidate& candidate) override;
   void RemoveRemoteCandidate(const Candidate& candidate) override;
+  void RemoveAllRemoteCandidates() override;
   // Sets the parameters in IceConfig. We do not set them blindly. Instead, we
   // only update the parameter if it is considered set in |config|. For example,
   // a negative value of receiving_timeout will be considered "not set" and we
@@ -132,12 +133,12 @@
   bool GetStats(std::vector<ConnectionInfo>* candidate_pair_stats_list,
                 std::vector<CandidateStats>* candidate_stats_list) override;
   absl::optional<int> GetRttEstimate() override;
+  const Connection* selected_connection() const override;
 
   // TODO(honghaiz): Remove this method once the reference of it in
   // Chromoting is removed.
   const Connection* best_connection() const { return selected_connection_; }
 
-  const Connection* selected_connection() const { return selected_connection_; }
   void set_incoming_only(bool value) { incoming_only_ = value; }
 
   // Note: These are only for testing purpose.
diff --git a/pc/ice_transport_unittest.cc b/pc/ice_transport_unittest.cc
new file mode 100644
index 0000000..c299b2c
--- /dev/null
+++ b/pc/ice_transport_unittest.cc
@@ -0,0 +1,26 @@
+/*
+ *  Copyright 2019 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 "pc/ice_transport.h"
+#include "p2p/base/fake_port_allocator.h"
+
+#include "test/gtest.h"
+
+namespace webrtc {
+
+class IceTransportTest : public testing::Test {};
+
+TEST_F(IceTransportTest, CreateStandaloneIceTransport) {
+  auto port_allocator = new cricket::FakePortAllocator(nullptr, nullptr);
+  auto transport = CreateIceTransport(port_allocator);
+  ASSERT_TRUE(transport->internal());
+}
+
+}  // namespace webrtc