Skip to content

Commit

Permalink
android_webview and apps: Replace base::Optional with absl
Browse files Browse the repository at this point in the history
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: Ie3384fe06a80c986a6b610752e10fff02e4b65a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2897150
Auto-Submit: Anton Bikineev <bikineev@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883143}
  • Loading branch information
Anton Bikineev authored and Chromium LUCI CQ committed May 14, 2021
1 parent 39fe786 commit 9c8495f
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 62 deletions.
14 changes: 7 additions & 7 deletions android_webview/browser/aw_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ gfx::ImageSkia AwContentBrowserClient::GetDefaultFavicon() {
bool AwContentBrowserClient::AllowAppCache(
const GURL& manifest_url,
const GURL& site_for_cookies,
const base::Optional<url::Origin>& top_frame_origin,
const absl::optional<url::Origin>& top_frame_origin,
content::BrowserContext* context) {
// WebView doesn't have a per-site policy for locally stored data,
// instead AppCache can be disabled for individual WebViews.
Expand Down Expand Up @@ -792,7 +792,7 @@ bool AwContentBrowserClient::HandleExternalProtocol(
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const base::Optional<url::Origin>& initiating_origin,
const absl::optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver =
out_factory->InitWithNewPipeAndPassReceiver();
Expand All @@ -802,7 +802,7 @@ bool AwContentBrowserClient::HandleExternalProtocol(
// Manages its own lifetime.
new android_webview::AwProxyingURLLoaderFactory(
frame_tree_node_id, std::move(receiver), mojo::NullRemote(),
true /* intercept_only */, base::nullopt /* security_options */);
true /* intercept_only */, absl::nullopt /* security_options */);
} else {
content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE,
Expand All @@ -813,7 +813,7 @@ bool AwContentBrowserClient::HandleExternalProtocol(
new android_webview::AwProxyingURLLoaderFactory(
frame_tree_node_id, std::move(receiver), mojo::NullRemote(),
true /* intercept_only */,
base::nullopt /* security_options */);
absl::nullopt /* security_options */);
},
std::move(receiver), frame_tree_node_id));
}
Expand Down Expand Up @@ -877,7 +877,7 @@ bool AwContentBrowserClient::WillCreateURLLoaderFactory(
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
base::Optional<int64_t> navigation_id,
absl::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
Expand Down Expand Up @@ -912,7 +912,7 @@ bool AwContentBrowserClient::WillCreateURLLoaderFactory(
// Android WebView has one non off-the-record browser context.
if (frame) {
auto security_options =
base::make_optional<AwProxyingURLLoaderFactory::SecurityOptions>();
absl::make_optional<AwProxyingURLLoaderFactory::SecurityOptions>();
security_options->disable_web_security =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableWebSecurity);
Expand Down Expand Up @@ -948,7 +948,7 @@ bool AwContentBrowserClient::WillCreateURLLoaderFactory(
content::RenderFrameHost::kNoFrameTreeNodeId,
std::move(proxied_receiver),
std::move(target_factory_remote),
base::nullopt /* security_options */));
absl::nullopt /* security_options */));
}
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions android_webview/browser/aw_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
gfx::ImageSkia GetDefaultFavicon() override;
bool AllowAppCache(const GURL& manifest_url,
const GURL& site_for_cookies,
const base::Optional<url::Origin>& top_frame_origin,
const absl::optional<url::Origin>& top_frame_origin,
content::BrowserContext* context) override;
scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext()
override;
Expand Down Expand Up @@ -186,7 +186,7 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
bool is_main_frame,
ui::PageTransition page_transition,
bool has_user_gesture,
const base::Optional<url::Origin>& initiating_origin,
const absl::optional<url::Origin>& initiating_origin,
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
override;
void RegisterNonNetworkSubresourceURLLoaderFactories(
Expand All @@ -204,7 +204,7 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
int render_process_id,
URLLoaderFactoryType type,
const url::Origin& request_initiator,
base::Optional<int64_t> navigation_id,
absl::optional<int64_t> navigation_id,
ukm::SourceIdObj ukm_source_id,
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/aw_feature_list_creator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void AwFeatureListCreator::SetUpFieldTrials() {
*base::CommandLine::ForCurrentProcess()),
/*low_entropy_provider=*/nullptr, std::make_unique<base::FeatureList>(),
aw_field_trials_.get(), &ignored_safe_seed_manager,
/*low_entropy_source_value=*/base::nullopt);
/*low_entropy_source_value=*/absl::nullopt);
}

