chromecast: Replace base::Optional and friends with absl counterparts

This replaces:
- base::Optional -> absl::optional
- include "base/optional.h"
  ->
  include "third_party/abseil-cpp/absl/types/optional.h"
- base::nullopt -> absl::nullopt
- base::make_optional -> absl::make_optional

Bug: 1202909
Change-Id: Ie8970e16d42af39ae424c836d5f0c48c913dc7ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2897224
Auto-Submit: Anton Bikineev <[email protected]>
Commit-Queue: Peter Kasting <[email protected]>
Reviewed-by: Peter Kasting <[email protected]>
Owners-Override: Peter Kasting <[email protected]>
Cr-Commit-Position: refs/heads/master@{#883275}
diff --git a/chromecast/base/serializers.cc b/chromecast/base/serializers.cc
index 1c38636..cb4fcd3 100644
--- a/chromecast/base/serializers.cc
+++ b/chromecast/base/serializers.cc
@@ -23,12 +23,12 @@
   return value;
 }
 
-base::Optional<std::string> SerializeToJson(const base::Value& value) {
+absl::optional<std::string> SerializeToJson(const base::Value& value) {
   std::string json_str;
   JSONStringValueSerializer serializer(&json_str);
   if (serializer.Serialize(value))
     return json_str;
-  return base::nullopt;
+  return absl::nullopt;
 }
 
 std::unique_ptr<base::Value> DeserializeJsonFromFile(
diff --git a/chromecast/base/serializers.h b/chromecast/base/serializers.h
index d2a35238..27ca8ae 100644
--- a/chromecast/base/serializers.h
+++ b/chromecast/base/serializers.h
@@ -8,7 +8,7 @@
 #include <memory>
 #include <string>
 
-#include "base/optional.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace base {
 class Value;
@@ -25,10 +25,10 @@
 
 // Deprecated: use base::JSONWriter::Write instead.
 // Helper function which serializes |value| into a JSON string. If a
-// serialization error occurs,the return value will be base::nullopt.
+// serialization error occurs,the return value will be absl::nullopt.
 // Dereferencing the result is equivalent to DCHECK()-ing that serialization
 // succeeded and retrieving the serialized string.
-base::Optional<std::string> SerializeToJson(const base::Value& value);
+absl::optional<std::string> SerializeToJson(const base::Value& value);
 
 // Helper function which deserializes JSON file at |path| into a base::Value.
 // If file in |path| is empty, is not valid JSON, or if some other
diff --git a/chromecast/base/serializers_unittest.cc b/chromecast/base/serializers_unittest.cc
index 05f4a0d..7ad2e8b 100644
--- a/chromecast/base/serializers_unittest.cc
+++ b/chromecast/base/serializers_unittest.cc
@@ -56,13 +56,13 @@
 
 TEST(SerializeToJson, BadValue) {
   base::Value value(std::vector<char>(12));
-  base::Optional<std::string> str = SerializeToJson(value);
+  absl::optional<std::string> str = SerializeToJson(value);
   EXPECT_FALSE(str.has_value());
 }
 
 TEST(SerializeToJson, EmptyValue) {
   base::DictionaryValue value;
-  base::Optional<std::string> str = SerializeToJson(value);
+  absl::optional<std::string> str = SerializeToJson(value);
   ASSERT_TRUE(str.has_value());
   EXPECT_EQ(kEmptyJsonString, *str);
 }
@@ -70,7 +70,7 @@
 TEST(SerializeToJson, PopulatedValue) {
   base::DictionaryValue orig_value;
   orig_value.SetString(kTestKey, kTestValue);
-  base::Optional<std::string> str = SerializeToJson(orig_value);
+  absl::optional<std::string> str = SerializeToJson(orig_value);
   ASSERT_TRUE(str.has_value());
 
   std::unique_ptr<base::Value> new_value = DeserializeFromJson(*str);
diff --git a/chromecast/browser/accessibility/flutter/ax_tree_source_flutter_unittest.cc b/chromecast/browser/accessibility/flutter/ax_tree_source_flutter_unittest.cc
index e4cf2c2..4163a67 100644
--- a/chromecast/browser/accessibility/flutter/ax_tree_source_flutter_unittest.cc
+++ b/chromecast/browser/accessibility/flutter/ax_tree_source_flutter_unittest.cc
@@ -121,7 +121,7 @@
               (override));
   void DispatchGetTextLocationDataResult(
       const ui::AXActionData& data,
-      const base::Optional<gfx::Rect>& rect) override {}
+      const absl::optional<gfx::Rect>& rect) override {}
 
   std::map<ax::mojom::Event, int> event_count_;
 };
diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc
index 8001775..ee0f827 100644
--- a/chromecast/browser/cast_content_browser_client.cc
+++ b/chromecast/browser/cast_content_browser_client.cc
@@ -726,13 +726,13 @@
   }
 }
 
-base::Optional<service_manager::Manifest>
+absl::optional<service_manager::Manifest>
 CastContentBrowserClient::GetServiceManifestOverlay(
     base::StringPiece service_name) {
   if (service_name == ServiceManagerContext::kBrowserServiceName)
     return GetCastContentBrowserOverlayManifest();
 
-  return base::nullopt;
+  return absl::nullopt;
 }
 
 std::vector<service_manager::Manifest>
diff --git a/chromecast/browser/cast_content_browser_client.h b/chromecast/browser/cast_content_browser_client.h
index 737c64f..336c81c 100644
--- a/chromecast/browser/cast_content_browser_client.h
+++ b/chromecast/browser/cast_content_browser_client.h
@@ -161,7 +161,7 @@
   virtual void RunServiceInstance(
       const service_manager::Identity& identity,
       mojo::PendingReceiver<service_manager::mojom::Service>* receiver);
-  virtual base::Optional<service_manager::Manifest> GetServiceManifestOverlay(
+  virtual absl::optional<service_manager::Manifest> GetServiceManifestOverlay(
       base::StringPiece service_name);
   std::vector<service_manager::Manifest> GetExtraServiceManifests();
   std::vector<std::string> GetStartupServices();
diff --git a/chromecast/browser/cast_download_manager_delegate.cc b/chromecast/browser/cast_download_manager_delegate.cc
index 4f22da36..827b54f4 100644
--- a/chromecast/browser/cast_download_manager_delegate.cc
+++ b/chromecast/browser/cast_download_manager_delegate.cc
@@ -33,7 +33,7 @@
       empty, download::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
       download::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT,
       download::DownloadItem::MixedContentStatus::UNKNOWN, empty,
-      base::nullopt /*download_schedule*/,
+      absl::nullopt /*download_schedule*/,
       download::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED);
   return true;
 }
diff --git a/chromecast/browser/cast_extension_url_loader_factory.cc b/chromecast/browser/cast_extension_url_loader_factory.cc
index 3e06fcbe..106e0c2 100644
--- a/chromecast/browser/cast_extension_url_loader_factory.cc
+++ b/chromecast/browser/cast_extension_url_loader_factory.cc
@@ -91,7 +91,7 @@
       const std::vector<std::string>& removed_headers,
       const net::HttpRequestHeaders& modified_headers,
       const net::HttpRequestHeaders& modified_cors_exempt_headers,
-      const base::Optional<GURL>& new_url) override {
+      const absl::optional<GURL>& new_url) override {
     NOTREACHED()
         << "The original client shouldn't have been notified of any redirects";
   }
@@ -124,7 +124,7 @@
     // just follow the redirect.
     network_loader_->FollowRedirect(std::vector<std::string>(),
                                     net::HttpRequestHeaders(),
-                                    net::HttpRequestHeaders(), base::nullopt);
+                                    net::HttpRequestHeaders(), absl::nullopt);
   }
 
   void OnUploadProgress(int64_t current_position,
diff --git a/chromecast/browser/cast_media_blocker.h b/chromecast/browser/cast_media_blocker.h
index cc8afb73..2ce4add9 100644
--- a/chromecast/browser/cast_media_blocker.h
+++ b/chromecast/browser/cast_media_blocker.h
@@ -53,7 +53,7 @@
   void MediaSessionInfoChanged(
       media_session::mojom::MediaSessionInfoPtr session_info) override;
   void MediaSessionMetadataChanged(
-      const base::Optional<media_session::MediaMetadata>& metadata) override {}
+      const absl::optional<media_session::MediaMetadata>& metadata) override {}
   void MediaSessionActionsChanged(
       const std::vector<media_session::mojom::MediaSessionAction>& action)
       override {}
@@ -62,7 +62,7 @@
                            std::vector<media_session::MediaImage>>& images)
       override {}
   void MediaSessionPositionChanged(
-      const base::Optional<media_session::MediaPosition>& position) override {}
+      const absl::optional<media_session::MediaPosition>& position) override {}
 
  private:
   friend shell::CastMediaBlockerTest;
diff --git a/chromecast/browser/cast_media_blocker_unittest.cc b/chromecast/browser/cast_media_blocker_unittest.cc
index 67896179..5f5b33f 100644
--- a/chromecast/browser/cast_media_blocker_unittest.cc
+++ b/chromecast/browser/cast_media_blocker_unittest.cc
@@ -56,7 +56,7 @@
   MOCK_METHOD1(ScrubTo, void(base::TimeDelta));
   MOCK_METHOD0(EnterPictureInPicture, void());
   MOCK_METHOD0(ExitPictureInPicture, void());
-  MOCK_METHOD1(SetAudioSinkId, void(const base::Optional<std::string>& id));
+  MOCK_METHOD1(SetAudioSinkId, void(const absl::optional<std::string>& id));
   MOCK_METHOD0(ToggleMicrophone, void());
   MOCK_METHOD0(ToggleCamera, void());
   MOCK_METHOD0(HangUp, void());
diff --git a/chromecast/browser/cast_web_contents.h b/chromecast/browser/cast_web_contents.h
index 0e1d43c..3ec70ed 100644
--- a/chromecast/browser/cast_web_contents.h
+++ b/chromecast/browser/cast_web_contents.h
@@ -11,13 +11,13 @@
 #include "base/callback.h"
 #include "base/containers/flat_set.h"
 #include "base/observer_list.h"
