Replace std::string::find() == 0 with absl::StartsWith (part 2).

This CL has been generated using clang-tidy [1] except for changes to
BUILD.gn files.

[1] - https://clang.llvm.org/extra/clang-tidy/checks/abseil-string-find-startswith.html

Bug: None
Change-Id: Ibf75601065a53bde28623b8eef57bec067235640
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172586
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30984}
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn
index cb5ede0..21a5f6f 100644
--- a/api/video_codecs/BUILD.gn
+++ b/api/video_codecs/BUILD.gn
@@ -149,6 +149,7 @@
     "../video:video_frame",
     "../video:video_rtp_headers",
     "//third_party/abseil-cpp/absl/base:core_headers",
+    "//third_party/abseil-cpp/absl/strings",
     "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
diff --git a/api/video_codecs/video_encoder_software_fallback_wrapper.cc b/api/video_codecs/video_encoder_software_fallback_wrapper.cc
index 3b2ad4f..354e8c2 100644
--- a/api/video_codecs/video_encoder_software_fallback_wrapper.cc
+++ b/api/video_codecs/video_encoder_software_fallback_wrapper.cc
@@ -17,6 +17,7 @@
 #include <string>
 #include <vector>
 
+#include "absl/strings/match.h"
 #include "absl/types/optional.h"
 #include "api/fec_controller_override.h"
 #include "api/video/i420_buffer.h"