void AwFeatureListCreator::CreateLocalState() {
Expand Down
8 changes: 4 additions & 4 deletions android_webview/browser/aw_http_auth_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/bind.h"
#include "base/optional.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "net/base/auth.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

using base::android::ConvertJavaStringToUTF16;
using base::android::JavaParamRef;
Expand Down Expand Up @@ -62,7 +62,7 @@ void AwHttpAuthHandler::Proceed(JNIEnv* env,
void AwHttpAuthHandler::Cancel(JNIEnv* env, const JavaParamRef<jobject>& obj) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (callback_) {
std::move(callback_).Run(base::nullopt);
std::move(callback_).Run(absl::nullopt);
}
}

Expand All @@ -72,14 +72,14 @@ void AwHttpAuthHandler::Start() {

// The WebContents may have been destroyed during the PostTask.
if (!web_contents()) {
std::move(callback_).Run(base::nullopt);
std::move(callback_).Run(absl::nullopt);
return;
}

AwContents* aw_contents = AwContents::FromWebContents(web_contents());
if (!aw_contents->OnReceivedHttpAuthRequest(http_auth_handler_, host_,
realm_)) {
std::move(callback_).Run(base::nullopt);
std::move(callback_).Run(absl::nullopt);
}
}

Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/cookie_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/optional.h"
#include "base/path_service.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
Expand All @@ -49,6 +48,7 @@
#include "services/network/cookie_access_delegate_impl.h"
#include "services/network/network_service.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/url_constants.h"

using base::WaitableEvent;
Expand Down Expand Up @@ -465,7 +465,7 @@ void CookieManager::SetCookieHelper(const GURL& host,
host, value, workaround_http_secure_cookies_, &should_allow_cookie);

std::unique_ptr<net::CanonicalCookie> cc(net::CanonicalCookie::Create(
new_host, value, base::Time::Now(), base::nullopt /* server_time */));
new_host, value, base::Time::Now(), absl::nullopt /* server_time */));

