Remove libcef/features/runtime.h (see #3685)

Use BUILDFLAG(ENABLE_CEF) exclusively in patch files.
This commit is contained in:
Marshall Greenblatt
2024-07-05 13:07:07 -04:00
parent 0d166c3c90
commit 60ce575e53
8 changed files with 75 additions and 118 deletions

View File

@ -1,26 +1,32 @@
diff --git chrome/app/chrome_main_delegate.cc chrome/app/chrome_main_delegate.cc
index 2805028bc810c..53154db3326f7 100644
index 2805028bc810c..0aef6f992262e 100644
--- chrome/app/chrome_main_delegate.cc
+++ chrome/app/chrome_main_delegate.cc
@@ -37,6 +37,7 @@
#include "base/trace_event/trace_event_impl.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/runtime.h"
+#include "cef/libcef/features/features.h"
#include "chrome/browser/buildflags.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/browser/chrome_resource_bundle_helper.h"
@@ -610,6 +611,9 @@ struct MainFunction {
@@ -608,6 +609,7 @@ struct MainFunction {
int (*function)(content::MainFunctionParams);
};
+#if !BUILDFLAG(ENABLE_CEF)
// Initializes the user data dir. Must be called before InitializeLocalState().
void InitializeUserDataDir(base::CommandLine* command_line) {
+ if (cef::IsChromeRuntimeEnabled()) {
+ return;
+ }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// In debug builds of Lacros, we keep track of when the user data dir
// is initialized, to ensure the cryptohome is not accessed before login
@@ -847,6 +851,10 @@ ChromeMainDelegate::~ChromeMainDelegate() {
@@ -691,6 +693,7 @@ void InitializeUserDataDir(base::CommandLine* command_line) {
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
#endif // BUILDFLAG(IS_WIN)
}
+#endif // !BUILDFLAG(ENABLE_CEF)
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// If Lacros was prelaunched at login screen, this method blocks waiting
@@ -847,6 +850,10 @@ ChromeMainDelegate::~ChromeMainDelegate() {
ChromeMainDelegate::~ChromeMainDelegate() = default;
#endif // !BUILDFLAG(IS_ANDROID)
@ -31,7 +37,7 @@ index 2805028bc810c..53154db3326f7 100644
std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
InvokedIn invoked_in) {
DUMP_WILL_BE_CHECK(base::ThreadPoolInstance::Get());
@@ -872,7 +880,7 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
@@ -872,7 +879,7 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
// future session's metrics.
DeferBrowserMetrics(user_data_dir);
@ -40,7 +46,7 @@ index 2805028bc810c..53154db3326f7 100644
// In the case the process is not the singleton process, the uninstall tasks
// need to be executed here. A window will be displayed asking to close all
// running instances.
@@ -1040,7 +1048,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
@@ -1040,7 +1047,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
// Initializes the resource bundle and determines the locale.
std::string actual_locale = LoadLocalState(
@ -50,37 +56,56 @@ index 2805028bc810c..53154db3326f7 100644
chrome_feature_list_creator->SetApplicationLocale(actual_locale);
chrome_feature_list_creator->OverrideCachedUIStrings();
@@ -1059,7 +1068,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
@@ -1057,6 +1065,8 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
new net::NetworkChangeNotifierFactoryAndroid());
#endif
+#if !BUILDFLAG(ENABLE_CEF)
+ // Avoid CEF crash with multi-threaded-message-loop.
if (base::FeatureList::IsEnabled(
features::kWriteBasicSystemProfileToPersistentHistogramsFile)) {
- bool record = true;
+ // Avoid CEF crash with multi-threaded-message-loop.
+ bool record = !cef::IsChromeRuntimeEnabled();
bool record = true;
@@ -1067,6 +1077,7 @@ std::optional<int> ChromeMainDelegate::PostEarlyInitialization(
if (record)
chrome_content_browser_client_->startup_data()->RecordCoreSystemProfile();
}
+#endif // !BUILDFLAG(ENABLE_CEF)
#if BUILDFLAG(IS_ANDROID)
record =
base::FeatureList::IsEnabled(chrome::android::kUmaBackgroundSessions);
@@ -1506,9 +1516,10 @@ void ChromeMainDelegate::PreSandboxStartup() {
UmaSessionStats::OnStartup();
@@ -1506,6 +1517,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
+ if (!cef::IsChromeRuntimeEnabled()) {
+#if !BUILDFLAG(ENABLE_CEF)
crash_reporter::InitializeCrashKeys();
-#if BUILDFLAG(IS_POSIX)
+#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(ENABLE_CEF)
ChromeCrashReporterClient::Create();
#endif
@@ -1516,6 +1527,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
#if BUILDFLAG(IS_POSIX)
@@ -1516,6 +1528,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
InitMacCrashReporter(command_line, process_type);
SetUpInstallerPreferences(command_line);
#endif
+ } // !cef::IsChromeRuntimeEnabled()
+#endif // !BUILDFLAG(ENABLE_CEF)
#if BUILDFLAG(IS_WIN)
child_process_logging::Init();
@@ -1696,7 +1708,8 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1527,6 +1540,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
base::CPU cpu_info;
#endif
+#if !BUILDFLAG(ENABLE_CEF)
// Initialize the user data dir for any process type that needs it.
bool initialize_user_data_dir = chrome::ProcessNeedsProfileDir(process_type);
#if BUILDFLAG(IS_CHROMEOS_LACROS)
@@ -1538,6 +1552,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
if (initialize_user_data_dir) {
InitializeUserDataDir(base::CommandLine::ForCurrentProcess());
}
+#endif // !BUILDFLAG(ENABLE_CEF)
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// Generate shared resource file only on browser process. This is to avoid
@@ -1696,7 +1711,8 @@ void ChromeMainDelegate::PreSandboxStartup() {
#else
const std::string loaded_locale =
ui::ResourceBundle::InitSharedInstanceWithLocale(
@ -90,39 +115,39 @@ index 2805028bc810c..53154db3326f7 100644
base::FilePath resources_pack_path;
base::PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
@@ -1726,6 +1739,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1726,6 +1742,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale;
}
+ if (!cef::IsChromeRuntimeEnabled()) {
+#if !BUILDFLAG(ENABLE_CEF)
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
// Zygote needs to call InitCrashReporter() in RunZygote().
if (process_type != switches::kZygoteProcess) {
@@ -1761,6 +1775,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
@@ -1761,6 +1778,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
// After all the platform Breakpads have been initialized, store the command
// line for crash reporting.
crash_keys::SetCrashKeysFromCommandLine(command_line);
+ } // !cef::IsChromeRuntimeEnabled()
+#endif // !BUILDFLAG(ENABLE_CEF)
#if BUILDFLAG(ENABLE_PDF)
MaybePatchGdiGetFontData();
@@ -1888,6 +1903,7 @@ void ChromeMainDelegate::ZygoteForked() {
@@ -1888,6 +1906,7 @@ void ChromeMainDelegate::ZygoteForked() {
SetUpProfilingShutdownHandler();
}
+ if (!cef::IsChromeRuntimeEnabled()) {
+#if !BUILDFLAG(ENABLE_CEF)
// Needs to be called after we have chrome::DIR_USER_DATA. BrowserMain sets
// this up for the browser process in a different manner.
const base::CommandLine* command_line =
@@ -1900,6 +1916,7 @@ void ChromeMainDelegate::ZygoteForked() {
@@ -1900,6 +1919,7 @@ void ChromeMainDelegate::ZygoteForked() {
// Reset the command line for the newly spawned process.
crash_keys::SetCrashKeysFromCommandLine(*command_line);
+ } // !cef::IsChromeRuntimeEnabled()
+#endif // !BUILDFLAG(ENABLE_CEF)
}
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
@@ -2002,6 +2019,7 @@ void ChromeMainDelegate::InitializeMemorySystem() {
@@ -2002,6 +2022,7 @@ void ChromeMainDelegate::InitializeMemorySystem() {
: memory_system::DispatcherParameters::
AllocationTraceRecorderInclusion::kIgnore;
@ -130,7 +155,7 @@ index 2805028bc810c..53154db3326f7 100644
memory_system::Initializer()
.SetGwpAsanParameters(gwp_asan_boost_sampling, process_type)
.SetProfilingClientParameters(chrome::GetChannel(),
@@ -2009,5 +2027,5 @@ void ChromeMainDelegate::InitializeMemorySystem() {
@@ -2009,5 +2030,5 @@ void ChromeMainDelegate::InitializeMemorySystem() {
.SetDispatcherParameters(memory_system::DispatcherParameters::
PoissonAllocationSamplerInclusion::kEnforce,
allocation_recorder_inclusion, process_type)
@ -212,14 +237,14 @@ index ac1361bd6bc2e..a303ca169c7f7 100644
base::PathService::OverrideAndCreateIfNeeded(
diff --git chrome/browser/chrome_browser_main.cc chrome/browser/chrome_browser_main.cc
index f90f1b8fa54d9..3c1406cc798a7 100644
index f90f1b8fa54d9..22fac24f015e1 100644
--- chrome/browser/chrome_browser_main.cc
+++ chrome/browser/chrome_browser_main.cc
@@ -52,6 +52,7 @@
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "cc/base/switches.h"
+#include "cef/libcef/features/runtime.h"
+#include "cef/libcef/features/features.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/active_use_util.h"
#include "chrome/browser/after_startup_task_utils.h"