Replace rtc::Optional with absl::optional in rtc_base

This is a no-op change because rtc::Optional is an alias to absl::optional

This CL generated by running script with parameter 'rtc_base'
Then manually fix where Optional was used without rtc prefix (patchset#3)

find $@ -type f \( -name \*.h -o -name \*.cc \) \
-exec sed -i 's|rtc::Optional|absl::optional|g' {} \+ \
-exec sed -i 's|rtc::nullopt|absl::nullopt|g' {} \+ \
-exec sed -i 's|#include "api/optional.h"|#include "absl/types/optional.h"|' {} \+

find $@ -type f -name BUILD.gn \
-exec sed -r -i 's|"[\./api]*:optional"|"//third_party/abseil-cpp/absl/types:optional"|' {} \+;

git cl format

Bug: webrtc:9078
Change-Id: I825f80cc8089747876ba6316d9e7c30e05716974
Reviewed-on: https://webrtc-review.googlesource.com/84585
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23700}
diff --git a/p2p/base/fakepackettransport.h b/p2p/base/fakepackettransport.h
index cbff511..e57bc17 100644
--- a/p2p/base/fakepackettransport.h
+++ b/p2p/base/fakepackettransport.h
@@ -88,10 +88,10 @@
 
   const CopyOnWriteBuffer* last_sent_packet() { return &last_sent_packet_; }
 
-  Optional<NetworkRoute> network_route() const override {
+  absl::optional<NetworkRoute> network_route() const override {
     return network_route_;
   }
-  void SetNetworkRoute(Optional<NetworkRoute> network_route) {
+  void SetNetworkRoute(absl::optional<NetworkRoute> network_route) {
     network_route_ = network_route;
   }
 
@@ -132,7 +132,7 @@
   bool writable_ = false;
   bool receiving_ = false;
 
-  Optional<NetworkRoute> network_route_;
+  absl::optional<NetworkRoute> network_route_;
 };
 
 }  // namespace rtc
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index bcca552..effe58b 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -446,7 +446,7 @@
   deps += [
     "..:webrtc_common",
     "../api:array_view",
-    "../api:optional",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 
   if (is_android) {
@@ -661,7 +661,7 @@
     ":checks",
     ":rtc_base_approved",
     ":safe_compare",
-    "../api:optional",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -728,7 +728,7 @@
     ":stringutils",
     "..:webrtc_common",
     "../api:array_view",
-    "../api:optional",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
   public_deps = [
     ":rtc_base_approved",
@@ -1304,9 +1304,9 @@
       ":rtc_base_tests_utils",
       ":stringutils",
       "../api:array_view",
-      "../api:optional",
       "../test:fileutils",
       "../test:test_support",
+      "//third_party/abseil-cpp/absl/types:optional",
     ]
     public_deps = [
       ":rtc_base",
diff --git a/rtc_base/experiments/BUILD.gn b/rtc_base/experiments/BUILD.gn
index 8b2b062..a95e258 100644
--- a/rtc_base/experiments/BUILD.gn
+++ b/rtc_base/experiments/BUILD.gn
@@ -15,8 +15,8 @@
   ]
   deps = [
     "../:rtc_base_approved",
-    "../../api:optional",
     "../../system_wrappers:field_trial_api",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -29,11 +29,11 @@
   ]
   deps = [
     "../:rtc_base_approved",
-    "../../api:optional",
     "../../api/units:data_rate",
     "../../api/units:data_size",
     "../../api/units:time_delta",
     "../../system_wrappers:field_trial_api",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -44,8 +44,8 @@
   ]
   deps = [
     "../:rtc_base_approved",
-    "../../api:optional",
     "../../system_wrappers:field_trial_api",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
@@ -57,9 +57,9 @@
   deps = [
     "../:rtc_base_approved",
     "../..:webrtc_common",
-    "../../api:optional",
     "../../api/video_codecs:video_codecs_api",
     "../../system_wrappers:field_trial_api",
+    "//third_party/abseil-cpp/absl/types:optional",
   ]
 }
 
diff --git a/rtc_base/experiments/alr_experiment.cc b/rtc_base/experiments/alr_experiment.cc
index c69caed..dff5ace 100644
--- a/rtc_base/experiments/alr_experiment.cc
+++ b/rtc_base/experiments/alr_experiment.cc
@@ -31,9 +31,9 @@
              .empty();
 }
 
-rtc::Optional<AlrExperimentSettings>
+absl::optional<AlrExperimentSettings>
 AlrExperimentSettings::CreateFromFieldTrial(const char* experiment_name) {
-  rtc::Optional<AlrExperimentSettings> ret;
+  absl::optional<AlrExperimentSettings> ret;
   std::string group_name = field_trial::FindFullName(experiment_name);
 
   const std::string kIgnoredSuffix = "_Dogfood";
diff --git a/rtc_base/experiments/alr_experiment.h b/rtc_base/experiments/alr_experiment.h
index a9c483d..4d9fd00 100644
--- a/rtc_base/experiments/alr_experiment.h
+++ b/rtc_base/experiments/alr_experiment.h
@@ -11,7 +11,7 @@
 #ifndef RTC_BASE_EXPERIMENTS_ALR_EXPERIMENT_H_
 #define RTC_BASE_EXPERIMENTS_ALR_EXPERIMENT_H_
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 
 namespace webrtc {
 struct AlrExperimentSettings {
@@ -28,7 +28,7 @@
 
   static const char kScreenshareProbingBweExperimentName[];
   static const char kStrictPacingAndProbingExperimentName[];
-  static rtc::Optional<AlrExperimentSettings> CreateFromFieldTrial(
+  static absl::optional<AlrExperimentSettings> CreateFromFieldTrial(
       const char* experiment_name);
   static bool MaxOneFieldTrialEnabled();
 
diff --git a/rtc_base/experiments/congestion_controller_experiment.cc b/rtc_base/experiments/congestion_controller_experiment.cc
index 9fdaacd..b05ef71 100644
--- a/rtc_base/experiments/congestion_controller_experiment.cc
+++ b/rtc_base/experiments/congestion_controller_experiment.cc
@@ -31,10 +31,10 @@
   return trial_string.find("Enabled,Injected") == 0;
 }
 
-rtc::Optional<CongestionControllerExperiment::BbrExperimentConfig>
+absl::optional<CongestionControllerExperiment::BbrExperimentConfig>
 CongestionControllerExperiment::GetBbrExperimentConfig() {
   if (!BbrControllerEnabled())
-    return rtc::nullopt;
+    return absl::nullopt;
   std::string trial_string =
       webrtc::field_trial::FindFullName(kControllerExperiment);
   BbrExperimentConfig config;
@@ -56,7 +56,7 @@
           &config.probe_rtt_congestion_window_gain) == 17) {
     return config;
   } else {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 }
 
diff --git a/rtc_base/experiments/congestion_controller_experiment.h b/rtc_base/experiments/congestion_controller_experiment.h
index eba8926..5428a4f 100644
--- a/rtc_base/experiments/congestion_controller_experiment.h
+++ b/rtc_base/experiments/congestion_controller_experiment.h
@@ -34,7 +34,7 @@
   };
   static bool BbrControllerEnabled();
   static bool InjectedControllerEnabled();
-  static rtc::Optional<BbrExperimentConfig> GetBbrExperimentConfig();
+  static absl::optional<BbrExperimentConfig> GetBbrExperimentConfig();
 };
 
 }  // namespace webrtc