if (!cc || !should_allow_cookie) {
MaybeRunCookieCallback(std::move(callback), false);
Expand Down
6 changes: 3 additions & 3 deletions android_webview/browser/gfx/aw_draw_fn_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "android_webview/public/browser/draw_fn.h"
#include "base/android/scoped_java_ref.h"
#include "base/macros.h"
#include "base/optional.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkRefCnt.h"

namespace android_webview {
Expand Down Expand Up @@ -63,10 +63,10 @@ class AwDrawFnImpl {
// Vulkan context provider for Vk rendering.
scoped_refptr<AwVulkanContextProvider> vulkan_context_provider_;

base::Optional<AwVulkanContextProvider::ScopedSecondaryCBDraw>
absl::optional<AwVulkanContextProvider::ScopedSecondaryCBDraw>
scoped_secondary_cb_draw_;

base::Optional<VulkanGLInterop> interop_;
absl::optional<VulkanGLInterop> interop_;

DISALLOW_COPY_AND_ASSIGN(AwDrawFnImpl);
};
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/gfx/aw_vulkan_context_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ void AwVulkanContextProvider::EnqueueSecondaryCBPostSubmitTask(
post_submit_tasks_.push_back(std::move(closure));
}

base::Optional<uint32_t> AwVulkanContextProvider::GetSyncCpuMemoryLimit()
absl::optional<uint32_t> AwVulkanContextProvider::GetSyncCpuMemoryLimit()
const {
return base::Optional<uint32_t>();
return absl::optional<uint32_t>();
}

bool AwVulkanContextProvider::Initialize(AwDrawFn_InitVkParams* params) {
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/gfx/aw_vulkan_context_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include <memory>

#include "base/macros.h"
#include "base/optional.h"
#include "components/viz/common/gpu/vulkan_context_provider.h"
#include "gpu/vulkan/vulkan_device_queue.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkSurfaceCharacterization.h"
#include "third_party/skia/include/gpu/GrBackendSemaphore.h"
Expand Down Expand Up @@ -56,7 +56,7 @@ class AwVulkanContextProvider final : public viz::VulkanContextProvider {
void EnqueueSecondaryCBSemaphores(
std::vector<VkSemaphore> semaphores) override;
void EnqueueSecondaryCBPostSubmitTask(base::OnceClosure closure) override;
base::Optional<uint32_t> GetSyncCpuMemoryLimit() const override;
absl::optional<uint32_t> GetSyncCpuMemoryLimit() const override;

VkDevice device() { return globals_->device_queue->GetVulkanDevice(); }
VkQueue queue() { return globals_->device_queue->GetVulkanQueue(); }
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/gfx/browser_view_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#include "base/cancelable_callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/optional.h"
#include "base/trace_event/trace_event.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "content/public/browser/android/synchronous_compositor.h"
#include "content/public/browser/android/synchronous_compositor_client.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size_f.h"
Expand Down Expand Up @@ -272,7 +272,7 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient,
gfx::Vector2dF overscroll_rounding_error_;

// The scroll to apply after the next scroll state update.
base::Optional<gfx::Vector2d> scroll_on_scroll_state_update_;
absl::optional<gfx::Vector2d> scroll_on_scroll_state_update_;

ParentCompositorDrawConstraints external_draw_constraints_;

Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/gfx/child_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ChildFrame {
scoped_refptr<content::SynchronousCompositor::FrameFuture> frame_future;
uint32_t layer_tree_frame_sink_id = 0u;
std::unique_ptr<viz::CompositorFrame> frame;
base::Optional<viz::HitTestRegionList> hit_test_region_list;
absl::optional<viz::HitTestRegionList> hit_test_region_list;
// The id of the compositor this |frame| comes from.
const viz::FrameSinkId frame_sink_id;
// Local surface id of the frame. Invalid if |frame| is null.
Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/gfx/display_scheduler_webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#ifndef ANDROID_WEBVIEW_BROWSER_GFX_DISPLAY_SCHEDULER_WEBVIEW_H_
#define ANDROID_WEBVIEW_BROWSER_GFX_DISPLAY_SCHEDULER_WEBVIEW_H_

#include "base/optional.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread_checker.h"
#include "components/viz/service/display/display_scheduler.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

namespace android_webview {
class RootFrameSink;
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/gfx/hardware_renderer_viz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void HardwareRendererViz::OnViz::DrawAndSwapOnViz(
render_pass->CreateAndAppendDrawQuad<viz::SurfaceDrawQuad>();
surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_rect),
gfx::Rect(quad_state->quad_layer_rect),
viz::SurfaceRange(base::nullopt, child_id),
viz::SurfaceRange(absl::nullopt, child_id),
SK_ColorWHITE, /*stretch_content_to_fill_bounds=*/false);

viz::CompositorFrame frame;
Expand Down Expand Up @@ -415,7 +415,7 @@ void HardwareRendererViz::DrawAndSwap(const HardwareRendererDrawParams& params,
->PessimisticallyResetGrContext();
}

base::Optional<OverlayProcessorWebView::ScopedSurfaceControlAvailable>
absl::optional<OverlayProcessorWebView::ScopedSurfaceControlAvailable>
allow_surface_control;

auto* overlay_processor = on_viz_->overlay_processor();
Expand Down
8 changes: 4 additions & 4 deletions android_webview/browser/gfx/overlay_processor_webview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class OverlayProcessorWebView::Manager
gpu_task_runner_ = gpu_service->main_runner();
}

base::Optional<gfx::SurfaceControl::Transaction> TakeHWUITransaction() {
absl::optional<gfx::SurfaceControl::Transaction> TakeHWUITransaction() {
DCHECK_CALLED_ON_VALID_THREAD(render_thread_checker_);

base::Optional<gfx::SurfaceControl::Transaction> result;
absl::optional<gfx::SurfaceControl::Transaction> result;
if (hwui_transaction_) {
result.swap(hwui_transaction_);
}
Expand Down Expand Up @@ -100,7 +100,7 @@ class OverlayProcessorWebView::Manager
scoped_refptr<gpu::SyncPointClientState> sync_point_client_state_;

scoped_refptr<gfx::SurfaceControl::Surface> parent_surface_;
base::Optional<gfx::SurfaceControl::Transaction> hwui_transaction_;
absl::optional<gfx::SurfaceControl::Transaction> hwui_transaction_;

GetSurfaceControlFn get_surface_control_ = nullptr;

Expand Down Expand Up @@ -152,7 +152,7 @@ void OverlayProcessorWebView::RemoveOverlays() {
NOTIMPLEMENTED();
}

base::Optional<gfx::SurfaceControl::Transaction>
absl::optional<gfx::SurfaceControl::Transaction>
OverlayProcessorWebView::TakeSurfaceTransactionOnRT() {
DCHECK(manager_);
return manager_->TakeHWUITransaction();
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/gfx/overlay_processor_webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ class OverlayProcessorWebView : public viz::OverlayProcessorSurfaceControl {

void SetOverlaysEnabledByHWUI(bool enabled);
void RemoveOverlays();
base::Optional<gfx::SurfaceControl::Transaction> TakeSurfaceTransactionOnRT();
absl::optional<gfx::SurfaceControl::Transaction> TakeSurfaceTransactionOnRT();

// viz::OverlayProcessorSurfaceControl overrides:
void TakeOverlayCandidates(
viz::OverlayCandidateList* candidate_list) override;
void ScheduleOverlays(
viz::DisplayResourceProvider* resource_provider) override;
void AdjustOutputSurfaceOverlay(base::Optional<OutputSurfaceOverlayPlane>*
void AdjustOutputSurfaceOverlay(absl::optional<OutputSurfaceOverlayPlane>*
output_surface_plane) override {}
void CheckOverlaySupport(
const viz::OverlayProcessorInterface::OutputSurfaceOverlayPlane*
Expand Down
6 changes: 3 additions & 3 deletions android_webview/browser/gfx/render_thread_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/optional.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "base/trace_event/traced_value.h"
#include "components/viz/common/features.h"
#include "components/viz/common/quads/compositor_frame.h"
#include "third_party/abseil-cpp/absl/types/optional.h"

namespace android_webview {

Expand Down Expand Up @@ -196,7 +196,7 @@ void RenderThreadManager::DrawOnRT(bool save_restore,
// Force GL binding init if it's not yet initialized.
GpuServiceWebView::GetInstance();

base::Optional<ScopedAppGLStateRestore> state_restore;
absl::optional<ScopedAppGLStateRestore> state_restore;
if (!vulkan_context_provider_) {
state_restore.emplace(ScopedAppGLStateRestore::MODE_DRAW, save_restore);
}
Expand Down Expand Up @@ -227,7 +227,7 @@ void RenderThreadManager::RemoveOverlaysOnRT(
void RenderThreadManager::DestroyHardwareRendererOnRT(bool save_restore) {
GpuServiceWebView::GetInstance();

base::Optional<ScopedAppGLStateRestore> state_restore;
absl::optional<ScopedAppGLStateRestore> state_restore;
if (!vulkan_context_provider_) {
state_restore.emplace(ScopedAppGLStateRestore::MODE_RESOURCE_MANAGEMENT,
save_restore);
Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/gfx/root_frame_sink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RootFrameSink::ChildCompositorFrameSink
void SubmitCompositorFrame(
const viz::LocalSurfaceId& local_surface_id,
viz::CompositorFrame frame,
base::Optional<viz::HitTestRegionList> hit_test_region_list) {
absl::optional<viz::HitTestRegionList> hit_test_region_list) {
size_ = frame.size_in_pixels();
support()->SubmitCompositorFrame(local_surface_id, std::move(frame),
std::move(hit_test_region_list));
Expand Down
4 changes: 2 additions & 2 deletions android_webview/browser/gfx/surfaces_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void SurfacesInstance::DrawAndSwap(gfx::Size viewport,
render_pass->CreateAndAppendDrawQuad<viz::SurfaceDrawQuad>();
surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_rect),
gfx::Rect(quad_state->quad_layer_rect),
viz::SurfaceRange(base::nullopt, child_id),
viz::SurfaceRange(absl::nullopt, child_id),
SK_ColorWHITE, /*stretch_content_to_fill_bounds=*/false);
surface_quad->allow_merge = !BackdropFiltersPreventMerge(child_id);

Expand Down Expand Up @@ -228,7 +228,7 @@ void SurfacesInstance::SetSolidColorRootFrame() {
viz::SharedQuadState* quad_state =
render_pass->CreateAndAppendSharedQuadState();
quad_state->SetAll(gfx::Transform(), rect, rect, gfx::MaskFilterInfo(),
base::nullopt, are_contents_opaque, 1.f,
absl::nullopt, are_contents_opaque, 1.f,
SkBlendMode::kSrcOver, 0);
viz::SolidColorDrawQuad* solid_quad =
render_pass->CreateAndAppendDrawQuad<viz::SolidColorDrawQuad>();
Expand Down
Loading

0 comments on commit 9c8495f

Please sign in to comment.