-#include "base/optional.h"
 #include "base/process/process.h"
 #include "chromecast/common/mojom/feature_manager.mojom.h"
 #include "content/public/common/media_playback_renderer_type.mojom.h"
 #include "mojo/public/cpp/bindings/generic_pending_receiver.h"
 #include "services/service_manager/public/cpp/binder_registry.h"
 #include "services/service_manager/public/cpp/interface_provider.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/blink/public/common/messaging/web_message_port.h"
 #include "ui/gfx/geometry/rect.h"
 #include "url/gurl.h"
@@ -230,7 +230,7 @@
     // Whether to provide a URL filter applied to network requests for the
     // activity hosted by this CastWebContents.
     // No filters implies no restrictions.
-    base::Optional<std::vector<std::string>> url_filters = base::nullopt;
+    absl::optional<std::vector<std::string>> url_filters = absl::nullopt;
     // Whether WebRTC peer connections are allowed to use legacy versions of the
     // TLS/DTLS protocols.
     bool webrtc_allow_legacy_tls_protocols = false;
@@ -273,7 +273,7 @@
   virtual PageState page_state() const = 0;
 
   // Returns the PID of the main frame process if valid.
-  virtual base::Optional<pid_t> GetMainFrameRenderProcessPid() const = 0;
+  virtual absl::optional<pid_t> GetMainFrameRenderProcessPid() const = 0;
 
   // ===========================================================================
   // Initialization and Setup
diff --git a/chromecast/browser/cast_web_contents_browsertest.cc b/chromecast/browser/cast_web_contents_browsertest.cc
index f5a61f1..b25b18de 100644
--- a/chromecast/browser/cast_web_contents_browsertest.cc
+++ b/chromecast/browser/cast_web_contents_browsertest.cc
@@ -186,7 +186,7 @@
 
   void WaitForNextIncomingMessage(
       base::OnceCallback<
-          void(std::string, base::Optional<blink::WebMessagePort>)> callback) {
+          void(std::string, absl::optional<blink::WebMessagePort>)> callback) {
     DCHECK(message_received_callback_.is_null())
         << "Only one waiting event is allowed.";
     message_received_callback_ = std::move(callback);
@@ -204,12 +204,12 @@
       return false;
     }
 
-    base::Optional<blink::WebMessagePort> incoming_port = base::nullopt;
+    absl::optional<blink::WebMessagePort> incoming_port = absl::nullopt;
     // Only one MessagePort should be sent to here.
     if (!message.ports.empty()) {
       DCHECK(message.ports.size() == 1)
           << "Only one control port can be provided";
-      incoming_port = base::make_optional<blink::WebMessagePort>(
+      incoming_port = absl::make_optional<blink::WebMessagePort>(
           std::move(message.ports[0]));
     }
 
@@ -226,7 +226,7 @@
   }
 
   base::OnceCallback<void(std::string,
-                          base::Optional<blink::WebMessagePort> incoming_port)>
+                          absl::optional<blink::WebMessagePort> incoming_port)>
       message_received_callback_;
 
   base::OnceCallback<void()> on_pipe_error_callback_;