diff --git a/rtc_base/experiments/field_trial_parser.cc b/rtc_base/experiments/field_trial_parser.cc
index d2a3add..4ea603f 100644
--- a/rtc_base/experiments/field_trial_parser.cc
+++ b/rtc_base/experiments/field_trial_parser.cc
@@ -47,7 +47,7 @@
     int key_end = std::min(val_end, colon_pos);
     int val_begin = key_end + 1;
     std::string key = trial_string.substr(i, key_end - i);
-    rtc::Optional<std::string> opt_value;
+    absl::optional<std::string> opt_value;
     if (val_end >= val_begin)
       opt_value = trial_string.substr(val_begin, val_end - val_begin);
     i = val_end + 1;
@@ -65,37 +65,37 @@
 }
 
 template <>
-rtc::Optional<bool> ParseTypedParameter<bool>(std::string str) {
+absl::optional<bool> ParseTypedParameter<bool>(std::string str) {
   if (str == "true" || str == "1") {
     return true;
   } else if (str == "false" || str == "0") {
     return false;
   }
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 
 template <>
-rtc::Optional<double> ParseTypedParameter<double>(std::string str) {
+absl::optional<double> ParseTypedParameter<double>(std::string str) {
   double value;
   if (sscanf(str.c_str(), "%lf", &value) == 1) {
     return value;
   } else {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 }
 
 template <>
-rtc::Optional<int> ParseTypedParameter<int>(std::string str) {
+absl::optional<int> ParseTypedParameter<int>(std::string str) {
   int value;
   if (sscanf(str.c_str(), "%i", &value) == 1) {
     return value;
   } else {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 }
 
 template <>
-rtc::Optional<std::string> ParseTypedParameter<std::string>(std::string str) {
+absl::optional<std::string> ParseTypedParameter<std::string>(std::string str) {
   return std::move(str);
 }
 
@@ -108,10 +108,10 @@
   return value_;
 }
 
-bool FieldTrialFlag::Parse(rtc::Optional<std::string> str_value) {
+bool FieldTrialFlag::Parse(absl::optional<std::string> str_value) {
   // Only set the flag if there is no argument provided.
   if (str_value) {
-    rtc::Optional<bool> opt_value = ParseTypedParameter<bool>(*str_value);
+    absl::optional<bool> opt_value = ParseTypedParameter<bool>(*str_value);
     if (!opt_value)
       return false;
     value_ = *opt_value;
diff --git a/rtc_base/experiments/field_trial_parser.h b/rtc_base/experiments/field_trial_parser.h
index ba60499..ff00b90 100644
--- a/rtc_base/experiments/field_trial_parser.h
+++ b/rtc_base/experiments/field_trial_parser.h
@@ -13,7 +13,7 @@
 #include <stdint.h>
 #include <initializer_list>
 #include <string>
-#include "api/optional.h"
+#include "absl/types/optional.h"
 
 // Field trial parser functionality. Provides funcitonality to parse field trial
 // argument strings in key:value format. Each parameter is described using
@@ -39,7 +39,7 @@
   friend void ParseFieldTrial(
       std::initializer_list<FieldTrialParameterInterface*> fields,
       std::string raw_string);
-  virtual bool Parse(rtc::Optional<std::string> str_value) = 0;
+  virtual bool Parse(absl::optional<std::string> str_value) = 0;
   std::string Key() const;
 
  private:
@@ -52,10 +52,10 @@
     std::initializer_list<FieldTrialParameterInterface*> fields,
     std::string raw_string);
 
-// Specialize this in code file for custom types. Should return rtc::nullopt if
+// Specialize this in code file for custom types. Should return absl::nullopt if
 // the given string cannot be properly parsed.
 template <typename T>
-rtc::Optional<T> ParseTypedParameter(std::string);
+absl::optional<T> ParseTypedParameter(std::string);
 
 // This class uses the ParseTypedParameter function to implement a parameter
 // implementation with an enforced default value.
@@ -68,9 +68,9 @@
   operator T() const { return Get(); }
 
  protected:
-  bool Parse(rtc::Optional<std::string> str_value) override {
+  bool Parse(absl::optional<std::string> str_value) override {
     if (str_value) {
-      rtc::Optional<T> value = ParseTypedParameter<T>(*str_value);
+      absl::optional<T> value = ParseTypedParameter<T>(*str_value);
       if (value.has_value()) {
         value_ = value.value();
         return true;
@@ -84,31 +84,31 @@
 };
 
 // This class uses the ParseTypedParameter function to implement an optional
-// parameter implementation that can default to rtc::nullopt.
+// parameter implementation that can default to absl::nullopt.
 template <typename T>
 class FieldTrialOptional : public FieldTrialParameterInterface {
  public:
   explicit FieldTrialOptional(std::string key)
       : FieldTrialParameterInterface(key) {}
-  FieldTrialOptional(std::string key, rtc::Optional<T> default_value)
+  FieldTrialOptional(std::string key, absl::optional<T> default_value)
       : FieldTrialParameterInterface(key), value_(default_value) {}
-  rtc::Optional<T> Get() const { return value_; }
+  absl::optional<T> Get() const { return value_; }
 
  protected:
-  bool Parse(rtc::Optional<std::string> str_value) override {
+  bool Parse(absl::optional<std::string> str_value) override {
     if (str_value) {
-      rtc::Optional<T> value = ParseTypedParameter<T>(*str_value);
+      absl::optional<T> value = ParseTypedParameter<T>(*str_value);
       if (!value.has_value())
         return false;
       value_ = value.value();
     } else {
-      value_ = rtc::nullopt;
+      value_ = absl::nullopt;
     }
     return true;
   }
 
  private:
-  rtc::Optional<T> value_;
+  absl::optional<T> value_;
 };
 
 // Equivalent to a FieldTrialParameter<bool> in the case that both key and value
@@ -121,7 +121,7 @@
   bool Get() const;
 
  protected:
-  bool Parse(rtc::Optional<std::string> str_value) override;
+  bool Parse(absl::optional<std::string> str_value) override;
 
  private:
   bool value_;
diff --git a/rtc_base/experiments/field_trial_parser_unittest.cc b/rtc_base/experiments/field_trial_parser_unittest.cc
index 6c343fc..73bddfd 100644
--- a/rtc_base/experiments/field_trial_parser_unittest.cc
+++ b/rtc_base/experiments/field_trial_parser_unittest.cc
@@ -43,14 +43,14 @@
 // Providing a custom parser for an enum can make the trial string easier to
 // read, but also adds more code and makes the string more verbose.
 template <>
-rtc::Optional<CustomEnum> ParseTypedParameter<CustomEnum>(std::string str) {
+absl::optional<CustomEnum> ParseTypedParameter<CustomEnum>(std::string str) {
   if (str == "default")
     return CustomEnum::kDefault;
   else if (str == "red")
     return CustomEnum::kRed;
   else if (str == "blue")
     return CustomEnum::kBlue;
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 
 TEST(FieldTrialParserTest, ParsesValidParameters) {
@@ -104,7 +104,7 @@
   EXPECT_EQ(exp.hash.Get(), "a80");
 }
 TEST(FieldTrialParserTest, ParsesOptionalParameters) {
-  FieldTrialOptional<int> max_count("c", rtc::nullopt);
+  FieldTrialOptional<int> max_count("c", absl::nullopt);
   ParseFieldTrial({&max_count}, "");
   EXPECT_FALSE(max_count.Get().has_value());
   ParseFieldTrial({&max_count}, "c:10");
diff --git a/rtc_base/experiments/field_trial_units.cc b/rtc_base/experiments/field_trial_units.cc
index 94af4a7..f53978b 100644
--- a/rtc_base/experiments/field_trial_units.cc
+++ b/rtc_base/experiments/field_trial_units.cc
@@ -12,7 +12,7 @@
 #include <limits>
 #include <string>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 
 // Large enough to fit "seconds", the longest supported unit name.
 #define RTC_TRIAL_UNIT_LENGTH_STR "7"
@@ -26,7 +26,7 @@
   std::string unit;
 };
 
-rtc::Optional<ValueWithUnit> ParseValueWithUnit(std::string str) {
+absl::optional<ValueWithUnit> ParseValueWithUnit(std::string str) {
   if (str == "inf") {
     return ValueWithUnit{std::numeric_limits<double>::infinity(), ""};
   } else if (str == "-inf") {
@@ -40,13 +40,13 @@
       return ValueWithUnit{double_val, unit_char};
     }
   }
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 }  // namespace
 
 template <>
-rtc::Optional<DataRate> ParseTypedParameter<DataRate>(std::string str) {
-  rtc::Optional<ValueWithUnit> result = ParseValueWithUnit(str);
+absl::optional<DataRate> ParseTypedParameter<DataRate>(std::string str) {
+  absl::optional<ValueWithUnit> result = ParseValueWithUnit(str);
   if (result) {
     if (result->unit.empty() || result->unit == "kbps") {
       return DataRate::kbps(result->value);
@@ -54,22 +54,22 @@
       return DataRate::bps(result->value);
     }
   }
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 
 template <>
-rtc::Optional<DataSize> ParseTypedParameter<DataSize>(std::string str) {
-  rtc::Optional<ValueWithUnit> result = ParseValueWithUnit(str);
+absl::optional<DataSize> ParseTypedParameter<DataSize>(std::string str) {
+  absl::optional<ValueWithUnit> result = ParseValueWithUnit(str);
   if (result) {
     if (result->unit.empty() || result->unit == "bytes")
       return DataSize::bytes(result->value);
   }
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 
 template <>
-rtc::Optional<TimeDelta> ParseTypedParameter<TimeDelta>(std::string str) {
-  rtc::Optional<ValueWithUnit> result = ParseValueWithUnit(str);
+absl::optional<TimeDelta> ParseTypedParameter<TimeDelta>(std::string str) {
+  absl::optional<ValueWithUnit> result = ParseValueWithUnit(str);
   if (result) {
     if (result->unit == "s" || result->unit == "seconds") {
       return TimeDelta::seconds(result->value);
@@ -79,7 +79,7 @@
       return TimeDelta::ms(result->value);
     }
   }
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 
 template class FieldTrialParameter<DataRate>;
diff --git a/rtc_base/experiments/field_trial_units_unittest.cc b/rtc_base/experiments/field_trial_units_unittest.cc
index da76f5a..1a2b75d 100644
--- a/rtc_base/experiments/field_trial_units_unittest.cc
+++ b/rtc_base/experiments/field_trial_units_unittest.cc
@@ -21,7 +21,7 @@
   FieldTrialParameter<TimeDelta> period =
       FieldTrialParameter<TimeDelta>("p", TimeDelta::ms(100));
   FieldTrialOptional<DataSize> max_buffer =
-      FieldTrialOptional<DataSize>("b", rtc::nullopt);
+      FieldTrialOptional<DataSize>("b", absl::nullopt);
 
   explicit DummyExperiment(std::string field_trial) {
     ParseFieldTrial({&target_rate, &max_buffer, &period}, field_trial);
diff --git a/rtc_base/experiments/quality_scaling_experiment.cc b/rtc_base/experiments/quality_scaling_experiment.cc
index 8c99954..c13de3f 100644
--- a/rtc_base/experiments/quality_scaling_experiment.cc
+++ b/rtc_base/experiments/quality_scaling_experiment.cc
@@ -23,14 +23,14 @@
 constexpr int kMaxH264Qp = 51;
 constexpr int kMaxGenericQp = 255;
 
-rtc::Optional<VideoEncoder::QpThresholds> GetThresholds(int low,
-                                                        int high,
-                                                        int max) {
+absl::optional<VideoEncoder::QpThresholds> GetThresholds(int low,
+                                                         int high,
+                                                         int max) {
   if (low < kMinQp || high > max || high < low)
-    return rtc::nullopt;
+    return absl::nullopt;
 
   RTC_LOG(LS_INFO) << "QP thresholds: low: " << low << ", high: " << high;
-  return rtc::Optional<VideoEncoder::QpThresholds>(
+  return absl::optional<VideoEncoder::QpThresholds>(
       VideoEncoder::QpThresholds(low, high));
 }
 }  // namespace
@@ -39,11 +39,11 @@
   return webrtc::field_trial::IsEnabled(kFieldTrial);
 }
 
-rtc::Optional<QualityScalingExperiment::Settings>
+absl::optional<QualityScalingExperiment::Settings>
 QualityScalingExperiment::ParseSettings() {
   const std::string group = webrtc::field_trial::FindFullName(kFieldTrial);
   if (group.empty())
-    return rtc::nullopt;
+    return absl::nullopt;
 
   Settings s;
   if (sscanf(group.c_str(), "Enabled-%d,%d,%d,%d,%d,%d,%d,%d,%f,%f,%d",
@@ -51,16 +51,16 @@
              &s.h264_high, &s.generic_low, &s.generic_high, &s.alpha_high,
              &s.alpha_low, &s.drop) != 11) {
     RTC_LOG(LS_WARNING) << "Invalid number of parameters provided.";
-    return rtc::nullopt;
+    return absl::nullopt;
   }
   return s;
 }
 
-rtc::Optional<VideoEncoder::QpThresholds>
+absl::optional<VideoEncoder::QpThresholds>
 QualityScalingExperiment::GetQpThresholds(VideoCodecType codec_type) {
   const auto settings = ParseSettings();
   if (!settings)
-    return rtc::nullopt;
+    return absl::nullopt;
 
   switch (codec_type) {
     case kVideoCodecVP8:
@@ -73,7 +73,7 @@
       return GetThresholds(settings->generic_low, settings->generic_high,
                            kMaxGenericQp);
     default:
-      return rtc::nullopt;
+      return absl::nullopt;
   }
 }
 
diff --git a/rtc_base/experiments/quality_scaling_experiment.h b/rtc_base/experiments/quality_scaling_experiment.h
index 6f24d6b..80a25ef 100644
--- a/rtc_base/experiments/quality_scaling_experiment.h
+++ b/rtc_base/experiments/quality_scaling_experiment.h
@@ -10,7 +10,7 @@
 #ifndef RTC_BASE_EXPERIMENTS_QUALITY_SCALING_EXPERIMENT_H_
 #define RTC_BASE_EXPERIMENTS_QUALITY_SCALING_EXPERIMENT_H_
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "api/video_codecs/video_encoder.h"
 #include "common_types.h"  // NOLINT(build/include)
 
@@ -44,10 +44,10 @@
   static bool Enabled();
 
   // Returns settings from field trial.
-  static rtc::Optional<Settings> ParseSettings();
+  static absl::optional<Settings> ParseSettings();
 
   // Returns QpThresholds for the |codec_type|.
-  static rtc::Optional<VideoEncoder::QpThresholds> GetQpThresholds(
+  static absl::optional<VideoEncoder::QpThresholds> GetQpThresholds(
       VideoCodecType codec_type);
 
   // Returns parsed values. If the parsing fails, default values are returned.
diff --git a/rtc_base/numerics/histogram_percentile_counter.cc b/rtc_base/numerics/histogram_percentile_counter.cc
index 87ebd53..4bc8cb0 100644
--- a/rtc_base/numerics/histogram_percentile_counter.cc
+++ b/rtc_base/numerics/histogram_percentile_counter.cc
@@ -48,12 +48,12 @@
   Add(value, 1);
 }
 
-rtc::Optional<uint32_t> HistogramPercentileCounter::GetPercentile(
+absl::optional<uint32_t> HistogramPercentileCounter::GetPercentile(
     float fraction) {
   RTC_CHECK_LE(fraction, 1.0);
   RTC_CHECK_GE(fraction, 0.0);
   if (total_elements_ == 0)
-    return rtc::nullopt;
+    return absl::nullopt;
   size_t elements_to_skip = static_cast<size_t>(
       std::max(0.0f, std::ceil(total_elements_ * fraction) - 1));
   if (elements_to_skip >= total_elements_)
@@ -73,7 +73,7 @@
     }
   }
   RTC_NOTREACHED();
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 
 }  // namespace rtc
diff --git a/rtc_base/numerics/histogram_percentile_counter.h b/rtc_base/numerics/histogram_percentile_counter.h
index 4ad2e53..7e5743f 100644
--- a/rtc_base/numerics/histogram_percentile_counter.h
+++ b/rtc_base/numerics/histogram_percentile_counter.h
@@ -15,7 +15,7 @@
 #include <map>
 #include <vector>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 
 namespace rtc {
 // Calculates percentiles on the stream of data. Use |Add| methods to add new
@@ -30,7 +30,7 @@
   void Add(uint32_t value, size_t count);
   void Add(const HistogramPercentileCounter& other);
   // Argument should be from 0 to 1.
-  rtc::Optional<uint32_t> GetPercentile(float fraction);
+  absl::optional<uint32_t> GetPercentile(float fraction);
 
  private:
   std::vector<size_t> histogram_low_;
diff --git a/rtc_base/numerics/moving_max_counter.h b/rtc_base/numerics/moving_max_counter.h
index 4595cf3..6c6286d 100644
--- a/rtc_base/numerics/moving_max_counter.h
+++ b/rtc_base/numerics/moving_max_counter.h
@@ -17,7 +17,7 @@
 #include <limits>
 #include <utility>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/constructormagic.h"
 
@@ -40,7 +40,7 @@
   // Advances the current time, and returns the maximum sample in the time
   // window ending at the current time. The new current time must be at least as
   // large as the old current time.
-  rtc::Optional<T> Max(int64_t current_time_ms);
+  absl::optional<T> Max(int64_t current_time_ms);
   void Reset();
 
  private:
@@ -83,9 +83,9 @@
 }
 
 template <class T>
-rtc::Optional<T> MovingMaxCounter<T>::Max(int64_t current_time_ms) {
+absl::optional<T> MovingMaxCounter<T>::Max(int64_t current_time_ms) {
   RollWindow(current_time_ms);
-  rtc::Optional<T> res;
+  absl::optional<T> res;
   if (!samples_.empty()) {
     res.emplace(samples_.front().second);
   }
diff --git a/rtc_base/numerics/sample_counter.cc b/rtc_base/numerics/sample_counter.cc
index 037fddc..d9244c3 100644
--- a/rtc_base/numerics/sample_counter.cc
+++ b/rtc_base/numerics/sample_counter.cc
@@ -54,24 +54,24 @@
     max_ = other.max_;
 }
 
-rtc::Optional<int> SampleCounter::Avg(int64_t min_required_samples) const {
+absl::optional<int> SampleCounter::Avg(int64_t min_required_samples) const {
   RTC_DCHECK_GT(min_required_samples, 0);
   if (num_samples_ < min_required_samples)
-    return rtc::nullopt;
+    return absl::nullopt;
   return rtc::dchecked_cast<int>(sum_ / num_samples_);
 }
 
-rtc::Optional<int64_t> SampleCounter::Variance(
+absl::optional<int64_t> SampleCounter::Variance(
     int64_t min_required_samples) const {
   RTC_DCHECK_GT(min_required_samples, 0);
   if (num_samples_ < min_required_samples)
-    return rtc::nullopt;
+    return absl::nullopt;
   // E[(x-mean)^2] = E[x^2] - mean^2
   int64_t mean = sum_ / num_samples_;
   return sum_squared_ / num_samples_ - mean * mean;
 }
 
-rtc::Optional<int> SampleCounter::Max() const {
+absl::optional<int> SampleCounter::Max() const {
   return max_;
 }
 
diff --git a/rtc_base/numerics/sample_counter.h b/rtc_base/numerics/sample_counter.h
index 0de6f25..643754e 100644
--- a/rtc_base/numerics/sample_counter.h
+++ b/rtc_base/numerics/sample_counter.h
@@ -11,7 +11,7 @@
 #ifndef RTC_BASE_NUMERICS_SAMPLE_COUNTER_H_
 #define RTC_BASE_NUMERICS_SAMPLE_COUNTER_H_
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 
 namespace rtc {
 
@@ -22,9 +22,9 @@
   SampleCounter();
   ~SampleCounter();
   void Add(int sample);
-  rtc::Optional<int> Avg(int64_t min_required_samples) const;
-  rtc::Optional<int64_t> Variance(int64_t min_required_samples) const;
-  rtc::Optional<int> Max() const;
+  absl::optional<int> Avg(int64_t min_required_samples) const;
+  absl::optional<int64_t> Variance(int64_t min_required_samples) const;
+  absl::optional<int> Max() const;
   void Reset();
   // Adds all the samples from the |other| SampleCounter as if they were all
   // individually added using |Add(int)| method.
@@ -34,7 +34,7 @@
   int64_t sum_ = 0;
   int64_t sum_squared_ = 0;
   int64_t num_samples_ = 0;
-  rtc::Optional<int> max_;
+  absl::optional<int> max_;
 };
 
 }  // namespace rtc
diff --git a/rtc_base/numerics/sample_counter_unittest.cc b/rtc_base/numerics/sample_counter_unittest.cc
index 844ea4a..898f00c 100644
--- a/rtc_base/numerics/sample_counter_unittest.cc
+++ b/rtc_base/numerics/sample_counter_unittest.cc
@@ -23,9 +23,9 @@
 TEST(SampleCounterTest, ProcessesNoSamples) {
   constexpr int kMinSamples = 1;
   SampleCounter counter;
-  EXPECT_THAT(counter.Avg(kMinSamples), Eq(rtc::nullopt));
-  EXPECT_THAT(counter.Avg(kMinSamples), Eq(rtc::nullopt));
-  EXPECT_THAT(counter.Max(), Eq(rtc::nullopt));
+  EXPECT_THAT(counter.Avg(kMinSamples), Eq(absl::nullopt));
+  EXPECT_THAT(counter.Avg(kMinSamples), Eq(absl::nullopt));
+  EXPECT_THAT(counter.Max(), Eq(absl::nullopt));
 }
 
 TEST(SampleCounterTest, NotEnoughSamples) {
@@ -34,8 +34,8 @@
   for (int value : {1, 2, 3, 4, 5}) {
     counter.Add(value);
   }
-  EXPECT_THAT(counter.Avg(kMinSamples), Eq(rtc::nullopt));
-  EXPECT_THAT(counter.Avg(kMinSamples), Eq(rtc::nullopt));
+  EXPECT_THAT(counter.Avg(kMinSamples), Eq(absl::nullopt));
+  EXPECT_THAT(counter.Avg(kMinSamples), Eq(absl::nullopt));
   EXPECT_THAT(counter.Max(), Eq(5));
 }
 
diff --git a/rtc_base/numerics/sequence_number_util.h b/rtc_base/numerics/sequence_number_util.h
index 9e4b844..c55513a 100644
--- a/rtc_base/numerics/sequence_number_util.h
+++ b/rtc_base/numerics/sequence_number_util.h
@@ -14,7 +14,7 @@
 #include <limits>
 #include <type_traits>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "rtc_base/numerics/mod_ops.h"
 #include "rtc_base/numerics/safe_compare.h"
 
@@ -120,7 +120,7 @@
 
  private:
   uint64_t last_unwrapped_;
-  rtc::Optional<T> last_value_;
+  absl::optional<T> last_value_;
 };
 
 }  // namespace webrtc
diff --git a/rtc_base/rate_limiter.cc b/rtc_base/rate_limiter.cc
index 34e0a40..0343f25 100644
--- a/rtc_base/rate_limiter.cc
+++ b/rtc_base/rate_limiter.cc
@@ -29,7 +29,7 @@
 bool RateLimiter::TryUseRate(size_t packet_size_bytes) {
   rtc::CritScope cs(&lock_);
   int64_t now_ms = clock_->TimeInMilliseconds();
-  rtc::Optional<uint32_t> current_rate = current_rate_.Rate(now_ms);
+  absl::optional<uint32_t> current_rate = current_rate_.Rate(now_ms);
   if (current_rate) {
     // If there is a current rate, check if adding bytes would cause maximum
     // bitrate target to be exceeded. If there is NOT a valid current rate,
diff --git a/rtc_base/rate_statistics.cc b/rtc_base/rate_statistics.cc
index e2d6b11..9b1ff8f 100644
--- a/rtc_base/rate_statistics.cc
+++ b/rtc_base/rate_statistics.cc
@@ -61,7 +61,7 @@
   ++num_samples_;
 }
 
-rtc::Optional<uint32_t> RateStatistics::Rate(int64_t now_ms) const {
+absl::optional<uint32_t> RateStatistics::Rate(int64_t now_ms) const {
   // Yeah, this const_cast ain't pretty, but the alternative is to declare most
   // of the members as mutable...
   const_cast<RateStatistics*>(this)->EraseOld(now_ms);
@@ -71,7 +71,7 @@
   int64_t active_window_size = now_ms - oldest_time_ + 1;
   if (num_samples_ == 0 || active_window_size <= 1 ||
       (num_samples_ <= 1 && active_window_size < current_window_size_ms_)) {
-    return rtc::nullopt;
+    return absl::nullopt;
   }
 
   float scale = scale_ / active_window_size;
diff --git a/rtc_base/rate_statistics.h b/rtc_base/rate_statistics.h
index aa28529..fe5ae82 100644
--- a/rtc_base/rate_statistics.h
+++ b/rtc_base/rate_statistics.h
@@ -13,7 +13,7 @@
 
 #include <memory>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "typedefs.h"  // NOLINT(build/include)
 
 namespace webrtc {
@@ -42,7 +42,7 @@
   // from a monotonic clock. Ie, it doesn't matter if this call moves the
   // window, since any subsequent call to Update or Rate would still have moved
   // the window as much or more.
-  rtc::Optional<uint32_t> Rate(int64_t now_ms) const;
+  absl::optional<uint32_t> Rate(int64_t now_ms) const;
 
   // Update the size of the averaging window. The maximum allowed value for
   // window_size_ms is max_window_size_ms as supplied in the constructor.
diff --git a/rtc_base/rate_statistics_unittest.cc b/rtc_base/rate_statistics_unittest.cc
index 51249b1..62f1486 100644
--- a/rtc_base/rate_statistics_unittest.cc
+++ b/rtc_base/rate_statistics_unittest.cc
@@ -53,7 +53,7 @@
     // Approximately 1200 kbps expected. Not exact since when packets
     // are removed we will jump 10 ms to the next packet.
     if (i > kInterval) {
-      rtc::Optional<uint32_t> rate = stats_.Rate(now_ms);
+      absl::optional<uint32_t> rate = stats_.Rate(now_ms);
       EXPECT_TRUE(static_cast<bool>(rate));
       uint32_t samples = i / kInterval + 1;
       uint64_t total_bits = samples * kPacketSize * 8;
@@ -78,7 +78,7 @@
   const uint32_t kExpectedBitrate = 8000000;
   // 1000 bytes per millisecond until plateau is reached.
   int prev_error = kExpectedBitrate;
-  rtc::Optional<uint32_t> bitrate;
+  absl::optional<uint32_t> bitrate;
   while (++now_ms < 10000) {
     stats_.Update(1000, now_ms);
     bitrate = stats_.Rate(now_ms);
@@ -102,7 +102,7 @@
   // Zero bytes per millisecond until 0 is reached.
   while (++now_ms < 20000) {
     stats_.Update(0, now_ms);
-    rtc::Optional<uint32_t> new_bitrate = stats_.Rate(now_ms);
+    absl::optional<uint32_t> new_bitrate = stats_.Rate(now_ms);
     if (static_cast<bool>(new_bitrate) && *new_bitrate != *bitrate) {
       // New bitrate must be lower than previous one.
       EXPECT_LT(*new_bitrate, *bitrate);
@@ -130,7 +130,7 @@
   const uint32_t kExpectedBitrate = 8000000;
   // 1000 bytes per millisecond until the window has been filled.
   int prev_error = kExpectedBitrate;
-  rtc::Optional<uint32_t> bitrate;
+  absl::optional<uint32_t> bitrate;
   while (++now_ms < 10000) {
     stats_.Update(1000, now_ms);
     bitrate = stats_.Rate(now_ms);
@@ -213,7 +213,7 @@
 
   // Window size should be full, and the single data point should be accepted.
   ++now_ms;
-  rtc::Optional<uint32_t> bitrate = stats_.Rate(now_ms);
+  absl::optional<uint32_t> bitrate = stats_.Rate(now_ms);
   EXPECT_TRUE(static_cast<bool>(bitrate));
   EXPECT_EQ(1000 * 8u, *bitrate);
 
@@ -239,7 +239,7 @@
   stats_.Update(kWindowMs, now_ms);
   now_ms += kWindowMs - 1;
   stats_.Update(0, now_ms);
-  rtc::Optional<uint32_t> bitrate = stats_.Rate(now_ms);
+  absl::optional<uint32_t> bitrate = stats_.Rate(now_ms);
   EXPECT_TRUE(static_cast<bool>(bitrate));
   EXPECT_EQ(1000 * 8u, *bitrate);
 
@@ -262,7 +262,7 @@
 
   stats_.Update(0, now_ms);
   now_ms += kWindowMs - 1;
-  rtc::Optional<uint32_t> bitrate = stats_.Rate(now_ms);
+  absl::optional<uint32_t> bitrate = stats_.Rate(now_ms);
   EXPECT_TRUE(static_cast<bool>(bitrate));
   EXPECT_EQ(0u, *bitrate);
 
diff --git a/rtc_base/rtccertificategenerator.cc b/rtc_base/rtccertificategenerator.cc
index c984746..0b51c61 100644
--- a/rtc_base/rtccertificategenerator.cc
+++ b/rtc_base/rtccertificategenerator.cc
@@ -42,7 +42,7 @@
       Thread* signaling_thread,
       Thread* worker_thread,
       const KeyParams& key_params,
-      const Optional<uint64_t>& expires_ms,
+      const absl::optional<uint64_t>& expires_ms,
       const scoped_refptr<RTCCertificateGeneratorCallback>& callback)
       : signaling_thread_(signaling_thread),
         worker_thread_(worker_thread),
@@ -94,7 +94,7 @@
   Thread* const signaling_thread_;
   Thread* const worker_thread_;
   const KeyParams key_params_;
-  const Optional<uint64_t> expires_ms_;
+  const absl::optional<uint64_t> expires_ms_;
   const scoped_refptr<RTCCertificateGeneratorCallback> callback_;
   scoped_refptr<RTCCertificate> certificate_;
 };
@@ -104,7 +104,7 @@
 // static
 scoped_refptr<RTCCertificate> RTCCertificateGenerator::GenerateCertificate(
     const KeyParams& key_params,
-    const Optional<uint64_t>& expires_ms) {
+    const absl::optional<uint64_t>& expires_ms) {
   if (!key_params.IsValid())
     return nullptr;
   SSLIdentity* identity;
@@ -139,7 +139,7 @@
 
 void RTCCertificateGenerator::GenerateCertificateAsync(
     const KeyParams& key_params,
-    const Optional<uint64_t>& expires_ms,
+    const absl::optional<uint64_t>& expires_ms,
     const scoped_refptr<RTCCertificateGeneratorCallback>& callback) {
   RTC_DCHECK(signaling_thread_->IsCurrent());
   RTC_DCHECK(callback);
diff --git a/rtc_base/rtccertificategenerator.h b/rtc_base/rtccertificategenerator.h
index df1be44..a6c503a 100644
--- a/rtc_base/rtccertificategenerator.h
+++ b/rtc_base/rtccertificategenerator.h
@@ -11,7 +11,7 @@
 #ifndef RTC_BASE_RTCCERTIFICATEGENERATOR_H_
 #define RTC_BASE_RTCCERTIFICATEGENERATOR_H_
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "rtc_base/refcount.h"
 #include "rtc_base/rtccertificate.h"
 #include "rtc_base/scoped_ref_ptr.h"
@@ -43,7 +43,7 @@
   // its own restrictions on the expiration time.
   virtual void GenerateCertificateAsync(
       const KeyParams& key_params,
-      const Optional<uint64_t>& expires_ms,
+      const absl::optional<uint64_t>& expires_ms,
       const scoped_refptr<RTCCertificateGeneratorCallback>& callback) = 0;
 };
 
@@ -60,7 +60,7 @@
   // specified, a default expiration time is used.
   static scoped_refptr<RTCCertificate> GenerateCertificate(
       const KeyParams& key_params,
-      const Optional<uint64_t>& expires_ms);
+      const absl::optional<uint64_t>& expires_ms);
 
   RTCCertificateGenerator(Thread* signaling_thread, Thread* worker_thread);
   ~RTCCertificateGenerator() override {}
@@ -72,7 +72,7 @@
   // specified, a default expiration time is used.
   void GenerateCertificateAsync(
       const KeyParams& key_params,
-      const Optional<uint64_t>& expires_ms,
+      const absl::optional<uint64_t>& expires_ms,
       const scoped_refptr<RTCCertificateGeneratorCallback>& callback) override;
 
  private:
diff --git a/rtc_base/rtccertificategenerator_unittest.cc b/rtc_base/rtccertificategenerator_unittest.cc
index baf0475..3929128 100644
--- a/rtc_base/rtccertificategenerator_unittest.cc
+++ b/rtc_base/rtccertificategenerator_unittest.cc
@@ -12,7 +12,7 @@
 
 #include <memory>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/gunit.h"
 #include "rtc_base/logging.h"
@@ -79,19 +79,19 @@
 };
 
 TEST_F(RTCCertificateGeneratorTest, GenerateECDSA) {
-  EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate(
-      KeyParams::ECDSA(), Optional<uint64_t>()));
+  EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate(KeyParams::ECDSA(),
+                                                           absl::nullopt));
 }
 
 TEST_F(RTCCertificateGeneratorTest, GenerateRSA) {
-  EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate(
-      KeyParams::RSA(), Optional<uint64_t>()));
+  EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate(KeyParams::RSA(),
+                                                           absl::nullopt));
 }
 
 TEST_F(RTCCertificateGeneratorTest, GenerateAsyncECDSA) {
   EXPECT_FALSE(fixture_->certificate());
-  fixture_->generator()->GenerateCertificateAsync(
-      KeyParams::ECDSA(), Optional<uint64_t>(), fixture_);
+  fixture_->generator()->GenerateCertificateAsync(KeyParams::ECDSA(),
+                                                  absl::nullopt, fixture_);
   // Until generation has completed, the certificate is null. Since this is an
   // async call, generation must not have completed until we process messages
   // posted to this thread (which is done by |EXPECT_TRUE_WAIT|).
@@ -110,15 +110,14 @@
 
   // Generate a certificate that expires immediately.
   scoped_refptr<RTCCertificate> cert_a =
-      RTCCertificateGenerator::GenerateCertificate(KeyParams::ECDSA(),
-                                                   Optional<uint64_t>(0));
+      RTCCertificateGenerator::GenerateCertificate(KeyParams::ECDSA(), 0);
   EXPECT_TRUE(cert_a);
 
   // Generate a certificate that expires in one minute.
   const uint64_t kExpiresMs = 60000;
   scoped_refptr<RTCCertificate> cert_b =
-      RTCCertificateGenerator::GenerateCertificate(
-          KeyParams::ECDSA(), Optional<uint64_t>(kExpiresMs));
+      RTCCertificateGenerator::GenerateCertificate(KeyParams::ECDSA(),
+                                                   kExpiresMs);
   EXPECT_TRUE(cert_b);
 
   // Verify that |cert_b| expires approximately |kExpiresMs| after |cert_a|
@@ -133,11 +132,11 @@
   KeyParams invalid_params = KeyParams::RSA(0, 0);
   EXPECT_FALSE(invalid_params.IsValid());
 
-  EXPECT_FALSE(RTCCertificateGenerator::GenerateCertificate(
-      invalid_params, Optional<uint64_t>()));
+  EXPECT_FALSE(RTCCertificateGenerator::GenerateCertificate(invalid_params,
+                                                            absl::nullopt));
 
-  fixture_->generator()->GenerateCertificateAsync(
-      invalid_params, Optional<uint64_t>(), fixture_);
+  fixture_->generator()->GenerateCertificateAsync(invalid_params, absl::nullopt,
+                                                  fixture_);
   EXPECT_TRUE_WAIT(fixture_->GenerateAsyncCompleted(), kGenerationTimeoutMs);
   EXPECT_FALSE(fixture_->certificate());
 }
diff --git a/rtc_base/socket.h b/rtc_base/socket.h
index 5950989..b8290bb 100644
--- a/rtc_base/socket.h
+++ b/rtc_base/socket.h
@@ -25,7 +25,7 @@
 #include "rtc_base/win32.h"
 #endif
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 #include "rtc_base/constructormagic.h"
 #include "rtc_base/socketaddress.h"
 
@@ -147,8 +147,8 @@
 
   PacketType packet_type = PacketType::kUnknown;
   PacketInfoProtocolType protocol = PacketInfoProtocolType::kUnknown;
-  // A unique id assigned by the network manager, and rtc::nullopt if not set.
-  rtc::Optional<uint16_t> network_id;
+  // A unique id assigned by the network manager, and absl::nullopt if not set.
+  absl::optional<uint16_t> network_id;
   size_t packet_size_bytes = 0;
   size_t turn_overhead_bytes = 0;
   SocketAddress local_socket_address;
diff --git a/rtc_base/string_to_number.cc b/rtc_base/string_to_number.cc
index fe17f34..06ac9e9 100644
--- a/rtc_base/string_to_number.cc
+++ b/rtc_base/string_to_number.cc
@@ -18,7 +18,7 @@
 namespace rtc {
 namespace string_to_number_internal {
 
-rtc::Optional<signed_type> ParseSigned(const char* str, int base) {
+absl::optional<signed_type> ParseSigned(const char* str, int base) {
   RTC_DCHECK(str);
   if (isdigit(str[0]) || str[0] == '-') {
     char* end = nullptr;
@@ -28,10 +28,10 @@
       return value;
     }
   }
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 
-rtc::Optional<unsigned_type> ParseUnsigned(const char* str, int base) {
+absl::optional<unsigned_type> ParseUnsigned(const char* str, int base) {
   RTC_DCHECK(str);
   if (isdigit(str[0]) || str[0] == '-') {
     // Explicitly discard negative values. std::strtoull parsing causes unsigned
@@ -45,7 +45,7 @@
       return value;
     }
   }
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 
 }  // namespace string_to_number_internal
diff --git a/rtc_base/string_to_number.h b/rtc_base/string_to_number.h
index 3a7ca58..9b4fa67 100644
--- a/rtc_base/string_to_number.h
+++ b/rtc_base/string_to_number.h
@@ -14,7 +14,7 @@
 #include <limits>
 #include <string>
 
-#include "api/optional.h"
+#include "absl/types/optional.h"
 
 namespace rtc {
 
@@ -25,8 +25,8 @@
 // are disabled in WebRTC.
 //
 // Integers are parsed using one of the following functions:
-//   rtc::Optional<int-type> StringToNumber(const char* str, int base = 10);
-//   rtc::Optional<int-type> StringToNumber(const std::string& str,
+//   absl::optional<int-type> StringToNumber(const char* str, int base = 10);
+//   absl::optional<int-type> StringToNumber(const std::string& str,
 //                                          int base = 10);
 //
 // These functions parse a value from the beginning of a string into one of the
@@ -46,13 +46,13 @@
 using unsigned_type = unsigned long long;  // NOLINT(runtime/int)
 using signed_type = long long;             // NOLINT(runtime/int)
 
-rtc::Optional<signed_type> ParseSigned(const char* str, int base);
-rtc::Optional<unsigned_type> ParseUnsigned(const char* str, int base);
+absl::optional<signed_type> ParseSigned(const char* str, int base);
+absl::optional<unsigned_type> ParseUnsigned(const char* str, int base);
 }  // namespace string_to_number_internal
 
 template <typename T>
 typename std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value,
-                        rtc::Optional<T>>::type
+                        absl::optional<T>>::type
 StringToNumber(const char* str, int base = 10) {
   using string_to_number_internal::signed_type;
   static_assert(
@@ -61,31 +61,31 @@
           std::numeric_limits<T>::lowest() >=
               std::numeric_limits<signed_type>::lowest(),
       "StringToNumber only supports signed integers as large as long long int");
-  rtc::Optional<signed_type> value =
+  absl::optional<signed_type> value =
       string_to_number_internal::ParseSigned(str, base);
   if (value && *value >= std::numeric_limits<T>::lowest() &&
       *value <= std::numeric_limits<T>::max()) {
     return static_cast<T>(*value);
   }
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 
 template <typename T>
 typename std::enable_if<std::is_integral<T>::value &&
                             std::is_unsigned<T>::value,
-                        rtc::Optional<T>>::type
+                        absl::optional<T>>::type
 StringToNumber(const char* str, int base = 10) {
   using string_to_number_internal::unsigned_type;
   static_assert(std::numeric_limits<T>::max() <=
                     std::numeric_limits<unsigned_type>::max(),
                 "StringToNumber only supports unsigned integers as large as "
                 "unsigned long long int");
-  rtc::Optional<unsigned_type> value =
+  absl::optional<unsigned_type> value =
       string_to_number_internal::ParseUnsigned(str, base);
   if (value && *value <= std::numeric_limits<T>::max()) {
     return static_cast<T>(*value);
   }
-  return rtc::nullopt;
+  return absl::nullopt;
 }
 
 // The std::string overloads only exists if there is a matching const char*
diff --git a/rtc_base/string_to_number_unittest.cc b/rtc_base/string_to_number_unittest.cc
index 691b26f..f7bf484 100644
--- a/rtc_base/string_to_number_unittest.cc
+++ b/rtc_base/string_to_number_unittest.cc
@@ -68,10 +68,10 @@
       (min_value == 0) ? "-2" : (std::to_string(min_value) + "1");
   // Make the large value approximately ten times larger than the maximum.
   const std::string too_large_string = std::to_string(max_value) + "1";
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(too_low_string));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(too_low_string.c_str()));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(too_large_string));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(too_large_string.c_str()));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(too_low_string));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(too_low_string.c_str()));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(too_large_string));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(too_large_string.c_str()));
 }
 
 TYPED_TEST_P(BasicNumberTest, TestInvalidInputs) {
@@ -79,18 +79,18 @@
   const char kInvalidCharArray[] = "Invalid string containing 47";
   const char kPlusMinusCharArray[] = "+-100";
   const char kNumberFollowedByCruft[] = "640x480";
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(kInvalidCharArray));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(std::string(kInvalidCharArray)));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(kPlusMinusCharArray));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(std::string(kPlusMinusCharArray)));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(kNumberFollowedByCruft));
-  EXPECT_EQ(rtc::nullopt,
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(kInvalidCharArray));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(std::string(kInvalidCharArray)));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(kPlusMinusCharArray));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(std::string(kPlusMinusCharArray)));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(kNumberFollowedByCruft));
+  EXPECT_EQ(absl::nullopt,
             StringToNumber<T>(std::string(kNumberFollowedByCruft)));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(" 5"));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(" - 5"));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>("- 5"));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>(" -5"));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<T>("5 "));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(" 5"));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(" - 5"));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>("- 5"));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>(" -5"));
+  EXPECT_EQ(absl::nullopt, StringToNumber<T>("5 "));
 }
 
 REGISTER_TYPED_TEST_CASE_P(BasicNumberTest,
@@ -105,10 +105,10 @@
                               IntegerTypes);
 
 TEST(StringToNumberTest, TestSpecificValues) {
-  EXPECT_EQ(rtc::nullopt, StringToNumber<uint8_t>("256"));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<uint8_t>("-256"));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<int8_t>("256"));
-  EXPECT_EQ(rtc::nullopt, StringToNumber<int8_t>("-256"));
+  EXPECT_EQ(absl::nullopt, StringToNumber<uint8_t>("256"));
+  EXPECT_EQ(absl::nullopt, StringToNumber<uint8_t>("-256"));
+  EXPECT_EQ(absl::nullopt, StringToNumber<int8_t>("256"));
+  EXPECT_EQ(absl::nullopt, StringToNumber<int8_t>("-256"));
 }
 
 }  // namespace rtc