Migrate absl variant.h and utility.h in headless
Since https://crrev.com/c/6330348, some utils in third_party/abseil-cpp/absl/types/variant.h and and third_party/abseil-cpp/absl/utility/utility.h are only aliases for their std counterparts. This CL migrates code to use std:: directly. Bug: 40242126 Change-Id: I984f3312078a04090436b5237f2eb0d3a43fabbc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6343015 Reviewed-by: Eric Seckler <eseckler@chromium.org> Commit-Queue: Victor Vianna <victorvianna@google.com> Cr-Commit-Position: refs/heads/main@{#1430888}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d3d7f3f397
commit
79ddc65aba
headless/lib
@ -5,6 +5,7 @@
|
||||
#include "headless/lib/browser/protocol/headless_handler.h"
|
||||
|
||||
#include <memory>
|
||||
#include <variant>
|
||||
|
||||
#include "base/base_switches.h"
|
||||
#include "base/check_deref.h"
|
||||
@ -63,7 +64,7 @@ std::optional<std::vector<uint8_t>> EncodeBitmapAsWebp(int quality,
|
||||
return gfx::WebpCodec::Encode(bitmap, quality);
|
||||
}
|
||||
|
||||
absl::variant<protocol::Response, BitmapEncoder>
|
||||
std::variant<protocol::Response, BitmapEncoder>
|
||||
GetEncoder(const std::string& format, int quality, bool optimize_for_speed) {
|
||||
if (quality < 0 || quality > 100) {
|
||||
return Response::InvalidParams(
|
||||
@ -175,11 +176,11 @@ void HeadlessHandler::BeginFrame(std::optional<double> in_frame_time_ticks,
|
||||
GetEncoder(params.GetFormat(ScreenshotParams::FormatEnum::Png),
|
||||
params.GetQuality(kDefaultScreenshotQuality),
|
||||
params.GetOptimizeForSpeed(false));
|
||||
if (absl::holds_alternative<protocol::Response>(encoder_or_response)) {
|
||||
callback->sendFailure(absl::get<protocol::Response>(encoder_or_response));
|
||||
if (std::holds_alternative<protocol::Response>(encoder_or_response)) {
|
||||
callback->sendFailure(std::get<protocol::Response>(encoder_or_response));
|
||||
return;
|
||||
}
|
||||
encoder = absl::get<BitmapEncoder>(std::move(encoder_or_response));
|
||||
encoder = std::get<BitmapEncoder>(std::move(encoder_or_response));
|
||||
}
|
||||
|
||||
const bool capture_screenshot = !!encoder;
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "headless/lib/browser/protocol/page_handler.h"
|
||||
|
||||
#include <variant>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
|
||||
@ -58,20 +60,20 @@ void PageHandler::PrintToPDF(std::optional<bool> landscape,
|
||||
return;
|
||||
}
|
||||
|
||||
absl::variant<printing::mojom::PrintPagesParamsPtr, std::string>
|
||||
std::variant<printing::mojom::PrintPagesParamsPtr, std::string>
|
||||
print_pages_params = print_to_pdf::GetPrintPagesParams(
|
||||
web_contents_->GetPrimaryMainFrame()->GetLastCommittedURL(),
|
||||
landscape, display_header_footer, print_background, scale,
|
||||
paper_width, paper_height, margin_top, margin_bottom, margin_left,
|
||||
margin_right, header_template, footer_template, prefer_css_page_size,
|
||||
generate_tagged_pdf, generate_document_outline);
|
||||
if (absl::holds_alternative<std::string>(print_pages_params)) {
|
||||
if (std::holds_alternative<std::string>(print_pages_params)) {
|
||||
callback->sendFailure(
|
||||
Response::InvalidParams(absl::get<std::string>(print_pages_params)));
|
||||
Response::InvalidParams(std::get<std::string>(print_pages_params)));
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK(absl::holds_alternative<printing::mojom::PrintPagesParamsPtr>(
|
||||
DCHECK(std::holds_alternative<printing::mojom::PrintPagesParamsPtr>(
|
||||
print_pages_params));
|
||||
|
||||
bool return_as_stream = transfer_mode.value_or("") ==
|
||||
@ -79,7 +81,7 @@ void PageHandler::PrintToPDF(std::optional<bool> landscape,
|
||||
HeadlessPrintManager::FromWebContents(web_contents_.get())
|
||||
->PrintToPdf(
|
||||
web_contents_->GetPrimaryMainFrame(), page_ranges.value_or(""),
|
||||
std::move(absl::get<printing::mojom::PrintPagesParamsPtr>(
|
||||
std::move(std::get<printing::mojom::PrintPagesParamsPtr>(
|
||||
print_pages_params)),
|
||||
base::BindOnce(&PageHandler::PDFCreated, weak_factory_.GetWeakPtr(),
|
||||
return_as_stream, std::move(callback)));
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
#include "base/base_switches.h"
|
||||
#include "base/command_line.h"
|
||||
@ -44,7 +45,6 @@
|
||||
#include "headless/lib/utility/headless_content_utility_client.h"
|
||||
#include "headless/public/switches.h"
|
||||
#include "sandbox/policy/switches.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
#include "third_party/blink/public/common/switches.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/resource/resource_bundle.h"
|
||||
@ -82,7 +82,6 @@
|
||||
#if defined(HEADLESS_SUPPORT_FIELD_TRIALS)
|
||||
#include "content/public/app/initialize_mojo_core.h"
|
||||
#include "headless/lib/browser/headless_field_trials.h"
|
||||
#include "third_party/abseil-cpp/absl/types/variant.h"
|
||||
#endif
|
||||
|
||||
namespace headless {
|
||||
@ -442,7 +441,7 @@ void HeadlessContentMainDelegate::PreSandboxStartup() {
|
||||
InitApplicationLocale(command_line);
|
||||
}
|
||||
|
||||
absl::variant<int, content::MainFunctionParams>
|
||||
std::variant<int, content::MainFunctionParams>
|
||||
HeadlessContentMainDelegate::RunProcess(
|
||||
const std::string& process_type,
|
||||
content::MainFunctionParams main_function_params) {
|
||||
@ -559,8 +558,9 @@ HeadlessContentMainDelegate::CreateContentUtilityClient() {
|
||||
|
||||
std::optional<int> HeadlessContentMainDelegate::PostEarlyInitialization(
|
||||
InvokedIn invoked_in) {
|
||||
if (absl::holds_alternative<InvokedInChildProcess>(invoked_in))
|
||||
if (std::holds_alternative<InvokedInChildProcess>(invoked_in)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
#if defined(HEADLESS_USE_PREFS)
|
||||
browser_->CreatePrefService();
|
||||
@ -604,7 +604,7 @@ bool HeadlessContentMainDelegate::ShouldCreateFeatureList(
|
||||
InvokedIn invoked_in) {
|
||||
// The content layer is always responsible for creating the FeatureList in
|
||||
// child processes.
|
||||
if (absl::holds_alternative<InvokedInChildProcess>(invoked_in)) {
|
||||
if (std::holds_alternative<InvokedInChildProcess>(invoked_in)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/app/content_main_delegate.h"
|
||||
@ -42,7 +43,7 @@ class HEADLESS_EXPORT HeadlessContentMainDelegate
|
||||
// content::ContentMainDelegate implementation:
|
||||
std::optional<int> BasicStartupComplete() override;
|
||||
void PreSandboxStartup() override;
|
||||
absl::variant<int, content::MainFunctionParams> RunProcess(
|
||||
std::variant<int, content::MainFunctionParams> RunProcess(
|
||||
const std::string& process_type,
|
||||
content::MainFunctionParams main_function_params) override;
|
||||
std::optional<int> PreBrowserMain() override;
|
||||
|
Reference in New Issue
Block a user