@@ -71,7 +72,7 @@
     const VideoEncoder& main_encoder) {
   const std::string field_trial =
       webrtc::field_trial::FindFullName(kVp8ForceFallbackEncoderFieldTrial);
-  if (field_trial.find("Enabled") != 0) {
+  if (!absl::StartsWith(field_trial, "Enabled")) {
     return absl::nullopt;
   }
 
diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc
index 3147a28..56c5e55 100644
--- a/call/rtp_transport_controller_send.cc
+++ b/call/rtp_transport_controller_send.cc
@@ -13,6 +13,7 @@
 #include <utility>
 #include <vector>
 
+#include "absl/strings/match.h"
 #include "absl/types/optional.h"
 #include "api/transport/goog_cc_factory.h"
 #include "api/transport/network_types.h"
@@ -60,7 +61,7 @@
 
 bool IsEnabled(const WebRtcKeyValueConfig* trials, absl::string_view key) {
   RTC_DCHECK(trials != nullptr);
-  return trials->Lookup(key).find("Enabled") == 0;
+  return absl::StartsWith(trials->Lookup(key), "Enabled");
 }
 
 bool IsRelayed(const rtc::NetworkRoute& route) {
diff --git a/modules/pacing/BUILD.gn b/modules/pacing/BUILD.gn
index d59d2b9..6f65c33 100644
--- a/modules/pacing/BUILD.gn
+++ b/modules/pacing/BUILD.gn
@@ -58,6 +58,7 @@
     "../rtp_rtcp:rtp_rtcp_format",
     "../utility",
     "//third_party/abseil-cpp/absl/memory",
+    "//third_party/abseil-cpp/absl/strings",
     "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
diff --git a/modules/pacing/paced_sender.cc b/modules/pacing/paced_sender.cc
index 3646952..cd298f9 100644
--- a/modules/pacing/paced_sender.cc
+++ b/modules/pacing/paced_sender.cc
@@ -15,6 +15,7 @@
 #include <vector>
 
 #include "absl/memory/memory.h"
+#include "absl/strings/match.h"
 #include "api/rtc_event_log/rtc_event_log.h"
 #include "modules/utility/include/process_thread.h"
 #include "rtc_base/checks.h"
@@ -27,21 +28,19 @@
 const int64_t PacedSender::kMaxQueueLengthMs = 2000;
 const float PacedSender::kDefaultPaceMultiplier = 2.5f;
 
-PacedSender::PacedSender(Clock* clock,
-                         PacketRouter* packet_router,
+PacedSender::PacedSender(Clock* clock, PacketRouter* packet_router,
                          RtcEventLog* event_log,
                          const WebRtcKeyValueConfig* field_trials,
                          ProcessThread* process_thread)
-    : process_mode_((field_trials != nullptr &&
-                     field_trials->Lookup("WebRTC-Pacer-DynamicProcess")
-                             .find("Enabled") == 0)
-                        ? PacingController::ProcessMode::kDynamic
-                        : PacingController::ProcessMode::kPeriodic),
+    : process_mode_(
+          (field_trials != nullptr &&
+           absl::StartsWith(field_trials->Lookup("WebRTC-Pacer-DynamicProcess"),
+                            "Enabled"))
+              ? PacingController::ProcessMode::kDynamic
+              : PacingController::ProcessMode::kPeriodic),
       pacing_controller_(clock,
                          static_cast<PacingController::PacketSender*>(this),
-                         event_log,
-                         field_trials,
-                         process_mode_),
+                         event_log, field_trials, process_mode_),
       clock_(clock),
       packet_router_(packet_router),
       process_thread_(process_thread) {
diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc
index 7b84877..f9ca408 100644
--- a/modules/pacing/pacing_controller.cc
+++ b/modules/pacing/pacing_controller.cc
@@ -15,6 +15,7 @@
 #include <utility>
 #include <vector>
 
+#include "absl/strings/match.h"
 #include "modules/pacing/bitrate_prober.h"
 #include "modules/pacing/interval_budget.h"
 #include "modules/utility/include/process_thread.h"
@@ -42,12 +43,12 @@
 
 bool IsDisabled(const WebRtcKeyValueConfig& field_trials,
                 absl::string_view key) {
-  return field_trials.Lookup(key).find("Disabled") == 0;
+  return absl::StartsWith(field_trials.Lookup(key), "Disabled");
 }
 
 bool IsEnabled(const WebRtcKeyValueConfig& field_trials,
                absl::string_view key) {
-  return field_trials.Lookup(key).find("Enabled") == 0;
+  return absl::StartsWith(field_trials.Lookup(key), "Enabled");
 }
 
 int GetPriorityForType(RtpPacketMediaType type) {
diff --git a/modules/pacing/round_robin_packet_queue.cc b/modules/pacing/round_robin_packet_queue.cc
index d61d441..6e4efb0 100644
--- a/modules/pacing/round_robin_packet_queue.cc
+++ b/modules/pacing/round_robin_packet_queue.cc
@@ -14,6 +14,7 @@
 #include <cstdint>
 #include <utility>
 
+#include "absl/strings/match.h"
 #include "rtc_base/checks.h"
 
 namespace webrtc {
@@ -105,7 +106,7 @@
   if (!field_trials) {
     return false;
   }
-  return field_trials->Lookup(name).find("Enabled") == 0;
+  return absl::StartsWith(field_trials->Lookup(name), "Enabled");
 }
 
 RoundRobinPacketQueue::RoundRobinPacketQueue(
diff --git a/modules/remote_bitrate_estimator/BUILD.gn b/modules/remote_bitrate_estimator/BUILD.gn
index 08233da..d7b0397 100644
--- a/modules/remote_bitrate_estimator/BUILD.gn
+++ b/modules/remote_bitrate_estimator/BUILD.gn
@@ -59,6 +59,7 @@
     "../../system_wrappers",
     "../../system_wrappers:field_trial",
     "../../system_wrappers:metrics",
+    "//third_party/abseil-cpp/absl/strings",
     "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc
index 95e0a33..da13176 100644
--- a/modules/remote_bitrate_estimator/aimd_rate_control.cc
+++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc
@@ -18,6 +18,7 @@
 #include <cstdio>
 #include <string>
 
+#include "absl/strings/match.h"
 #include "api/transport/network_types.h"
 #include "api/units/data_rate.h"
 #include "modules/remote_bitrate_estimator/include/bwe_defines.h"
@@ -37,12 +38,12 @@
 
 bool IsEnabled(const WebRtcKeyValueConfig& field_trials,
                absl::string_view key) {
-  return field_trials.Lookup(key).find("Enabled") == 0;
+  return absl::StartsWith(field_trials.Lookup(key), "Enabled");
 }
 
 bool IsNotDisabled(const WebRtcKeyValueConfig& field_trials,
                    absl::string_view key) {
-  return field_trials.Lookup(key).find("Disabled") != 0;
+  return !absl::StartsWith(field_trials.Lookup(key), "Disabled");
 }
 
 double ReadBackoffFactor(const WebRtcKeyValueConfig& key_value_config) {
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc
index 3c07eb5..26512c4 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -148,20 +148,19 @@
       packetization_overhead_bitrate_(1000, RateStatistics::kBpsScale),
       frame_encryptor_(config.frame_encryptor),
       require_frame_encryption_(config.require_frame_encryption),
-      generic_descriptor_auth_experiment_(
-          config.field_trials->Lookup("WebRTC-GenericDescriptorAuth")
-              .find("Disabled") != 0),
-      exclude_transport_sequence_number_from_fec_experiment_(
-          config.field_trials
-              ->Lookup(kExcludeTransportSequenceNumberFromFecFieldTrial)
-              .find("Enabled") == 0),
+      generic_descriptor_auth_experiment_(!absl::StartsWith(
+          config.field_trials->Lookup("WebRTC-GenericDescriptorAuth"),
+          "Disabled")),
+      exclude_transport_sequence_number_from_fec_experiment_(absl::StartsWith(
+          config.field_trials->Lookup(
+              kExcludeTransportSequenceNumberFromFecFieldTrial),
+          "Enabled")),
       absolute_capture_time_sender_(config.clock),
       frame_transformer_delegate_(
           config.frame_transformer
               ? new rtc::RefCountedObject<
                     RTPSenderVideoFrameTransformerDelegate>(
-                    this,
-                    std::move(config.frame_transformer))
+                    this, std::move(config.frame_transformer))
               : nullptr) {
   if (frame_transformer_delegate_)
     frame_transformer_delegate_->Init();
diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn
index 058e9b7..f557526 100644
--- a/rtc_base/experiments/BUILD.gn
+++ b/rtc_base/experiments/BUILD.gn
@@ -164,6 +164,7 @@
     "../../api/units:data_size",
     "../../api/video_codecs:video_codecs_api",
     "../../system_wrappers:field_trial",
+    "//third_party/abseil-cpp/absl/strings",
     "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
diff --git a/rtc_base/experiments/rate_control_settings.cc b/rtc_base/experiments/rate_control_settings.cc
index ce77c9e..ff5bb65 100644
--- a/rtc_base/experiments/rate_control_settings.cc
+++ b/rtc_base/experiments/rate_control_settings.cc
@@ -15,6 +15,7 @@
 
 #include <string>
 
+#include "absl/strings/match.h"
 #include "api/transport/field_trial_based_config.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/numerics/safe_conversions.h"
@@ -42,7 +43,7 @@
 
 bool IsEnabled(const WebRtcKeyValueConfig* const key_value_config,
                absl::string_view key) {
-  return key_value_config->Lookup(key).find("Enabled") == 0;
+  return absl::StartsWith(key_value_config->Lookup(key), "Enabled");
 }
 
 void ParseHysteresisFactor(const WebRtcKeyValueConfig* const key_value_config,
diff --git a/rtc_base/network_unittest.cc b/rtc_base/network_unittest.cc
index 4135864..d5aa8ac 100644
--- a/rtc_base/network_unittest.cc
+++ b/rtc_base/network_unittest.cc
@@ -15,6 +15,7 @@
 #include <memory>
 #include <vector>
 
+#include "absl/strings/match.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/net_helpers.h"
 #include "rtc_base/network_monitor.h"
@@ -47,10 +48,10 @@
   AdapterType GetAdapterType(const std::string& if_name) override {
     // Note that the name matching rules are different from the
     // GetAdapterTypeFromName in NetworkManager.
-    if (if_name.find("wifi") == 0) {
+    if (absl::StartsWith(if_name, "wifi")) {
       return ADAPTER_TYPE_WIFI;
     }
-    if (if_name.find("cellular") == 0) {
+    if (absl::StartsWith(if_name, "cellular")) {
       return ADAPTER_TYPE_CELLULAR;
     }
     return ADAPTER_TYPE_UNKNOWN;
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 29d5d6d..2e22476 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -128,6 +128,7 @@
     "../rtc_base:timeutils",
     "../rtc_base/task_utils:repeating_task",
     "../system_wrappers",
+    "//third_party/abseil-cpp/absl/strings",
   ]
 }
 
diff --git a/test/frame_generator_capturer.cc b/test/frame_generator_capturer.cc
index 3a298cc..9806c83 100644
--- a/test/frame_generator_capturer.cc
+++ b/test/frame_generator_capturer.cc
@@ -17,6 +17,7 @@
 #include <utility>
 #include <vector>
 
+#include "absl/strings/match.h"
 #include "api/test/create_frame_generator.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/critical_section.h"
@@ -34,7 +35,7 @@
   int ext_pos = path.rfind(".");
   if (ext_pos < 0) {
     return test::ResourcePath(path, "yuv");
-  } else if (path.find(resource_prefix) == 0) {
+  } else if (absl::StartsWith(path, resource_prefix)) {
     std::string name = path.substr(resource_prefix.length(), ext_pos);
     std::string ext = path.substr(ext_pos, path.size());
     return test::ResourcePath(name, ext);
diff --git a/test/scenario/BUILD.gn b/test/scenario/BUILD.gn
index ed66936..e2e5f8c 100644
--- a/test/scenario/BUILD.gn
+++ b/test/scenario/BUILD.gn
@@ -144,6 +144,7 @@
       "//third_party/abseil-cpp/absl/flags:flag",
       "//third_party/abseil-cpp/absl/flags:parse",
       "//third_party/abseil-cpp/absl/memory",
+      "//third_party/abseil-cpp/absl/strings",
       "//third_party/abseil-cpp/absl/types:optional",
     ]
     if (is_android) {
diff --git a/test/scenario/video_stream.cc b/test/scenario/video_stream.cc
index d842b1c..4bea740 100644
--- a/test/scenario/video_stream.cc
+++ b/test/scenario/video_stream.cc
@@ -13,6 +13,7 @@
 #include <memory>
 #include <utility>
 
+#include "absl/strings/match.h"
 #include "api/test/create_frame_generator.h"
 #include "api/test/frame_generator_interface.h"
 #include "api/test/video/function_video_encoder_factory.h"
@@ -112,7 +113,7 @@
   int ext_pos = path.rfind(".");
   if (ext_pos < 0) {
     return test::ResourcePath(path, "yuv");
-  } else if (path.find(resource_prefix) == 0) {
+  } else if (absl::StartsWith(path, resource_prefix)) {
     std::string name = path.substr(resource_prefix.length(), ext_pos);
     std::string ext = path.substr(ext_pos, path.size());
     return test::ResourcePath(name, ext);
diff --git a/video/BUILD.gn b/video/BUILD.gn
index a12cc03..14109c3 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -124,6 +124,7 @@
     "//third_party/abseil-cpp/absl/algorithm:container",
     "//third_party/abseil-cpp/absl/base:core_headers",
     "//third_party/abseil-cpp/absl/memory",
+    "//third_party/abseil-cpp/absl/strings",
     "//third_party/abseil-cpp/absl/types:optional",
   ]
 
diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc
index 1464605..e75b955 100644
--- a/video/send_statistics_proxy.cc
+++ b/video/send_statistics_proxy.cc
@@ -16,6 +16,7 @@
 #include <limits>
 #include <utility>
 
+#include "absl/strings/match.h"
 #include "api/video/video_codec_constants.h"
 #include "api/video/video_codec_type.h"
 #include "api/video_codecs/video_codec.h"
@@ -112,15 +113,17 @@
 absl::optional<int> GetFallbackMaxPixelsIfFieldTrialEnabled() {
   std::string group =
       webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial);
-  return (group.find("Enabled") == 0) ? GetFallbackMaxPixels(group.substr(7))
-                                      : absl::optional<int>();
+  return (absl::StartsWith(group, "Enabled"))
+             ? GetFallbackMaxPixels(group.substr(7))
+             : absl::optional<int>();
 }
 
 absl::optional<int> GetFallbackMaxPixelsIfFieldTrialDisabled() {
   std::string group =
       webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial);
-  return (group.find("Disabled") == 0) ? GetFallbackMaxPixels(group.substr(8))
-                                       : absl::optional<int>();
+  return (absl::StartsWith(group, "Disabled"))
+             ? GetFallbackMaxPixels(group.substr(8))
+             : absl::optional<int>();
 }
 }  // namespace