diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index 8cd16eb515..46ce8074f2 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -184,6 +184,7 @@ if (rtc_include_tests) { "../rtc_base:threading", "../test:scoped_key_value_config", ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("p2p_test_utils") { diff --git a/p2p/base/fake_port_allocator.h b/p2p/base/fake_port_allocator.h index 59533faab0..66dc6a4265 100644 --- a/p2p/base/fake_port_allocator.h +++ b/p2p/base/fake_port_allocator.h @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "p2p/base/basic_packet_socket_factory.h" #include "p2p/base/port_allocator.h" #include "p2p/base/udp_port.h" @@ -237,9 +238,19 @@ class FakePortAllocator : public cricket::PortAllocator { int component, const std::string& ice_ufrag, const std::string& ice_pwd) override { - return new FakePortAllocatorSession(this, network_thread_, factory_, - content_name, component, ice_ufrag, - ice_pwd, field_trials_); + return CreateSessionInternal(absl::string_view(content_name), component, + absl::string_view(ice_ufrag), + absl::string_view(ice_pwd)); + } + + cricket::PortAllocatorSession* CreateSessionInternal( + absl::string_view content_name, + int component, + absl::string_view ice_ufrag, + absl::string_view ice_pwd) override { + return new FakePortAllocatorSession( + this, network_thread_, factory_, std::string(content_name), component, + std::string(ice_ufrag), std::string(ice_pwd), field_trials_); } bool initialized() const { return initialized_; } diff --git a/p2p/base/port_allocator.cc b/p2p/base/port_allocator.cc index 6c3ccc8e46..4963f34313 100644 --- a/p2p/base/port_allocator.cc +++ b/p2p/base/port_allocator.cc @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "p2p/base/ice_credentials_iterator.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -312,6 +313,15 @@ std::vector PortAllocator::GetPooledIceCredentials() { return list; } +PortAllocatorSession* PortAllocator::CreateSessionInternal( + absl::string_view content_name, + int component, + absl::string_view ice_ufrag, + absl::string_view ice_pwd) { + return CreateSessionInternal(std::string(content_name), component, + std::string(ice_ufrag), std::string(ice_pwd)); +} + Candidate PortAllocator::SanitizeCandidate(const Candidate& c) const { CheckRunOnValidThreadAndInitialized(); // For a local host candidate, we need to conceal its IP address candidate if diff --git a/p2p/base/port_allocator.h b/p2p/base/port_allocator.h index 08584d988b..29f5326454 100644 --- a/p2p/base/port_allocator.h +++ b/p2p/base/port_allocator.h @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/sequence_checker.h" #include "api/transport/enums.h" #include "p2p/base/port.h" @@ -602,11 +603,18 @@ class RTC_EXPORT PortAllocator : public sigslot::has_slots<> { SignalCandidateFilterChanged; protected: + // TODO(webrtc::13579): Remove std::string version once downstream users have + // migrated to the absl::string_view version. virtual PortAllocatorSession* CreateSessionInternal( const std::string& content_name, int component, const std::string& ice_ufrag, const std::string& ice_pwd) = 0; + virtual PortAllocatorSession* CreateSessionInternal( + absl::string_view content_name, + int component, + absl::string_view ice_ufrag, + absl::string_view ice_pwd); const std::vector>& pooled_sessions() { return pooled_sessions_; diff --git a/p2p/client/basic_port_allocator.cc b/p2p/client/basic_port_allocator.cc index 3a1488e66b..a8a0b622e0 100644 --- a/p2p/client/basic_port_allocator.cc +++ b/p2p/client/basic_port_allocator.cc @@ -20,6 +20,7 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" +#include "absl/strings/string_view.h" #include "api/transport/field_trial_based_config.h" #include "p2p/base/basic_packet_socket_factory.h" #include "p2p/base/port.h" @@ -258,9 +259,20 @@ PortAllocatorSession* BasicPortAllocator::CreateSessionInternal( int component, const std::string& ice_ufrag, const std::string& ice_pwd) { + return CreateSessionInternal(absl::string_view(content_name), component, + absl::string_view(ice_ufrag), + absl::string_view(ice_pwd)); +} + +PortAllocatorSession* BasicPortAllocator::CreateSessionInternal( + absl::string_view content_name, + int component, + absl::string_view ice_ufrag, + absl::string_view ice_pwd) { CheckRunOnValidThreadAndInitialized(); PortAllocatorSession* session = new BasicPortAllocatorSession( - this, content_name, component, ice_ufrag, ice_pwd); + this, std::string(content_name), component, std::string(ice_ufrag), + std::string(ice_pwd)); session->SignalIceRegathering.connect(this, &BasicPortAllocator::OnIceRegathering); return session; diff --git a/p2p/client/basic_port_allocator.h b/p2p/client/basic_port_allocator.h index 048b52749a..ae3a536055 100644 --- a/p2p/client/basic_port_allocator.h +++ b/p2p/client/basic_port_allocator.h @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/field_trials_view.h" #include "api/turn_customizer.h" #include "p2p/base/port_allocator.h" @@ -72,6 +73,11 @@ class RTC_EXPORT BasicPortAllocator : public PortAllocator { int component, const std::string& ice_ufrag, const std::string& ice_pwd) override; + PortAllocatorSession* CreateSessionInternal( + absl::string_view content_name, + int component, + absl::string_view ice_ufrag, + absl::string_view ice_pwd) override; // Convenience method that adds a TURN server to the configuration. void AddTurnServer(const RelayServerConfig& turn_server);