@@ -823,7 +823,7 @@
     auto quit_closure = run_loop.QuitClosure();
     auto received_message_callback = base::BindOnce(
         [](base::OnceClosure loop_quit_closure, std::string port_msg,
-           base::Optional<blink::WebMessagePort> incoming_port) {
+           absl::optional<blink::WebMessagePort> incoming_port) {
           EXPECT_EQ("got_port", port_msg);
           std::move(loop_quit_closure).Run();
         },
@@ -843,7 +843,7 @@
     auto quit_closure = run_loop.QuitClosure();
     auto received_message_callback = base::BindOnce(
         [](base::OnceClosure loop_quit_closure, std::string port_msg,
-           base::Optional<blink::WebMessagePort> incoming_port) {
+           absl::optional<blink::WebMessagePort> incoming_port) {
           EXPECT_EQ("ack ping", port_msg);
           std::move(loop_quit_closure).Run();
         },
@@ -891,7 +891,7 @@
     auto quit_closure = run_loop.QuitClosure();
     auto received_message_callback = base::BindOnce(
         [](base::OnceClosure loop_quit_closure, std::string port_msg,
-           base::Optional<blink::WebMessagePort> incoming_port) {
+           absl::optional<blink::WebMessagePort> incoming_port) {
           EXPECT_EQ("got_port", port_msg);
           std::move(loop_quit_closure).Run();
         },
diff --git a/chromecast/browser/cast_web_contents_impl.cc b/chromecast/browser/cast_web_contents_impl.cc
index 278c7d8..1061ee2 100644
--- a/chromecast/browser/cast_web_contents_impl.cc
+++ b/chromecast/browser/cast_web_contents_impl.cc
@@ -10,7 +10,6 @@
 #include "base/callback_helpers.h"
 #include "base/logging.h"
 #include "base/no_destructor.h"
-#include "base/optional.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/sequenced_task_runner_handle.h"
 #include "base/trace_event/trace_event.h"
@@ -38,6 +37,7 @@
 #include "mojo/public/cpp/bindings/remote.h"
 #include "net/base/net_errors.h"
 #include "services/service_manager/public/cpp/interface_provider.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
 #include "third_party/blink/public/common/renderer_preferences/renderer_preferences.h"
 #include "third_party/blink/public/mojom/autoplay/autoplay.mojom.h"
@@ -201,19 +201,19 @@
   return page_state_;
 }
 
-base::Optional<pid_t> CastWebContentsImpl::GetMainFrameRenderProcessPid()
+absl::optional<pid_t> CastWebContentsImpl::GetMainFrameRenderProcessPid()
     const {
   // Returns empty value if |web_contents_| is (being) destroyed or the main
   // frame is not available yet.
   if (!web_contents_ || !web_contents_->GetMainFrame()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   auto* rph = web_contents_->GetMainFrame()->GetProcess();
   if (!rph || rph->GetProcess().Handle() == base::kNullProcessHandle) {
-    return base::nullopt;
+    return absl::nullopt;
   }
-  return base::make_optional(rph->GetProcess().Handle());
+  return absl::make_optional(rph->GetProcess().Handle());
 }
 
 void CastWebContentsImpl::AddRendererFeatures(
@@ -345,7 +345,7 @@
 
   // If origin is set as wildcard, no origin scoping would be applied.
   constexpr char kWildcardOrigin[] = "*";
-  base::Optional<std::u16string> target_origin_utf16;
+  absl::optional<std::u16string> target_origin_utf16;
   if (target_origin != kWildcardOrigin)
     target_origin_utf16 = base::UTF8ToUTF16(target_origin);
 
diff --git a/chromecast/browser/cast_web_contents_impl.h b/chromecast/browser/cast_web_contents_impl.h
index 7ebc164..27f2ce61 100644
--- a/chromecast/browser/cast_web_contents_impl.h
+++ b/chromecast/browser/cast_web_contents_impl.h
@@ -17,7 +17,6 @@
 #include "base/memory/platform_shared_memory_region.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/weak_ptr.h"
-#include "base/optional.h"
 #include "base/sequence_checker.h"
 #include "base/time/time.h"
 #include "chromecast/browser/cast_media_blocker.h"
@@ -29,6 +28,7 @@
 #include "content/public/common/media_playback_renderer_type.mojom.h"
 #include "services/service_manager/public/cpp/binder_registry.h"
 #include "services/service_manager/public/cpp/interface_provider.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/blink/public/mojom/favicon/favicon_url.mojom-forward.h"
 
 namespace content {
@@ -51,7 +51,7 @@
 
   content::WebContents* web_contents() const override;
   PageState page_state() const override;
-  base::Optional<pid_t> GetMainFrameRenderProcessPid() const override;
+  absl::optional<pid_t> GetMainFrameRenderProcessPid() const override;
 
   // CastWebContents implementation:
   int tab_id() const override;
@@ -156,7 +156,7 @@
   BackgroundColor view_background_color_;
   shell::RemoteDebuggingServer* const remote_debugging_server_;
   std::unique_ptr<CastMediaBlocker> media_blocker_;
-  base::Optional<std::vector<std::string>> activity_url_filter_;
+  absl::optional<std::vector<std::string>> activity_url_filter_;
 
   // Retained so that this observer can be removed before being destroyed:
   content::RenderProcessHost* main_process_host_;
diff --git a/chromecast/browser/cast_web_preferences.h b/chromecast/browser/cast_web_preferences.h
index 1367ebb..32dbc20c 100644
--- a/chromecast/browser/cast_web_preferences.h
+++ b/chromecast/browser/cast_web_preferences.h
@@ -5,8 +5,8 @@
 #ifndef CHROMECAST_BROWSER_CAST_WEB_PREFERENCES_H_
 #define CHROMECAST_BROWSER_CAST_WEB_PREFERENCES_H_
 
-#include "base/optional.h"
 #include "base/supports_user_data.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom.h"
 
 namespace chromecast {
@@ -18,10 +18,10 @@
   struct Preferences {
     Preferences();
 
-    base::Optional<blink::mojom::AutoplayPolicy> autoplay_policy;
-    base::Optional<bool> hide_scrollbars;
-    base::Optional<bool> javascript_enabled;
-    base::Optional<bool> supports_multiple_windows;
+    absl::optional<blink::mojom::AutoplayPolicy> autoplay_policy;
+    absl::optional<bool> hide_scrollbars;
+    absl::optional<bool> javascript_enabled;
+    absl::optional<bool> supports_multiple_windows;
   };
 
   // Unique key used to identify CastWebPreferences in WebContents' user data.
diff --git a/chromecast/browser/service_manager_context.cc b/chromecast/browser/service_manager_context.cc
index 12031c9..be8e628 100644
--- a/chromecast/browser/service_manager_context.cc
+++ b/chromecast/browser/service_manager_context.cc
@@ -19,7 +19,6 @@
 #include "base/memory/weak_ptr.h"
 #include "base/message_loop/message_pump_type.h"
 #include "base/no_destructor.h"
-#include "base/optional.h"
 #include "base/process/process_handle.h"
 #include "base/single_thread_task_runner.h"
 #include "base/stl_util.h"
@@ -46,6 +45,7 @@
 #include "services/service_manager/service_manager.h"
 #include "services/service_manager/service_process_host.h"
 #include "services/service_manager/service_process_launcher.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "ui/base/buildflags.h"
 #include "ui/base/ui_base_features.h"
 
@@ -303,7 +303,7 @@
   manifests.push_back(GetBrowserManifest());
   manifests.push_back(GetSystemManifest(cast_content_browser_client_));
   for (auto& manifest : manifests) {
-    base::Optional<service_manager::Manifest> overlay =
+    absl::optional<service_manager::Manifest> overlay =
         cast_content_browser_client_->GetServiceManifestOverlay(
             manifest.service_name);
     if (overlay)
diff --git a/chromecast/browser/test/mock_cast_web_view.h b/chromecast/browser/test/mock_cast_web_view.h
index 6925145..aebbaa7 100644
--- a/chromecast/browser/test/mock_cast_web_view.h
+++ b/chromecast/browser/test/mock_cast_web_view.h
@@ -20,7 +20,7 @@
   MOCK_METHOD(int, id, (), (const, override));
   MOCK_METHOD(content::WebContents*, web_contents, (), (const, override));
   MOCK_METHOD(PageState, page_state, (), (const, override));
-  MOCK_METHOD(base::Optional<pid_t>,
+  MOCK_METHOD(absl::optional<pid_t>,
               GetMainFrameRenderProcessPid,
               (),
               (const, override));
diff --git a/chromecast/browser/webui/cast_resource_data_source.h b/chromecast/browser/webui/cast_resource_data_source.h
index 07cd2b4..3c36cf0 100644
--- a/chromecast/browser/webui/cast_resource_data_source.h
+++ b/chromecast/browser/webui/cast_resource_data_source.h
@@ -8,9 +8,9 @@
 #include <string>
 
 #include "base/macros.h"
-#include "base/optional.h"
 #include "chromecast/browser/webui/mojom/webui.mojom.h"
 #include "content/public/browser/url_data_source.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace chromecast {
 
@@ -46,7 +46,7 @@
   const bool for_webui_;
   mojo::Remote<mojom::Resources> remote_;
 
-  base::Optional<std::string> frame_src_;
+  absl::optional<std::string> frame_src_;
   bool deny_xframe_options_ = true;
 };
 
diff --git a/chromecast/browser/webview/cast_window_embedder.h b/chromecast/browser/webview/cast_window_embedder.h
index 45dcf63..3bd4e12 100644
--- a/chromecast/browser/webview/cast_window_embedder.h
+++ b/chromecast/browser/webview/cast_window_embedder.h
@@ -7,8 +7,8 @@
 
 #include <string>
 
-#include "base/optional.h"
 #include "chromecast/browser/cast_content_window.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace content {
 class WebContents;
@@ -76,10 +76,10 @@
 
     // Unique window ID assigned by the embedder.
     int window_id = -1;
-    base::Optional<VisibilityChange> visibility_changed;
-    base::Optional<NavigationType> navigation;
-    base::Optional<BackGestureProgressEvent> back_gesture_progress_event;
-    base::Optional<bool> back_gesture_cancel_event;
+    absl::optional<VisibilityChange> visibility_changed;
+    absl::optional<NavigationType> navigation;
+    absl::optional<BackGestureProgressEvent> back_gesture_progress_event;
+    absl::optional<bool> back_gesture_cancel_event;
   };
 
   // Interface for the embedded Cast window to implement for
@@ -155,11 +155,11 @@
     VisibilityPriority visibility_priority = VisibilityPriority::DEFAULT;
 
     // Application-related metadata associated with the Cast window.
-    base::Optional<std::string> app_context;
+    absl::optional<std::string> app_context;
 
     // Custom data for the Cast window. The embedder and whoever set the
     // value need to have agreement on the schema of |host_context|.
-    base::Optional<base::Value> host_context;
+    absl::optional<base::Value> host_context;
   };
 
   // The embedded Cast window will use this to communicate with the embedder
diff --git a/chromecast/browser/webview/webview_window_manager.cc b/chromecast/browser/webview/webview_window_manager.cc
index 95a4a14..c72d7c3a 100644
--- a/chromecast/browser/webview/webview_window_manager.cc
+++ b/chromecast/browser/webview/webview_window_manager.cc
@@ -5,11 +5,11 @@
 #include "chromecast/browser/webview/webview_window_manager.h"
 
 #include "base/logging.h"
-#include "base/optional.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "components/exo/shell_surface_util.h"
 #include "components/exo/surface.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "ui/aura/env.h"
 
 namespace chromecast {
diff --git a/chromecast/common/cast_resource_delegate.cc b/chromecast/common/cast_resource_delegate.cc
index 82614b1..3dc0afd 100644
--- a/chromecast/common/cast_resource_delegate.cc
+++ b/chromecast/common/cast_resource_delegate.cc
@@ -66,9 +66,9 @@
   return NULL;
 }
 
-base::Optional<std::string> CastResourceDelegate::LoadDataResourceString(
+absl::optional<std::string> CastResourceDelegate::LoadDataResourceString(
     int resource_id) {
-  return base::nullopt;
+  return absl::nullopt;
 }
 
 bool CastResourceDelegate::GetRawDataResource(int resource_id,
diff --git a/chromecast/common/cast_resource_delegate.h b/chromecast/common/cast_resource_delegate.h
index 4d333cd0..ccbad02 100644
--- a/chromecast/common/cast_resource_delegate.h
+++ b/chromecast/common/cast_resource_delegate.h
@@ -45,7 +45,7 @@
   base::RefCountedStaticMemory* LoadDataResourceBytes(
       int resource_id,
       ui::ScaleFactor scale_factor) override;
-  base::Optional<std::string> LoadDataResourceString(int resource_id) override;
+  absl::optional<std::string> LoadDataResourceString(int resource_id) override;
   bool GetRawDataResource(int resource_id,
                           ui::ScaleFactor scale_factor,
                           base::StringPiece* value) const override;
diff --git a/chromecast/crash/linux/crash_testing_utils.cc b/chromecast/crash/linux/crash_testing_utils.cc
index 9de0d36..826eb7f 100644
--- a/chromecast/crash/linux/crash_testing_utils.cc
+++ b/chromecast/crash/linux/crash_testing_utils.cc
@@ -46,7 +46,7 @@
   for (const std::string& line : lines) {
     if (line.size() == 0)
       continue;
-    base::Optional<base::Value> dump_info = base::JSONReader::Read(line);
+    absl::optional<base::Value> dump_info = base::JSONReader::Read(line);
     RCHECK(dump_info.has_value(), nullptr, "Invalid DumpInfo");
     DumpInfo info(&dump_info.value());
     RCHECK(info.valid(), nullptr, "Invalid DumpInfo");
@@ -94,7 +94,7 @@
 }  // namespace
 
 std::unique_ptr<DumpInfo> CreateDumpInfo(const std::string& json_string) {
-  base::Optional<base::Value> value = base::JSONReader::Read(json_string);
+  absl::optional<base::Value> value = base::JSONReader::Read(json_string);
   return value.has_value() ? std::make_unique<DumpInfo>(&value.value())
                            : std::make_unique<DumpInfo>(nullptr);
 }
diff --git a/chromecast/crash/linux/synchronized_minidump_manager.cc b/chromecast/crash/linux/synchronized_minidump_manager.cc
index c2c3272e3..015c490 100644
--- a/chromecast/crash/linux/synchronized_minidump_manager.cc
+++ b/chromecast/crash/linux/synchronized_minidump_manager.cc
@@ -286,7 +286,7 @@
   for (const std::string& line : lines) {
     if (line.size() == 0)
       continue;
-    base::Optional<base::Value> dump_info = base::JSONReader::Read(line);
+    absl::optional<base::Value> dump_info = base::JSONReader::Read(line);
     RCHECK(dump_info.has_value(), false);
     DumpInfo info(&dump_info.value());
     RCHECK(info.valid(), false);
diff --git a/chromecast/device/bluetooth/le/le_scan_manager.h b/chromecast/device/bluetooth/le/le_scan_manager.h
index 52305789..1ce9f13d 100644
--- a/chromecast/device/bluetooth/le/le_scan_manager.h
+++ b/chromecast/device/bluetooth/le/le_scan_manager.h
@@ -80,7 +80,7 @@
       base::OnceCallback<void(std::vector<LeScanResult>)>;
   virtual void GetScanResults(
       GetScanResultsCallback cb,
-      base::Optional<ScanFilter> scan_filter = base::nullopt) = 0;
+      absl::optional<ScanFilter> scan_filter = absl::nullopt) = 0;
 
   virtual void ClearScanResults() = 0;
 
diff --git a/chromecast/device/bluetooth/le/le_scan_manager_impl.cc b/chromecast/device/bluetooth/le/le_scan_manager_impl.cc
index 58b1031..5df0093 100644
--- a/chromecast/device/bluetooth/le/le_scan_manager_impl.cc
+++ b/chromecast/device/bluetooth/le/le_scan_manager_impl.cc
@@ -117,7 +117,7 @@
 }
 
 void LeScanManagerImpl::GetScanResults(GetScanResultsCallback cb,
-                                       base::Optional<ScanFilter> scan_filter) {
+                                       absl::optional<ScanFilter> scan_filter) {
   MAKE_SURE_IO_THREAD(GetScanResults, BindToCurrentSequence(std::move(cb)),
                       std::move(scan_filter));
   std::move(cb).Run(GetScanResultsInternal(std::move(scan_filter)));
@@ -224,7 +224,7 @@
 
 // Returns a list of all scan results. The results are sorted by RSSI.
 std::vector<LeScanResult> LeScanManagerImpl::GetScanResultsInternal(
-    base::Optional<ScanFilter> scan_filter) {
+    absl::optional<ScanFilter> scan_filter) {
   DCHECK(io_task_runner_->BelongsToCurrentThread());
   std::vector<LeScanResult> results;
   for (const auto& pair : addr_to_scan_results_) {
diff --git a/chromecast/device/bluetooth/le/le_scan_manager_impl.h b/chromecast/device/bluetooth/le/le_scan_manager_impl.h
index ac426206..ccac818 100644
--- a/chromecast/device/bluetooth/le/le_scan_manager_impl.h
+++ b/chromecast/device/bluetooth/le/le_scan_manager_impl.h
@@ -40,7 +40,7 @@
   void RequestScan(RequestScanCallback cb) override;
   void GetScanResults(
       GetScanResultsCallback cb,
-      base::Optional<ScanFilter> service_uuid = base::nullopt) override;
+      absl::optional<ScanFilter> service_uuid = absl::nullopt) override;
   void ClearScanResults() override;
   void PauseScan() override;
   void ResumeScan() override;
@@ -58,7 +58,7 @@
   // Returns a list of all BLE scan results. The results are sorted by RSSI.
   // Must be called on |io_task_runner|.
   std::vector<LeScanResult> GetScanResultsInternal(
-      base::Optional<ScanFilter> service_uuid);
+      absl::optional<ScanFilter> service_uuid);
 
   void NotifyScanHandleDestroyed(int32_t id);
 
diff --git a/chromecast/device/bluetooth/le/le_scan_result.cc b/chromecast/device/bluetooth/le/le_scan_result.cc
index 686b7966..e4113e6 100644
--- a/chromecast/device/bluetooth/le/le_scan_result.cc
+++ b/chromecast/device/bluetooth/le/le_scan_result.cc
@@ -13,19 +13,19 @@
 namespace {
 
 template <typename T, bluetooth_v2_shlib::Uuid (*converter)(T)>
-base::Optional<LeScanResult::UuidList> GetUuidsFromShort(
+absl::optional<LeScanResult::UuidList> GetUuidsFromShort(
     const std::map<uint8_t, std::vector<std::vector<uint8_t>>>& type_to_data,
     uint8_t type) {
   auto it = type_to_data.find(type);
   if (it == type_to_data.end()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   LeScanResult::UuidList ret;
   for (const auto& field : it->second) {
     if (field.size() % sizeof(T)) {
       LOG(ERROR) << "Invalid length, expected multiple of " << sizeof(T);
-      return base::nullopt;
+      return absl::nullopt;
     }
 
     for (size_t i = 0; i < field.size(); i += sizeof(T)) {
@@ -43,12 +43,12 @@
   return ret;
 }
 
-base::Optional<LeScanResult::UuidList> GetUuidsAsUuid(
+absl::optional<LeScanResult::UuidList> GetUuidsAsUuid(
     const std::map<uint8_t, std::vector<std::vector<uint8_t>>>& type_to_data,
     uint8_t type) {
   auto it = type_to_data.find(type);
   if (it == type_to_data.end()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   LeScanResult::UuidList ret;
@@ -56,7 +56,7 @@
     if (field.size() % sizeof(bluetooth_v2_shlib::Uuid)) {
       LOG(ERROR) << "Invalid length, expected multiple of "
                  << sizeof(bluetooth_v2_shlib::Uuid);
-      return base::nullopt;
+      return absl::nullopt;
     }
 
     for (size_t i = 0; i < field.size();
@@ -115,7 +115,7 @@
   return true;
 }
 
-base::Optional<std::string> LeScanResult::Name() const {
+absl::optional<std::string> LeScanResult::Name() const {
   auto it = type_to_data.find(kGapCompleteName);
   if (it != type_to_data.end()) {
     DCHECK_GE(it->second.size(), 1u);
@@ -130,28 +130,28 @@
                        it->second[0].size());
   }
 
-  return base::nullopt;
+  return absl::nullopt;
 }
 
-base::Optional<uint8_t> LeScanResult::Flags() const {
+absl::optional<uint8_t> LeScanResult::Flags() const {
   auto it = type_to_data.find(kGapFlags);
   if (it == type_to_data.end()) {
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   DCHECK_GE(it->second.size(), 1u);
   if (it->second[0].size() != 1) {
     LOG(ERROR) << "Invalid length for flags";
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   return it->second[0][0];
 }
 
-base::Optional<LeScanResult::UuidList> LeScanResult::AllServiceUuids() const {
+absl::optional<LeScanResult::UuidList> LeScanResult::AllServiceUuids() const {
   bool any_exist = false;
   UuidList ret;
-  auto insert_if_exists = [&ret, &any_exist](base::Optional<UuidList> list) {
+  auto insert_if_exists = [&ret, &any_exist](absl::optional<UuidList> list) {
     if (list) {
       any_exist = true;
       ret.insert(ret.end(), list->begin(), list->end());
@@ -166,42 +166,42 @@
   insert_if_exists(CompleteListOf128BitServiceUuids());
 
   if (!any_exist) {
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   return ret;
 }
 
-base::Optional<LeScanResult::UuidList>
+absl::optional<LeScanResult::UuidList>
 LeScanResult::IncompleteListOf16BitServiceUuids() const {
   return GetUuidsFromShort<uint16_t, util::UuidFromInt16>(
       type_to_data, kGapIncomplete16BitServiceUuids);
 }
 
-base::Optional<LeScanResult::UuidList>
+absl::optional<LeScanResult::UuidList>
 LeScanResult::CompleteListOf16BitServiceUuids() const {
   return GetUuidsFromShort<uint16_t, util::UuidFromInt16>(
       type_to_data, kGapComplete16BitServiceUuids);
 }
 
-base::Optional<LeScanResult::UuidList>
+absl::optional<LeScanResult::UuidList>
 LeScanResult::IncompleteListOf32BitServiceUuids() const {
   return GetUuidsFromShort<uint32_t, util::UuidFromInt32>(
       type_to_data, kGapIncomplete32BitServiceUuids);
 }
 
-base::Optional<LeScanResult::UuidList>
+absl::optional<LeScanResult::UuidList>
 LeScanResult::CompleteListOf32BitServiceUuids() const {
   return GetUuidsFromShort<uint32_t, util::UuidFromInt32>(
       type_to_data, kGapComplete32BitServiceUuids);
 }
 
-base::Optional<LeScanResult::UuidList>
+absl::optional<LeScanResult::UuidList>
 LeScanResult::IncompleteListOf128BitServiceUuids() const {
   return GetUuidsAsUuid(type_to_data, kGapIncomplete128BitServiceUuids);
 }
 
-base::Optional<LeScanResult::UuidList>
+absl::optional<LeScanResult::UuidList>
 LeScanResult::CompleteListOf128BitServiceUuids() const {
   return GetUuidsAsUuid(type_to_data, kGapComplete128BitServiceUuids);
 }
diff --git a/chromecast/device/bluetooth/le/le_scan_result.h b/chromecast/device/bluetooth/le/le_scan_result.h
index dbc7144..6502bd5 100644
--- a/chromecast/device/bluetooth/le/le_scan_result.h
+++ b/chromecast/device/bluetooth/le/le_scan_result.h
@@ -10,8 +10,8 @@
 #include <vector>
 
 #include "base/containers/span.h"
-#include "base/optional.h"
 #include "chromecast/public/bluetooth/bluetooth_types.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace chromecast {
 namespace bluetooth {
@@ -43,18 +43,18 @@
 
   bool SetAdvData(base::span<const uint8_t> adv_data);
 
-  base::Optional<std::string> Name() const;
+  absl::optional<std::string> Name() const;
 
-  base::Optional<uint8_t> Flags() const;
+  absl::optional<uint8_t> Flags() const;
 
   using UuidList = std::vector<bluetooth_v2_shlib::Uuid>;
-  base::Optional<UuidList> AllServiceUuids() const;
-  base::Optional<UuidList> IncompleteListOf16BitServiceUuids() const;
-  base::Optional<UuidList> CompleteListOf16BitServiceUuids() const;
-  base::Optional<UuidList> IncompleteListOf32BitServiceUuids() const;
-  base::Optional<UuidList> CompleteListOf32BitServiceUuids() const;
-  base::Optional<UuidList> IncompleteListOf128BitServiceUuids() const;
-  base::Optional<UuidList> CompleteListOf128BitServiceUuids() const;
+  absl::optional<UuidList> AllServiceUuids() const;
+  absl::optional<UuidList> IncompleteListOf16BitServiceUuids() const;
+  absl::optional<UuidList> CompleteListOf16BitServiceUuids() const;
+  absl::optional<UuidList> IncompleteListOf32BitServiceUuids() const;
+  absl::optional<UuidList> CompleteListOf32BitServiceUuids() const;
+  absl::optional<UuidList> IncompleteListOf128BitServiceUuids() const;
+  absl::optional<UuidList> CompleteListOf128BitServiceUuids() const;
 
   using ServiceDataMap =
       std::map<bluetooth_v2_shlib::Uuid, std::vector<uint8_t>>;
diff --git a/chromecast/device/bluetooth/le/le_scan_result_test.cc b/chromecast/device/bluetooth/le/le_scan_result_test.cc
index 09ad98d6..70907bd 100644
--- a/chromecast/device/bluetooth/le/le_scan_result_test.cc
+++ b/chromecast/device/bluetooth/le/le_scan_result_test.cc
@@ -62,7 +62,7 @@
       std::vector<uint8_t>(
           reinterpret_cast<const uint8_t*>(kName1),
           reinterpret_cast<const uint8_t*>(kName1) + strlen(kName1)));
-  base::Optional<std::string> name = scan_result.Name();
+  absl::optional<std::string> name = scan_result.Name();
   ASSERT_TRUE(name);
   EXPECT_EQ(kName1, *name);
 
diff --git a/chromecast/device/bluetooth/le/mock_le_scan_manager.h b/chromecast/device/bluetooth/le/mock_le_scan_manager.h
index 41b7b4ae..26a6946 100644
--- a/chromecast/device/bluetooth/le/mock_le_scan_manager.h
+++ b/chromecast/device/bluetooth/le/mock_le_scan_manager.h
@@ -48,9 +48,9 @@
 
   MOCK_METHOD(std::vector<LeScanResult>,
               GetScanResults,
-              (base::Optional<ScanFilter> scan_filter));
+              (absl::optional<ScanFilter> scan_filter));
   void GetScanResults(GetScanResultsCallback cb,
-                      base::Optional<ScanFilter> scan_filter) override {
+                      absl::optional<ScanFilter> scan_filter) override {
     std::move(cb).Run(GetScanResults(std::move(scan_filter)));
   }
   MOCK_METHOD(void, ClearScanResults, (), (override));
diff --git a/chromecast/device/bluetooth/le/scan_filter.cc b/chromecast/device/bluetooth/le/scan_filter.cc
index cf581758..0e2d322 100644
--- a/chromecast/device/bluetooth/le/scan_filter.cc
+++ b/chromecast/device/bluetooth/le/scan_filter.cc
@@ -29,7 +29,7 @@
   }
 
   if (service_uuid) {
-    base::Optional<LeScanResult::UuidList> all_uuids =
+    absl::optional<LeScanResult::UuidList> all_uuids =
         scan_result.AllServiceUuids();
     if (!all_uuids) {
       return false;
@@ -41,7 +41,7 @@
   }
 
   if (!name && regex_name) {
-    base::Optional<std::string> scan_name = scan_result.Name();
+    absl::optional<std::string> scan_name = scan_result.Name();
     if (!scan_name || !RE2::PartialMatch(*scan_name, *regex_name)) {
       return false;
     }
diff --git a/chromecast/device/bluetooth/le/scan_filter.h b/chromecast/device/bluetooth/le/scan_filter.h
index 14682454..869b1cc 100644
--- a/chromecast/device/bluetooth/le/scan_filter.h
+++ b/chromecast/device/bluetooth/le/scan_filter.h
@@ -7,9 +7,9 @@
 
 #include <string>
 
-#include "base/optional.h"
 #include "chromecast/device/bluetooth/le/le_scan_result.h"
 #include "chromecast/public/bluetooth/bluetooth_types.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace chromecast {
 namespace bluetooth {
@@ -26,13 +26,13 @@
   bool Matches(const LeScanResult& scan_result) const;
 
   // Exact name.
-  base::Optional<std::string> name;
+  absl::optional<std::string> name;
 
   // RE2 partial match on name. This is ignored if |name| is specified.
   // https://github.com/google/re2
-  base::Optional<std::string> regex_name;
+  absl::optional<std::string> regex_name;
 
-  base::Optional<bluetooth_v2_shlib::Uuid> service_uuid;
+  absl::optional<bluetooth_v2_shlib::Uuid> service_uuid;
 };
 
 }  // namespace bluetooth
diff --git a/chromecast/external_mojo/public/cpp/external_mojo_broker.cc b/chromecast/external_mojo/public/cpp/external_mojo_broker.cc
index 49cb95a..9e51d9f8 100644
--- a/chromecast/external_mojo/public/cpp/external_mojo_broker.cc
+++ b/chromecast/external_mojo/public/cpp/external_mojo_broker.cc
@@ -18,7 +18,6 @@
 #include "base/logging.h"
 #include "base/macros.h"
 #include "base/message_loop/message_pump_for_io.h"
-#include "base/optional.h"
 #include "base/task/current_thread.h"
 #include "base/token.h"
 #include "base/trace_event/trace_event.h"
@@ -41,6 +40,7 @@
 #include "services/service_manager/public/cpp/service_receiver.h"
 #include "services/service_manager/public/mojom/connector.mojom.h"
 #include "services/service_manager/public/mojom/service.mojom.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace chromecast {
 namespace external_mojo {
@@ -60,7 +60,7 @@
     const std::string& service_name,
     const std::string& interface_name,
     service_manager::mojom::ConnectResult result,
-    const base::Optional<service_manager::Identity>& identity) {
+    const absl::optional<service_manager::Identity>& identity) {
   if (result != service_manager::mojom::ConnectResult::SUCCEEDED) {
     LOG(ERROR) << "Failed to bind " << service_name << ":" << interface_name
                << ", result = " << result;
@@ -137,7 +137,7 @@
       connector_->BindInterface(filter.service_name(), interface_name,
                                 std::move(interface_pipe));
       std::move(callback).Run(service_manager::mojom::ConnectResult::SUCCEEDED,
-                              base::nullopt);
+                              absl::nullopt);
     }
 
     void QueryService(const std::string& service_name,
@@ -149,7 +149,7 @@
     void WarmService(const ::service_manager::ServiceFilter& filter,
                      WarmServiceCallback callback) override {
       std::move(callback).Run(service_manager::mojom::ConnectResult::SUCCEEDED,
-                              base::nullopt);
+                              absl::nullopt);
     }
 
     void RegisterServiceInstance(
diff --git a/chromecast/graphics/accessibility/accessibility_focus_ring_controller.h b/chromecast/graphics/accessibility/accessibility_focus_ring_controller.h
index 30459d08..2504c524 100644
--- a/chromecast/graphics/accessibility/accessibility_focus_ring_controller.h
+++ b/chromecast/graphics/accessibility/accessibility_focus_ring_controller.h
@@ -13,10 +13,10 @@
 
 #include "base/bind.h"
 #include "base/macros.h"
-#include "base/optional.h"
 #include "base/time/time.h"
 #include "chromecast/graphics/accessibility/accessibility_focus_ring.h"
 #include "chromecast/graphics/accessibility/accessibility_layer.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/skia/include/core/SkColor.h"
 #include "ui/gfx/geometry/rect.h"
 
@@ -118,7 +118,7 @@
   std::vector<std::unique_ptr<AccessibilityFocusRingLayer>> focus_layers_;
   FocusRingBehavior focus_ring_behavior_ =
       FocusRingBehavior::FADE_OUT_FOCUS_RING;
-  base::Optional<SkColor> focus_ring_color_;
+  absl::optional<SkColor> focus_ring_color_;
 
   LayerAnimationInfo caret_animation_info_;
   gfx::Point caret_location_;
diff --git a/chromecast/graphics/accessibility/focus_ring_layer.h b/chromecast/graphics/accessibility/focus_ring_layer.h
index 4c7d4c98..6e1521a 100644
--- a/chromecast/graphics/accessibility/focus_ring_layer.h
+++ b/chromecast/graphics/accessibility/focus_ring_layer.h
@@ -9,8 +9,8 @@
 #define CHROMECAST_GRAPHICS_ACCESSIBILITY_FOCUS_RING_LAYER_H_
 
 #include "base/macros.h"
-#include "base/optional.h"
 #include "chromecast/graphics/accessibility/accessibility_layer.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/skia/include/core/SkColor.h"
 #include "ui/compositor/compositor_animation_observer.h"
 #include "ui/compositor/layer_delegate.h"
@@ -41,7 +41,7 @@
   // ui::LayerDelegate overrides:
   void OnPaintLayer(const ui::PaintContext& context) override;
 
-  base::Optional<SkColor> custom_color_;
+  absl::optional<SkColor> custom_color_;
 
   DISALLOW_COPY_AND_ASSIGN(FocusRingLayer);
 };
diff --git a/chromecast/graphics/cast_screen.h b/chromecast/graphics/cast_screen.h
index c043731..4d26107 100644
--- a/chromecast/graphics/cast_screen.h
+++ b/chromecast/graphics/cast_screen.h
@@ -6,8 +6,8 @@
 #define CHROMECAST_GRAPHICS_CAST_SCREEN_H_
 
 #include "base/macros.h"
-#include "base/optional.h"
 #include "chromecast/public/graphics_types.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "ui/display/display.h"
 #include "ui/display/screen_base.h"
 
@@ -51,7 +51,7 @@
   bool RestorePrimaryDisplaySettings();
 
  private:
-  base::Optional<display::Display> stashed_display_settings_;
+  absl::optional<display::Display> stashed_display_settings_;
 
   DISALLOW_COPY_AND_ASSIGN(CastScreen);
 };
diff --git a/chromecast/media/cma/backend/alsa/alsa_volume_control.cc b/chromecast/media/cma/backend/alsa/alsa_volume_control.cc
index 5b9b46b..760654c 100644
--- a/chromecast/media/cma/backend/alsa/alsa_volume_control.cc
+++ b/chromecast/media/cma/backend/alsa/alsa_volume_control.cc
@@ -392,11 +392,11 @@
   return success;
 }
 
-base::Optional<bool> AlsaVolumeControl::IsElementAllMuted(
+absl::optional<bool> AlsaVolumeControl::IsElementAllMuted(
     ScopedAlsaMixer* mixer) {
   if (!mixer || !mixer->element ||
       !alsa_->MixerSelemHasPlaybackSwitch(mixer->element)) {
-    return base::nullopt;
+    return absl::nullopt;
   }
   for (int32_t channel = 0; channel <= SND_MIXER_SCHN_LAST; ++channel) {
     int channel_unmuted;
@@ -405,7 +405,7 @@
         &channel_unmuted);
     if (err != 0) {
       LOG(ERROR) << "MixerSelemGetPlaybackSwitch: " << alsa_->StrError(err);
-      return base::nullopt;
+      return absl::nullopt;
     }
     if (channel_unmuted) {
       return false;
diff --git a/chromecast/media/cma/backend/alsa/alsa_volume_control.h b/chromecast/media/cma/backend/alsa/alsa_volume_control.h
index 075e487..626c0c5 100644
--- a/chromecast/media/cma/backend/alsa/alsa_volume_control.h
+++ b/chromecast/media/cma/backend/alsa/alsa_volume_control.h
@@ -11,10 +11,10 @@
 
 #include "base/macros.h"
 #include "base/message_loop/message_pump_for_io.h"
-#include "base/optional.h"
 #include "base/timer/timer.h"
 #include "chromecast/media/cma/backend/system_volume_control.h"
 #include "media/audio/alsa/alsa_wrapper.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace chromecast {
 namespace media {
@@ -54,9 +54,9 @@
                                         unsigned int mask);
 
   bool SetElementMuted(ScopedAlsaMixer* mixer, bool muted);
-  // Returns true if all channels are muted, returns base::nullopt if element
+  // Returns true if all channels are muted, returns absl::nullopt if element
   // state is not accessible.
-  base::Optional<bool> IsElementAllMuted(ScopedAlsaMixer* mixer);
+  absl::optional<bool> IsElementAllMuted(ScopedAlsaMixer* mixer);
 
   void RefreshMixerFds(ScopedAlsaMixer* mixer);
 
diff --git a/chromecast/media/cma/backend/mixer/post_processing_pipeline_parser.cc b/chromecast/media/cma/backend/mixer/post_processing_pipeline_parser.cc
index 8b41038..2805c64 100644
--- a/chromecast/media/cma/backend/mixer/post_processing_pipeline_parser.cc
+++ b/chromecast/media/cma/backend/mixer/post_processing_pipeline_parser.cc
@@ -31,7 +31,7 @@
 StreamPipelineDescriptor::StreamPipelineDescriptor(
     const base::Value* pipeline_in,
     const base::Value* stream_types_in,
-    const base::Optional<int> num_input_channels_in,
+    const absl::optional<int> num_input_channels_in,
     const base::Value* volume_limits_in)
     : pipeline(pipeline_in),
       stream_types(stream_types_in),
@@ -134,7 +134,7 @@
   if (!postprocessor_config_ || !stream_dict) {
     LOG(WARNING) << "No post-processor description found for \"" << key
                  << "\" in " << file_path_ << ". Using passthrough.";
-    return StreamPipelineDescriptor(nullptr, nullptr, base::nullopt, nullptr);
+    return StreamPipelineDescriptor(nullptr, nullptr, absl::nullopt, nullptr);
   }
   const base::Value* processors_list =
       stream_dict->FindKeyOfType(kProcessorsKey, base::Value::Type::LIST);
diff --git a/chromecast/media/cma/backend/mixer/post_processing_pipeline_parser.h b/chromecast/media/cma/backend/mixer/post_processing_pipeline_parser.h
index 06bf80c..1bd291c 100644
--- a/chromecast/media/cma/backend/mixer/post_processing_pipeline_parser.h
+++ b/chromecast/media/cma/backend/mixer/post_processing_pipeline_parser.h
@@ -12,8 +12,8 @@
 #include "base/containers/flat_set.h"
 #include "base/files/file_path.h"
 #include "base/macros.h"
-#include "base/optional.h"
 #include "base/values.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace chromecast {
 namespace media {
@@ -28,12 +28,12 @@
   //    ... ]
   const base::Value* pipeline;
   const base::Value* stream_types;
-  const base::Optional<int> num_input_channels;
+  const absl::optional<int> num_input_channels;
   const base::Value* volume_limits;
 
   StreamPipelineDescriptor(const base::Value* pipeline_in,
                            const base::Value* stream_types_in,
-                           const base::Optional<int> num_input_channels_in,
+                           const absl::optional<int> num_input_channels_in,
                            const base::Value* volume_limits_in);
   ~StreamPipelineDescriptor();
   StreamPipelineDescriptor(const StreamPipelineDescriptor& other);
diff --git a/chromecast/media/cma/backend/proxy/audio_channel_broker_impl.h b/chromecast/media/cma/backend/proxy/audio_channel_broker_impl.h
index 8fc197c2..b2db620 100644
--- a/chromecast/media/cma/backend/proxy/audio_channel_broker_impl.h
+++ b/chromecast/media/cma/backend/proxy/audio_channel_broker_impl.h
@@ -10,8 +10,8 @@
 #include "base/bind.h"
 #include "base/callback.h"
 #include "base/memory/weak_ptr.h"
-#include "base/optional.h"
 #include "chromecast/media/cma/backend/proxy/cast_runtime_audio_channel_broker.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/grpc/src/include/grpcpp/impl/codegen/status.h"
 #include "third_party/openscreen/src/cast/cast_core/api/runtime/cast_audio_channel_service.grpc.pb.h"
 #include "third_party/openscreen/src/cast/cast_core/api/runtime/cast_audio_channel_service.pb.h"
diff --git a/chromecast/media/cma/backend/proxy/audio_channel_push_buffer_handler.h b/chromecast/media/cma/backend/proxy/audio_channel_push_buffer_handler.h
index 4c6a16c..e96a478d 100644
--- a/chromecast/media/cma/backend/proxy/audio_channel_push_buffer_handler.h
+++ b/chromecast/media/cma/backend/proxy/audio_channel_push_buffer_handler.h
@@ -5,8 +5,8 @@
 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_PROXY_AUDIO_CHANNEL_PUSH_BUFFER_HANDLER_H_
 #define CHROMECAST_MEDIA_CMA_BACKEND_PROXY_AUDIO_CHANNEL_PUSH_BUFFER_HANDLER_H_
 
-#include "base/optional.h"
 #include "chromecast/media/api/cma_backend.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/openscreen/src/cast/cast_core/api/runtime/cast_audio_channel_service.pb.h"
 
 namespace chromecast {
@@ -62,7 +62,7 @@
   // true.
   //
   // May only be called by the CONSUMER.
-  virtual base::Optional<PushBufferRequest> GetBufferedData() = 0;
+  virtual absl::optional<PushBufferRequest> GetBufferedData() = 0;
 };
 
 }  // namespace media
diff --git a/chromecast/media/cma/backend/proxy/buffer_id_manager.h b/chromecast/media/cma/backend/proxy/buffer_id_manager.h
index 57bc980..0cdf19b 100644
--- a/chromecast/media/cma/backend/proxy/buffer_id_manager.h
+++ b/chromecast/media/cma/backend/proxy/buffer_id_manager.h
@@ -153,7 +153,7 @@
   int64_t pending_playback_time_in_microseconds_ = 0;
 
   // Information about the most recently played buffer.
-  mutable base::Optional<BufferPlayoutInfo> most_recently_played_buffer_;
+  mutable absl::optional<BufferPlayoutInfo> most_recently_played_buffer_;
 
   BufferIdQueue buffer_id_queue_;
   std::queue<BufferInfo> buffer_infos_;
diff --git a/chromecast/media/cma/backend/proxy/cast_runtime_audio_channel_broker.h b/chromecast/media/cma/backend/proxy/cast_runtime_audio_channel_broker.h
index 003a0b09..709aeb7e 100644
--- a/chromecast/media/cma/backend/proxy/cast_runtime_audio_channel_broker.h
+++ b/chromecast/media/cma/backend/proxy/cast_runtime_audio_channel_broker.h
@@ -8,7 +8,7 @@
 #include <memory>
 
 #include "base/memory/weak_ptr.h"
-#include "base/optional.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/openscreen/src/cast/cast_core/api/runtime/cast_audio_channel_service.pb.h"
 #include "third_party/protobuf/src/google/protobuf/duration.pb.h"
 
@@ -71,7 +71,7 @@
 
     // Returns a PushBufferRequest to be sent across the |PushBuffer| RPC. May
     // only be called if |HasBufferedData()| is true.
-    virtual base::Optional<PushBufferRequest> GetBufferedData() = 0;
+    virtual absl::optional<PushBufferRequest> GetBufferedData() = 0;
     virtual bool HasBufferedData() = 0;
 
     // Handlers for the responses of the messages defined in
@@ -103,7 +103,7 @@
 
     // Called when a |GetMediaTime| RPC call completes. If |status| is kOK, then
     // |time| is a valid non-empty MediaTime object. Else, |time| may be empty.
-    virtual void HandleGetMediaTimeResponse(base::Optional<MediaTime> time,
+    virtual void HandleGetMediaTimeResponse(absl::optional<MediaTime> time,
                                             StatusCode status) = 0;
   };
 
diff --git a/chromecast/media/cma/backend/proxy/cma_backend_proxy.h b/chromecast/media/cma/backend/proxy/cma_backend_proxy.h
index c2be4c6..1c21e621 100644
--- a/chromecast/media/cma/backend/proxy/cma_backend_proxy.h
+++ b/chromecast/media/cma/backend/proxy/cma_backend_proxy.h
@@ -10,9 +10,9 @@
 #include <memory>
 
 #include "base/callback.h"
-#include "base/optional.h"
 #include "chromecast/media/api/cma_backend.h"
 #include "chromecast/media/cma/backend/proxy/multizone_audio_decoder_proxy.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace chromecast {
 namespace media {
diff --git a/chromecast/media/cma/backend/proxy/media_pipeline_buffer_extension.h b/chromecast/media/cma/backend/proxy/media_pipeline_buffer_extension.h
index 0d4c0a5..46dd92a 100644
--- a/chromecast/media/cma/backend/proxy/media_pipeline_buffer_extension.h
+++ b/chromecast/media/cma/backend/proxy/media_pipeline_buffer_extension.h
@@ -10,11 +10,11 @@
 
 #include "base/memory/ref_counted.h"
 #include "base/memory/scoped_refptr.h"
-#include "base/optional.h"
 #include "base/threading/thread_checker.h"
 #include "chromecast/media/api/cma_backend.h"
 #include "chromecast/media/cma/backend/proxy/audio_decoder_pipeline_node.h"
 #include "chromecast/public/media/cast_key_status.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace chromecast {
 
@@ -60,8 +60,8 @@
     PendingCommand& operator=(const PendingCommand& other);
     PendingCommand& operator=(PendingCommand&& other);
 
-    base::Optional<scoped_refptr<DecoderBufferBase>> buffer;
-    base::Optional<AudioConfig> config;
+    absl::optional<scoped_refptr<DecoderBufferBase>> buffer;
+    absl::optional<AudioConfig> config;
   };
 
   // AudioDecoderPipelineNode overrides.
diff --git a/chromecast/media/cma/backend/proxy/proxy_call_translator.cc b/chromecast/media/cma/backend/proxy/proxy_call_translator.cc
index ca7b541f..a3fe68f 100644
--- a/chromecast/media/cma/backend/proxy/proxy_call_translator.cc
+++ b/chromecast/media/cma/backend/proxy/proxy_call_translator.cc
@@ -284,7 +284,7 @@
       ToGrpcTypes(std::move(buffer), buffer_id));
 }
 
-base::Optional<ProxyCallTranslator::PushBufferRequest>
+absl::optional<ProxyCallTranslator::PushBufferRequest>
 ProxyCallTranslator::GetBufferedData() {
   return push_buffer_handler_.GetBufferedData();
 }
@@ -335,7 +335,7 @@
 }
 
 void ProxyCallTranslator::HandleGetMediaTimeResponse(
-    base::Optional<MediaTime> time,
+    absl::optional<MediaTime> time,
     CastRuntimeAudioChannelBroker::StatusCode status) {
   NOTREACHED();
 }
diff --git a/chromecast/media/cma/backend/proxy/proxy_call_translator.h b/chromecast/media/cma/backend/proxy/proxy_call_translator.h
index 976e08a6..a008c8b 100644
--- a/chromecast/media/cma/backend/proxy/proxy_call_translator.h
+++ b/chromecast/media/cma/backend/proxy/proxy_call_translator.h
@@ -8,12 +8,12 @@
 #include <memory>
 
 #include "base/memory/ref_counted.h"
-#include "base/optional.h"
 #include "chromecast/media/api/decoder_buffer_base.h"
 #include "chromecast/media/cma/backend/proxy/buffer_id_manager.h"
 #include "chromecast/media/cma/backend/proxy/cast_runtime_audio_channel_broker.h"
 #include "chromecast/media/cma/backend/proxy/cma_proxy_handler.h"
 #include "chromecast/media/cma/backend/proxy/push_buffer_pending_handler.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace chromecast {
 
@@ -75,7 +75,7 @@
       std::unique_ptr<CastRuntimeAudioChannelBroker> decoder_channel);
 
   // CastRuntimeAudioChannelBroker::Handler overrides:
-  base::Optional<PushBufferRequest> GetBufferedData() override;
+  absl::optional<PushBufferRequest> GetBufferedData() override;
   bool HasBufferedData() override;
   void HandleInitializeResponse(
       CastRuntimeAudioChannelBroker::StatusCode status) override;
@@ -90,7 +90,7 @@
       int64_t decoded_bytes,
       CastRuntimeAudioChannelBroker::StatusCode status) override;
   void HandleGetMediaTimeResponse(
-      base::Optional<MediaTime> time,
+      absl::optional<MediaTime> time,
       CastRuntimeAudioChannelBroker::StatusCode status) override;
 
   // Helper to share error handling code.
diff --git a/chromecast/media/cma/backend/proxy/push_buffer_pending_handler.cc b/chromecast/media/cma/backend/proxy/push_buffer_pending_handler.cc
index 39d944c6..8713649 100644
--- a/chromecast/media/cma/backend/proxy/push_buffer_pending_handler.cc
+++ b/chromecast/media/cma/backend/proxy/push_buffer_pending_handler.cc
@@ -77,7 +77,7 @@
   return delegated_handler_->HasBufferedData();
 }
 
-base::Optional<AudioChannelPushBufferHandler::PushBufferRequest>
+absl::optional<AudioChannelPushBufferHandler::PushBufferRequest>
 PushBufferPendingHandler::GetBufferedData() {
   // The pending data is only considered by the producer sequence, so this
   // consumer sequence call does not consider it.
diff --git a/chromecast/media/cma/backend/proxy/push_buffer_pending_handler.h b/chromecast/media/cma/backend/proxy/push_buffer_pending_handler.h
index 1129e8b..cfea504f 100644
--- a/chromecast/media/cma/backend/proxy/push_buffer_pending_handler.h
+++ b/chromecast/media/cma/backend/proxy/push_buffer_pending_handler.h
@@ -58,7 +58,7 @@
   CmaBackend::BufferStatus PushBuffer(
       const PushBufferRequest& request) override;
   bool HasBufferedData() const override;
-  base::Optional<PushBufferRequest> GetBufferedData() override;
+  absl::optional<PushBufferRequest> GetBufferedData() override;
 
  private:
   friend class PushBufferPendingHandlerTest;
diff --git a/chromecast/media/cma/backend/proxy/push_buffer_pending_handler_unittest.cc b/chromecast/media/cma/backend/proxy/push_buffer_pending_handler_unittest.cc
index 47072b5..2ca42c6 100644
--- a/chromecast/media/cma/backend/proxy/push_buffer_pending_handler_unittest.cc
+++ b/chromecast/media/cma/backend/proxy/push_buffer_pending_handler_unittest.cc
@@ -71,7 +71,7 @@
 
   MOCK_METHOD1(PushBuffer, CmaBackend::BufferStatus(const PushBufferRequest&));
   MOCK_CONST_METHOD0(HasBufferedData, bool());
-  MOCK_METHOD0(GetBufferedData, base::Optional<PushBufferRequest>());
+  MOCK_METHOD0(GetBufferedData, absl::optional<PushBufferRequest>());
 };
 
 }  // namespace
diff --git a/chromecast/media/cma/backend/proxy/push_buffer_queue.cc b/chromecast/media/cma/backend/proxy/push_buffer_queue.cc
index e5b9477..822bd24 100644
--- a/chromecast/media/cma/backend/proxy/push_buffer_queue.cc
+++ b/chromecast/media/cma/backend/proxy/push_buffer_queue.cc
@@ -70,7 +70,7 @@
     // when the entire |buffer_| is full at time of writing.
     bytes_written_during_current_write_ = 0;
     producer_handler_.overflow();
-    producer_stream_ = base::nullopt;
+    producer_stream_ = absl::nullopt;
     producer_stream_.emplace(&producer_handler_);
   }
 
@@ -82,7 +82,7 @@
   return !is_in_invalid_state_ && GetAvailableyByteCount() != size_t{0};
 }
 
-base::Optional<PushBufferQueue::PushBufferRequest>
+absl::optional<PushBufferQueue::PushBufferRequest>
 PushBufferQueue::GetBufferedData() {
   auto result = GetBufferedDataImpl();
   if (result.has_value()) {
@@ -92,7 +92,7 @@
   return result;
 }
 
-base::Optional<PushBufferQueue::PushBufferRequest>
+absl::optional<PushBufferQueue::PushBufferRequest>
 PushBufferQueue::GetBufferedDataImpl() {
   DCHECK_CALLED_ON_VALID_SEQUENCE(consumer_sequence_checker_);
   DCHECK(HasBufferedData());
@@ -127,12 +127,12 @@
 
     // If |!succeeded|, the streams have ended up in an unexpected state and
     // need to be recreated.
-    protobuf_consumer_stream_ = base::nullopt;
-    consumer_stream_ = base::nullopt;
+    protobuf_consumer_stream_ = absl::nullopt;
+    consumer_stream_ = absl::nullopt;
     consumer_stream_.emplace(&consumer_handler_);
     protobuf_consumer_stream_.emplace(&consumer_stream_.value(), 1);
 
-    return base::nullopt;
+    return absl::nullopt;
   }
 
   consecuitive_read_failures_ = 0;
diff --git a/chromecast/media/cma/backend/proxy/push_buffer_queue.h b/chromecast/media/cma/backend/proxy/push_buffer_queue.h
index 38fa4ce..a09d26b 100644
--- a/chromecast/media/cma/backend/proxy/push_buffer_queue.h
+++ b/chromecast/media/cma/backend/proxy/push_buffer_queue.h
@@ -9,11 +9,11 @@
 #include <istream>
 #include <ostream>
 
-#include "base/optional.h"
 #include "base/sequence_checker.h"
 #include "chromecast/media/api/cma_backend.h"
 #include "chromecast/media/api/decoder_buffer_base.h"
 #include "chromecast/media/cma/backend/proxy/audio_channel_push_buffer_handler.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/openscreen/src/cast/cast_core/api/runtime/cast_audio_channel_service.pb.h"
 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h"
 
@@ -47,7 +47,7 @@
   CmaBackend::BufferStatus PushBuffer(
       const PushBufferRequest& request) override;
   bool HasBufferedData() const override;
-  base::Optional<PushBufferRequest> GetBufferedData() override;
+  absl::optional<PushBufferRequest> GetBufferedData() override;
 
  private:
   // These classes exist for the following 2 reasons:
@@ -128,7 +128,7 @@
 
   // Helper methods to be used for test hooks.
   bool PushBufferImpl(const PushBufferRequest& request);
-  base::Optional<PushBufferRequest> GetBufferedDataImpl();
+  absl::optional<PushBufferRequest> GetBufferedDataImpl();
 
   // Buffer where serialized PushBufferRequest data is stored.
   char buffer_[kBufferSizeBytes];
@@ -168,14 +168,14 @@
   // Input streams backed by this instance. They must be optional so that they
   // can be re-created following a failed read. These should only be used by the
   // CONSUMER.
-  base::Optional<std::istream> consumer_stream_;
-  base::Optional<google::protobuf::io::IstreamInputStream>
+  absl::optional<std::istream> consumer_stream_;
+  absl::optional<google::protobuf::io::IstreamInputStream>
       protobuf_consumer_stream_;
 
   // Output stream backed by this instance. This must be optional so it can be
   // re-created following a failed write. It should only be used by the
   // PRODUCER.
-  base::Optional<std::ostream> producer_stream_;
+  absl::optional<std::ostream> producer_stream_;
 };
 
 }  // namespace media
diff --git a/chromecast/media/cma/backend/proxy/push_buffer_queue_unittest.cc b/chromecast/media/cma/backend/proxy/push_buffer_queue_unittest.cc
index 46b1b1a..6da70e4 100644
--- a/chromecast/media/cma/backend/proxy/push_buffer_queue_unittest.cc
+++ b/chromecast/media/cma/backend/proxy/push_buffer_queue_unittest.cc
@@ -9,10 +9,10 @@
 
 #include "base/bind.h"
 #include "base/location.h"
-#include "base/optional.h"
 #include "base/threading/thread.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/openscreen/src/cast/cast_core/api/runtime/cast_audio_channel_service.grpc.pb.h"
 
 namespace chromecast {
@@ -49,7 +49,7 @@
   void ReadData(const std::string& name,
                 const PushBufferQueue::PushBufferRequest& target_buffer) {
     ASSERT_TRUE(queue_.HasBufferedData()) << name;
-    base::Optional<PushBufferRequest> get = queue_.GetBufferedData();
+    absl::optional<PushBufferRequest> get = queue_.GetBufferedData();
     ASSERT_TRUE(get.has_value()) << name;
     CheckEqual("first", get.value(), target_buffer);
   }
@@ -136,7 +136,7 @@
     return queue_.PushBufferImpl(request);
   }
 
-  base::Optional<PushBufferQueue::PushBufferRequest> StartGetBufferedData() {
+  absl::optional<PushBufferQueue::PushBufferRequest> StartGetBufferedData() {
     return queue_.GetBufferedDataImpl();
   }
 
@@ -269,7 +269,7 @@
   UpdateBufferWriteStreamPositions();
 
   ASSERT_TRUE(queue_.HasBufferedData());
-  base::Optional<PushBufferRequest> pulled_buffer = queue_.GetBufferedData();
+  absl::optional<PushBufferRequest> pulled_buffer = queue_.GetBufferedData();
   EXPECT_FALSE(pulled_buffer.has_value());
   EXPECT_TRUE(queue_.HasBufferedData());
 
diff --git a/chromecast/media/cma/base/decoder_config_adapter.cc b/chromecast/media/cma/base/decoder_config_adapter.cc
index 0169173..dac3c3f 100644
--- a/chromecast/media/cma/base/decoder_config_adapter.cc
+++ b/chromecast/media/cma/base/decoder_config_adapter.cc
@@ -332,7 +332,7 @@
   video_config.matrix = static_cast<MatrixID>(config.color_space_info().matrix);
   video_config.range = static_cast<RangeID>(config.color_space_info().range);
 
-  base::Optional<::gfx::HDRMetadata> hdr_metadata = config.hdr_metadata();
+  absl::optional<::gfx::HDRMetadata> hdr_metadata = config.hdr_metadata();
   if (hdr_metadata) {
     video_config.have_hdr_metadata = true;
     video_config.hdr_metadata.max_content_light_level =
diff --git a/chromecast/media/cma/decoder/cast_audio_decoder.cc b/chromecast/media/cma/decoder/cast_audio_decoder.cc
index 51d1e0f..dd294df 100644
--- a/chromecast/media/cma/decoder/cast_audio_decoder.cc
+++ b/chromecast/media/cma/decoder/cast_audio_decoder.cc
@@ -16,7 +16,6 @@
 #include "base/location.h"
 #include "base/logging.h"
 #include "base/macros.h"
-#include "base/optional.h"
 #include "base/single_thread_task_runner.h"
 #include "chromecast/media/api/decoder_buffer_base.h"
 #include "chromecast/media/cma/base/decoder_buffer_adapter.h"
@@ -32,6 +31,7 @@
 #include "media/base/sample_format.h"
 #include "media/base/status.h"
 #include "media/filters/ffmpeg_audio_decoder.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace chromecast {
 namespace media {
diff --git a/chromecast/media/gpu/cast_gpu_factory_impl.cc b/chromecast/media/gpu/cast_gpu_factory_impl.cc
index eaa8ec2..da43ca86 100644
--- a/chromecast/media/gpu/cast_gpu_factory_impl.cc
+++ b/chromecast/media/gpu/cast_gpu_factory_impl.cc
@@ -176,7 +176,7 @@
       implementation, request_overlay_info_cb, gfx::ColorSpace::CreateSRGB());
 }
 
-base::Optional<::media::VideoEncodeAccelerator::SupportedProfiles>
+absl::optional<::media::VideoEncodeAccelerator::SupportedProfiles>
 CastGpuFactoryImpl::GetVideoEncodeAcceleratorSupportedProfiles() {
   return ::media::VideoEncodeAccelerator::SupportedProfiles();
 }
diff --git a/chromecast/media/gpu/cast_gpu_factory_impl.h b/chromecast/media/gpu/cast_gpu_factory_impl.h
index 6929556..d33e47f8 100644
--- a/chromecast/media/gpu/cast_gpu_factory_impl.h
+++ b/chromecast/media/gpu/cast_gpu_factory_impl.h
@@ -64,7 +64,7 @@
       ::media::MediaLog* media_log,
       ::media::VideoDecoderImplementation implementation,
       ::media::RequestOverlayInfoCB request_overlay_info_cb) override;
-  base::Optional<media::VideoEncodeAccelerator::SupportedProfiles>
+  absl::optional<media::VideoEncodeAccelerator::SupportedProfiles>
   GetVideoEncodeAcceleratorSupportedProfiles() override;
   bool IsEncoderSupportKnown() override;
   void NotifyEncoderSupportKnown(base::OnceClosure) override;
diff --git a/chromecast/media/service/cast_renderer.cc b/chromecast/media/service/cast_renderer.cc
index fcac6e1e..e8ade00 100644
--- a/chromecast/media/service/cast_renderer.cc
+++ b/chromecast/media/service/cast_renderer.cc
@@ -345,7 +345,7 @@
 }
 
 void CastRenderer::SetLatencyHint(
-    base::Optional<base::TimeDelta> latency_hint) {}
+    absl::optional<base::TimeDelta> latency_hint) {}
 
 void CastRenderer::Flush(base::OnceClosure flush_cb) {
   DCHECK(task_runner_->BelongsToCurrentThread());
diff --git a/chromecast/media/service/cast_renderer.h b/chromecast/media/service/cast_renderer.h
index 9b2740a..e114a754 100644
--- a/chromecast/media/service/cast_renderer.h
+++ b/chromecast/media/service/cast_renderer.h
@@ -10,7 +10,6 @@
 
 #include "base/memory/weak_ptr.h"
 #include "base/no_destructor.h"
-#include "base/optional.h"
 #include "base/unguessable_token.h"
 #include "chromecast/common/mojom/multiroom.mojom.h"
 #include "chromecast/common/mojom/service_connector.mojom.h"
@@ -23,6 +22,7 @@
 #include "media/mojo/mojom/frame_interface_factory.mojom.h"
 #include "mojo/public/cpp/bindings/receiver.h"
 #include "mojo/public/cpp/bindings/remote.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "ui/gfx/geometry/rect_f.h"
 #include "ui/gfx/overlay_transform.h"
 
@@ -63,7 +63,7 @@
                   ::media::PipelineStatusCallback init_cb) final;
   void SetCdm(::media::CdmContext* cdm_context,
               CdmAttachedCB cdm_attached_cb) final;
-  void SetLatencyHint(base::Optional<base::TimeDelta> latency_hint) final;
+  void SetLatencyHint(absl::optional<base::TimeDelta> latency_hint) final;
   void Flush(base::OnceClosure flush_cb) final;
   void StartPlayingFrom(base::TimeDelta time) final;
   void SetPlaybackRate(double playback_rate) final;
@@ -142,7 +142,7 @@
     return *g_overlay_composited_callback;
   }
 
-  base::Optional<float> pending_volume_;
+  absl::optional<float> pending_volume_;
 
   base::WeakPtrFactory<CastRenderer> weak_factory_;
   DISALLOW_COPY_AND_ASSIGN(CastRenderer);
diff --git a/chromecast/renderer/activity_filtering_websocket_handshake_throttle.cc b/chromecast/renderer/activity_filtering_websocket_handshake_throttle.cc
index 4d4a5cb..243b5ed 100644
--- a/chromecast/renderer/activity_filtering_websocket_handshake_throttle.cc
+++ b/chromecast/renderer/activity_filtering_websocket_handshake_throttle.cc
@@ -24,7 +24,7 @@
 
   // Pass through allowed URLs, block otherwise.
   if (url_filter_->UrlMatchesWhitelist(gurl)) {
-    std::move(completion_callback).Run(base::nullopt);
+    std::move(completion_callback).Run(absl::nullopt);
     return;
   }
 
diff --git a/chromecast/renderer/cast_content_renderer_client.cc b/chromecast/renderer/cast_content_renderer_client.cc
index aa69a80..dabd118 100644
--- a/chromecast/renderer/cast_content_renderer_client.cc
+++ b/chromecast/renderer/cast_content_renderer_client.cc
@@ -7,7 +7,6 @@
 #include <utility>
 
 #include "base/command_line.h"
-#include "base/optional.h"
 #include "base/strings/string_number_conversions.h"
 #include "chromecast/base/bitstream_audio_codecs.h"
 #include "chromecast/base/cast_features.h"
@@ -38,6 +37,7 @@
 #include "mojo/public/cpp/bindings/pending_remote.h"
 #include "mojo/public/cpp/bindings/remote.h"
 #include "services/network/public/cpp/is_potentially_trustworthy.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 #include "third_party/blink/public/common/browser_interface_broker_proxy.h"
 #include "third_party/blink/public/platform/web_runtime_features.h"
 #include "third_party/blink/public/web/web_frame_widget.h"
@@ -396,7 +396,7 @@
       type, activity_url_filter_manager(), this);
 }
 
-base::Optional<::media::AudioRendererAlgorithmParameters>
+absl::optional<::media::AudioRendererAlgorithmParameters>
 CastContentRendererClient::GetAudioRendererAlgorithmParameters(
     ::media::AudioParameters audio_parameters) {
 #if defined(OS_ANDROID)
@@ -405,9 +405,9 @@
   parameters.starting_capacity = kAudioRendererStartingCapacity;
   parameters.starting_capacity_for_encrypted =
       kAudioRendererStartingCapacityEncrypted;
-  return base::Optional<::media::AudioRendererAlgorithmParameters>(parameters);
+  return absl::optional<::media::AudioRendererAlgorithmParameters>(parameters);
 #else
-  return base::nullopt;
+  return absl::nullopt;
 #endif
 }
 
diff --git a/chromecast/renderer/cast_content_renderer_client.h b/chromecast/renderer/cast_content_renderer_client.h
index 5e5de3a..0eb203ca 100644
--- a/chromecast/renderer/cast_content_renderer_client.h
+++ b/chromecast/renderer/cast_content_renderer_client.h
@@ -79,7 +79,7 @@
   std::unique_ptr<blink::URLLoaderThrottleProvider>
   CreateURLLoaderThrottleProvider(
       blink::URLLoaderThrottleProviderType type) override;
-  base::Optional<::media::AudioRendererAlgorithmParameters>
+  absl::optional<::media::AudioRendererAlgorithmParameters>
   GetAudioRendererAlgorithmParameters(
       ::media::AudioParameters audio_parameters) override;