diff --git a/DEPS b/DEPS index 0dafe31d96..5eab1f29f4 100644 --- a/DEPS +++ b/DEPS @@ -1428,6 +1428,8 @@ include_rules = [ "+rtc_tools", # Abseil whitelist. Keep this in sync with abseil-in-webrtc.md. + "+absl/algorithm/algorithm.h", + "+absl/algorithm/container.h", "+absl/base/attributes.h", "+absl/container/inlined_vector.h", "+absl/memory/memory.h", diff --git a/abseil-in-webrtc.md b/abseil-in-webrtc.md index 1075aa9b79..117d515de4 100644 --- a/abseil-in-webrtc.md +++ b/abseil-in-webrtc.md @@ -20,6 +20,8 @@ adds the first use. `absl::is_trivially_copy_assignable`, and `absl::is_trivially_destructible` from `absl/meta/type_traits.h`. * `absl::variant` and related stuff from `absl/types/variant.h`. +* The functions in `absl/algorithm/algorithm.h` and + `absl/algorithm/container.h` ## **Disallowed** diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index 4ccb2fc1a0..6148105939 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -102,6 +102,7 @@ rtc_static_library("rtc_p2p") { "../rtc_base/third_party/sigslot", "../system_wrappers:field_trial", "../system_wrappers:metrics", + "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 6fee0249ba..89f919913e 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -10,11 +10,11 @@ #include "p2p/base/p2p_transport_channel.h" -#include #include #include #include +#include "absl/algorithm/container.h" #include "api/candidate.h" #include "logging/rtc_event_log/ice_logger.h" #include "p2p/base/candidate_pair_interface.h" @@ -1460,9 +1460,9 @@ void P2PTransportChannel::MaybeStartPinging() { } int64_t now = rtc::TimeMillis(); - if (std::any_of( - connections_.begin(), connections_.end(), - [this, now](const Connection* c) { return IsPingable(c, now); })) { + if (absl::c_any_of(connections_, [this, now](const Connection* c) { + return IsPingable(c, now); + })) { RTC_LOG(LS_INFO) << ToString() << ": Have a pingable connection for the first time; " "starting to ping."; @@ -1996,8 +1996,8 @@ void P2PTransportChannel::CheckAndPing() { // When the selected connection is not receiving or not writable, or any // active connection has not been pinged enough times, use the weak ping // interval. - bool need_more_pings_at_weak_interval = std::any_of( - connections_.begin(), connections_.end(), [](Connection* conn) { + bool need_more_pings_at_weak_interval = + absl::c_any_of(connections_, [](Connection* conn) { return conn->active() && conn->num_pings_sent() < MIN_PINGS_AT_WEAK_PING_INTERVAL; });