0

Revert "Reland: Move windows prefetch code to //components/app_launch_prefetch"

This reverts commit 6e04f2a49c.

Reason for revert: crash on Windows
[0227/095220.580:FATAL:feature_list.cc(108)] Check failed: !feature. Accessed feature ExpandedPrefetchRange before FeatureList registration.

Original change's description:
> Reland: Move windows prefetch code to //components/app_launch_prefetch
>
> This relands crrev.com/c/5238168. It fixes the bug where the FeatureList
> was accessed from Crashpad before initialization during certain tests.
>
> This is to permit calling from chrome-agnostic locations including GPU
> and crashpad.
>
> Bug: 40946432, 325307453
> Fixed: 325473318
> Change-Id: I5861968256fb1e857423e3f92adfea195914ed7e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5317853
> Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
> Commit-Queue: Sean Maher <spvw@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1265282}

Bug: 40946432, 325307453
Change-Id: Id1ee64c03bde07490be29caa868d5b032a1aee7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5323354
Auto-Submit: Peng Huang <penghuang@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Peng Huang <penghuang@chromium.org>
Reviewed-by: Greg Thompson <grt@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1266672}
This commit is contained in:
Peng Huang
2024-02-28 22:15:20 +00:00
committed by Chromium LUCI CQ
parent 7508b0e0ac
commit acc30f7cf5
28 changed files with 230 additions and 272 deletions

@ -6074,7 +6074,6 @@ static_library("browser") {
"//chrome/notification_helper:constants",
"//chrome/services/util_win/public/mojom",
"//chrome/updater/app/server/win:updater_legacy_idl",
"//components/app_launch_prefetch",
"//components/crash/core/app",
"//components/crash/core/app:crash_export_thunk_include",
"//components/os_crypt/async/browser:dpapi_key_provider",

@ -39,10 +39,9 @@ include_rules = [
"+components/access_code_cast",
"+components/account_id",
"+components/account_manager_core",
"+components/affiliations",
"+components/allocation_recorder",
"+components/app_constants/constants.h",
"+components/app_launch_prefetch",
"+components/affiliations",
# TODO(b/129295708): Remove after move is complete.
"+components/arc",
"+components/app_restore",

@ -147,7 +147,6 @@
#if BUILDFLAG(IS_WIN)
#include "base/win/windows_version.h"
#include "chrome/browser/browser_features.h"
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "components/os_crypt/async/browser/dpapi_key_provider.h"
#elif BUILDFLAG(IS_MAC)
#include "chrome/browser/chrome_browser_main_mac.h"
@ -1571,8 +1570,7 @@ void BrowserProcessImpl::RestartBackgroundInstance() {
}
#if BUILDFLAG(IS_WIN)
new_cl->AppendArgNative(app_launch_prefetch::GetPrefetchSwitch(
app_launch_prefetch::SubprocessType::kBrowserBackground));
new_cl->AppendArg(switches::kPrefetchArgumentBrowserBackground);
#endif // BUILDFLAG(IS_WIN)
DLOG(WARNING) << "Shutting down current instance of the browser.";

@ -1341,7 +1341,6 @@ static_library("extensions") {
"system_display/display_info_provider_win.h",
]
deps += [
"//components/app_launch_prefetch",
"//components/device_signals/core/common/win",
"//third_party/iaccessible2",
"//third_party/isimpledom",

@ -36,7 +36,6 @@
#if BUILDFLAG(IS_WIN)
#include "chrome/common/pref_names.h"
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "components/prefs/pref_service.h"
#include "extensions/common/extension_features.h"
#include "ui/views/win/hwnd_util.h"
@ -279,9 +278,8 @@ void NativeProcessLauncherImpl::Core::DoLaunchOnThreadPool(
reconnect_command_line.AppendSwitchPath(::switches::kUserDataDir,
profile_directory_.DirName());
#if BUILDFLAG(IS_WIN)
reconnect_command_line.AppendArgNative(
app_launch_prefetch::GetPrefetchSwitch(
app_launch_prefetch::SubprocessType::kBrowserBackground));
reconnect_command_line.AppendArg(
::switches::kPrefetchArgumentBrowserBackground);
#endif
base::Value::List args;
for (const auto& arg : reconnect_command_line.argv()) {

@ -835,6 +835,10 @@ const char kNotificationInlineReply[] = "notification-inline-reply";
// has been activated. Should contain the launch ID encoded by Chrome.
const char kNotificationLaunchId[] = "notification-launch-id";
// /prefetch:# arguments for the browser process launched in background mode and
// as documented in prefetch_type_win.h.
const char kPrefetchArgumentBrowserBackground[] = "/prefetch:5";
// See kHideIcons.
const char kShowIcons[] = "show-icons";

@ -176,7 +176,6 @@ static_library("with_no_strings") {
"//base/win:pe_image",
"//build:branding_buildflags",
"//chrome/install_static:install_static_util",
"//components/app_launch_prefetch",
"//components/base32",
"//components/metrics:client_info",
"//components/version_info:channel",

@ -5,7 +5,6 @@ include_rules = [
"+chrome/install_static",
"+components/app_launch_prefetch",
"+components/base32",
"+components/metrics",
"+components/version_info/channel.h",

@ -19,7 +19,6 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/util_constants.h"
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "crypto/sha2.h"
namespace {
@ -60,8 +59,7 @@ void EnableBackgroundStartAtLogin() {
base::CommandLine cmd_line(application_dir.Append(installer::kChromeExe));
cmd_line.AppendSwitch(switches::kNoStartupWindow);
cmd_line.AppendArgNative(app_launch_prefetch::GetPrefetchSwitch(
app_launch_prefetch::SubprocessType::kBrowserBackground));
cmd_line.AppendArg(switches::kPrefetchArgumentBrowserBackground);
if (auto key_name = GetAutoLaunchKeyName(); !key_name.empty()) {
base::win::AddCommandToAutoRun(HKEY_CURRENT_USER, key_name,

@ -1,15 +0,0 @@
# Copyright 2024 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/features.gni")
component("app_launch_prefetch") {
assert(is_win, "//components/app_launch_prefetch only supported on Windows")
sources = [
"app_launch_prefetch.cc",
"app_launch_prefetch.h",
]
defines = [ "IS_APP_LAUNCH_PREFETCH_IMPL" ]
public_deps = [ "//base" ]
}

@ -1,2 +0,0 @@
etienneb@chromium.org
joel@microsoft.com

@ -1,165 +0,0 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/notreached.h"
#include "base/win/windows_version.h"
namespace {
// If enabled use the expanded range for the prefetch cmd line option.
BASE_FEATURE(kExpandedPrefetchRange,
"ExpandedPrefetchRange",
base::FEATURE_DISABLED_BY_DEFAULT);
// /prefetch:# arguments to use when launching various process types. It has
// been observed that when file reads are consistent for 3 process launches with
// the same /prefetch:# argument, the Windows prefetcher starts issuing reads in
// batch at process launch. Because reads depend on the process type, the
// prefetcher wouldn't be able to observe consistent reads if no /prefetch:#
// arguments were used. Note that the browser process has no /prefetch:#
// argument; as such all other processes must have one in order to avoid
// polluting its profile.
// On Windows versions before Win11 21H2 the value must always be in [1, 8];
// otherwise it is treated as 0 by the Windows prefetcher and will interfere
// with the main process launch.
constexpr base::CommandLine::StringPieceType kPrefetchArgument1 =
L"/prefetch:1";
constexpr base::CommandLine::StringPieceType kPrefetchArgument2 =
L"/prefetch:2";
constexpr base::CommandLine::StringPieceType kPrefetchArgument3 =
L"/prefetch:3";
constexpr base::CommandLine::StringPieceType kPrefetchArgument4 =
L"/prefetch:4";
// /prefetch:5, /prefetch:6 and /prefetch:7 are reserved for content embedders
// and are not to be used by content itself, with caveats: we violate this rule
// with kBrowserBackground using bucket 5, while the 7th bucket is used by the
// crashpad fallback handler. Note that /prefetch:7 is hardcoded by the crashpad
// fallback handler, because it can be launched before FeatureList
// initialization.
constexpr base::CommandLine::StringPieceType kPrefetchArgument5 =
L"/prefetch:5";
// constexpr base::CommandLine::StringPieceType kPrefetchArgument6 =
// "/prefetch:6";
constexpr base::CommandLine::StringPieceType kPrefetchArgument7 =
L"/prefetch:7";
// Catch all for Windows versions before Win 11 21H2.
constexpr base::CommandLine::StringPieceType kPrefetchArgument8 =
L"/prefetch:8";
// On Windows 11 21H2 and later the prefetch range was expanded to be [1,16]
constexpr base::CommandLine::StringPieceType kPrefetchArgument9 =
L"/prefetch:9";
constexpr base::CommandLine::StringPieceType kPrefetchArgument10 =
L"/prefetch:10";
constexpr base::CommandLine::StringPieceType kPrefetchArgument11 =
L"/prefetch:11";
constexpr base::CommandLine::StringPieceType kPrefetchArgument12 =
L"/prefetch:12";
constexpr base::CommandLine::StringPieceType kPrefetchArgument13 =
L"/prefetch:13";
constexpr base::CommandLine::StringPieceType kPrefetchArgument14 =
L"/prefetch:14";
// constexpr base::CommandLine::StringPieceType kPrefetchArgument15 =
// "/prefetch:15";
// Catch all for Windows versions Win 11 21H2 and later.
constexpr base::CommandLine::StringPieceType kPrefetchArgument16 =
L"/prefetch:16";
} // namespace
namespace app_launch_prefetch {
base::CommandLine::StringPieceType GetPrefetchSwitch(SubprocessType type) {
using enum SubprocessType;
if (base::win::GetVersion() >= base::win::Version::WIN11 &&
base::FeatureList::IsEnabled(kExpandedPrefetchRange)) {
// These are the prefetch arguments used on Windows versions
// for Win11 and later. There are fewer processes using the same
// values and this should lead to better App Launch PreFetch (ALPF)
// behavior.
// kPrefetchArgument8 and kPrefetchArgument15 are currently unused.
switch (type) {
case kBrowser:
NOTREACHED_NORETURN();
case kRenderer:
return kPrefetchArgument1;
case kGPU:
return kPrefetchArgument2;
case kPpapi:
return kPrefetchArgument3;
case kCrashpad:
return kPrefetchArgument4;
case kBrowserBackground:
return kPrefetchArgument5;
case kCrashpadFallback:
return kPrefetchArgument7;
case kExtension:
return kPrefetchArgument9;
case kGPUInfo:
return kPrefetchArgument10;
case kUtilityNetworkService:
return kPrefetchArgument11;
case kUtilityAudio:
return kPrefetchArgument12;
case kUtilityStorage:
return kPrefetchArgument13;
case kUtilityOther:
return kPrefetchArgument14;
case kCatchAll:
return kPrefetchArgument16;
}
} else {
// These are the prefetch arguments used on Windows versions
// before Win11 21H2. There are multiple processes using the same values
// and this leads to less than optimal App Launch PreFetch (ALPF) behavior.
// /prefetch:5, /prefetch:6 and /prefetch:7 are reserved for content
// embedders and are not to be used by content itself, with caveats: we
// violate this rule with kBrowserBackground using bucket 5, while the 7th
// bucket is used by the crashpad fallback handler.
switch (type) {
case kBrowser:
NOTREACHED_NORETURN();
case kRenderer:
return kPrefetchArgument1;
case kGPU:
return kPrefetchArgument2;
case kExtension:
return kPrefetchArgument2;
case kPpapi:
return kPrefetchArgument3;
case kUtilityNetworkService:
return kPrefetchArgument3;
case kCrashpad:
return kPrefetchArgument4;
case kBrowserBackground:
return kPrefetchArgument5;
case kCrashpadFallback:
return kPrefetchArgument7;
case kCatchAll:
return kPrefetchArgument8;
case kGPUInfo:
return kPrefetchArgument8;
case kUtilityAudio:
return kPrefetchArgument8;
case kUtilityStorage:
return kPrefetchArgument8;
case kUtilityOther:
return kPrefetchArgument8;
}
}
}
} // namespace app_launch_prefetch

@ -1,42 +0,0 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_APP_LAUNCH_PREFETCH_APP_LAUNCH_PREFETCH_H_
#define COMPONENTS_APP_LAUNCH_PREFETCH_APP_LAUNCH_PREFETCH_H_
#include "base/command_line.h"
#include "base/component_export.h"
namespace app_launch_prefetch {
// These are the App Launch PreFetch (ALPF) splits we do based on process
// type and subtype to differentiate file and offset usage within the files
// accessed by the different variations of the browser processes with the
// same process name.
enum class SubprocessType {
kBrowser,
kBrowserBackground,
kCatchAll,
kCrashpad,
kCrashpadFallback,
kExtension,
kGPU,
kGPUInfo,
kPpapi,
kRenderer,
kUtilityAudio,
kUtilityNetworkService,
kUtilityStorage,
kUtilityOther
};
// Returns an argument to be added to a command line when launching a process to
// direct the Windows prefetcher to use the profile indicated by
// `prefetch_type`.
COMPONENT_EXPORT(APP_LAUNCH_PREFETCH)
base::CommandLine::StringPieceType GetPrefetchSwitch(SubprocessType type);
} // namespace app_launch_prefetch
#endif // COMPONENTS_APP_LAUNCH_PREFETCH_APP_LAUNCH_PREFETCH_H_

@ -137,7 +137,6 @@ static_library("app") {
]
deps += [
"//components/app_launch_prefetch",
"//third_party/crashpad/crashpad/client",
"//third_party/crashpad/crashpad/handler",
"//third_party/crashpad/crashpad/minidump",

@ -2,7 +2,6 @@ include_rules = [
"+sandbox",
"+third_party/breakpad",
"+components/allocation_recorder/crash_handler",
"+components/app_launch_prefetch",
"+components/crash/android/jni_headers",
"+components/gwp_asan/buildflags/buildflags.h",
"+components/gwp_asan/crash_handler/crash_handler.h",

@ -18,7 +18,6 @@
#include "base/win/windows_version.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "components/crash/core/app/crash_export_thunks.h"
#include "components/crash/core/app/crash_reporter_client.h"
#include "components/crash/core/app/crash_switches.h"
@ -119,9 +118,10 @@ bool PlatformCrashpadInitialization(
start_arguments.push_back(std::string("--user-data-dir=") +
user_data_dir);
}
start_arguments.push_back(
base::WideToUTF8(app_launch_prefetch::GetPrefetchSwitch(
app_launch_prefetch::SubprocessType::kCrashpad)));
// The prefetch argument added here has to be documented in
// prefetch_type_win.h. A constant can't be used here because crashpad
// can't depend on Chrome.
start_arguments.push_back("/prefetch:4");
} else {
base::FilePath exe_dir = exe_file.DirName();
exe_file = exe_dir.Append(FILE_PATH_LITERAL("crashpad_handler.exe"));

@ -24,7 +24,6 @@ include_rules = [
# as autofill or extensions, and chrome implementation details such as
# settings, packaging details, installation or crash reporting.
"+components/app_launch_prefetch",
"+components/attribution_reporting",
"+components/browsing_topics/common",
"+components/memory_pressure",

@ -2814,7 +2814,6 @@ source_set("browser") {
"__ATLHOST_H__",
]
deps += [
"//components/app_launch_prefetch",
"//content/utility:delegate_data",
"//services/screen_ai/public/cpp:utilities",
"//third_party/blink/public/common:font_unique_name_table_proto",

@ -36,6 +36,7 @@
#if BUILDFLAG(IS_WIN)
#include "base/win/windows_types.h"
#include "content/public/common/prefetch_type_win.h"
#include "sandbox/win/src/sandbox_types.h"
#else
#include "content/public/browser/posix_file_descriptor_info.h"
@ -145,6 +146,12 @@ class ChildProcessLauncherHelper
// Platform specific.
std::unique_ptr<FileMappedForLaunch> GetFilesToMap();
#if BUILDFLAG(IS_WIN)
// Returns the Prefetch string for the process type on the OS in use.
static std::string_view GetPrefetchSwitch(
const AppLaunchPrefetchType prefetch_type);
#endif
// Returns true if the process will be launched using base::LaunchOptions.
// If false, all of the base::LaunchOptions* below will be nullptr.
// Platform specific.

@ -2,16 +2,74 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/child_process_launcher_helper.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/process/process.h"
#include "base/strings/string_number_conversions.h"
#include "base/win/scoped_handle.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "content/browser/child_process_launcher.h"
#include "content/browser/child_process_launcher_helper.h"
#include "content/public/browser/child_process_launcher_utils.h"
#include "content/public/common/content_features.h"
#include "content/public/common/result_codes.h"
#include "content/public/common/sandbox_init_win.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "mojo/public/cpp/platform/named_platform_channel.h"
#include "mojo/public/cpp/platform/platform_channel.h"
#include "sandbox/policy/win/sandbox_win.h"
#include "sandbox/win/src/sandbox_types.h"
namespace {
// /prefetch:# arguments to use when launching various process types. It has
// been observed that when file reads are consistent for 3 process launches with
// the same /prefetch:# argument, the Windows prefetcher starts issuing reads in
// batch at process launch. Because reads depend on the process type, the
// prefetcher wouldn't be able to observe consistent reads if no /prefetch:#
// arguments were used. Note that the browser process has no /prefetch:#
// argument; as such all other processes must have one in order to avoid
// polluting its profile.
// On Windows versions before Win11 21H2 the value must always be in [1, 8];
// otherwise it is treated as 0 by the Windows prefetcher and will interfere
// with the main process launch.
constexpr std::string_view kPrefetchArgument1 = "/prefetch:1";
constexpr std::string_view kPrefetchArgument2 = "/prefetch:2";
constexpr std::string_view kPrefetchArgument3 = "/prefetch:3";
constexpr std::string_view kPrefetchArgument4 = "/prefetch:4";
// /prefetch:5, /prefetch:6 and /prefetch:7 are reserved for content embedders
// and are not to be used by content itself. There are two exceptions to this
// rule.
//
// We violate this rule with kBrowserBackground using 5 defined by
// kPrefetchArgumentBrowserBackground in chrome/common/chrome_switches.cc.
constexpr std::string_view kPrefetchArgument5 = "/prefetch:5";
// constexpr std::string_view kPrefetchArgument6 = "/prefetch:6";
// constexpr std::string_view kPrefetchArgument7 = "/prefetch:7";
// Catch all for Windows versions before Win 11 21H2
constexpr std::string_view kPrefetchArgument8 = "/prefetch:8";
// On Windows 11 21H2 and later the prefetch range was expanded to be [1,16]
constexpr std::string_view kPrefetchArgument9 = "/prefetch:9";
constexpr std::string_view kPrefetchArgument10 = "/prefetch:10";
constexpr std::string_view kPrefetchArgument11 = "/prefetch:11";
constexpr std::string_view kPrefetchArgument12 = "/prefetch:12";
constexpr std::string_view kPrefetchArgument13 = "/prefetch:13";
constexpr std::string_view kPrefetchArgument14 = "/prefetch:14";
// constexpr std::string_view kPrefetchArgument15 = "/prefetch:15";
// Catch all for Windows versions Win 11 21H2 and later
constexpr std::string_view kPrefetchArgument16 = "/prefetch:16";
} // namespace
namespace content {
namespace internal {
@ -38,6 +96,86 @@ ChildProcessLauncherHelper::GetFilesToMap() {
return nullptr;
}
// static
std::string_view ChildProcessLauncherHelper::GetPrefetchSwitch(
const AppLaunchPrefetchType prefetch_type) {
if (base::win::GetVersion() >= base::win::Version::WIN11 &&
base::FeatureList::IsEnabled(features::kExpandedPrefetchRange)) {
// These are the prefetch arguments used on Windows versions
// for Win11 and later. There are fewer processes using the same
// values and this should lead to better App Launch PreFetch (ALPF)
// behavior.
// kPrefetchArgument8 and kPrefetchArgument15 are currently unused.
switch (prefetch_type) {
case AppLaunchPrefetchType::kBrowser:
NOTREACHED_NORETURN();
case AppLaunchPrefetchType::kRenderer:
return kPrefetchArgument1;
case AppLaunchPrefetchType::kGPU:
return kPrefetchArgument2;
case AppLaunchPrefetchType::kPpapi:
return kPrefetchArgument3;
case AppLaunchPrefetchType::kCrashpad:
return kPrefetchArgument4;
case AppLaunchPrefetchType::kBrowserBackground:
return kPrefetchArgument5;
case AppLaunchPrefetchType::kExtension:
return kPrefetchArgument9;
case AppLaunchPrefetchType::kGPUInfo:
return kPrefetchArgument10;
case AppLaunchPrefetchType::kUtilityNetworkService:
return kPrefetchArgument11;
case AppLaunchPrefetchType::kUtilityAudio:
return kPrefetchArgument12;
case AppLaunchPrefetchType::kUtilityStorage:
return kPrefetchArgument13;
case AppLaunchPrefetchType::kUtilityOther:
return kPrefetchArgument14;
case AppLaunchPrefetchType::kCatchAll:
return kPrefetchArgument16;
}
} else {
// These are the prefetch arguments used on Windows versions
// before Win11 21H2. There are multiple processes using the same values
// and this leads to less than optimal App Launch PreFetch (ALPF) behavior.
// /prefetch:5, /prefetch:6 and /prefetch:7 are reserved for content
// embedders and are not to be used by content itself. We violate this
// rule with kBrowserBackground using 5 defined by
// kPrefetchArgumentBrowserBackground in chrome/common/chrome_switches.cc.
switch (prefetch_type) {
case AppLaunchPrefetchType::kBrowser:
NOTREACHED_NORETURN();
case AppLaunchPrefetchType::kRenderer:
return kPrefetchArgument1;
case AppLaunchPrefetchType::kGPU:
return kPrefetchArgument2;
case AppLaunchPrefetchType::kExtension:
return kPrefetchArgument2;
case AppLaunchPrefetchType::kPpapi:
return kPrefetchArgument3;
case AppLaunchPrefetchType::kUtilityNetworkService:
return kPrefetchArgument3;
case AppLaunchPrefetchType::kCrashpad:
return kPrefetchArgument4;
case AppLaunchPrefetchType::kBrowserBackground:
return kPrefetchArgument5;
case AppLaunchPrefetchType::kCatchAll:
return kPrefetchArgument8;
case AppLaunchPrefetchType::kGPUInfo:
return kPrefetchArgument8;
case AppLaunchPrefetchType::kUtilityAudio:
return kPrefetchArgument8;
case AppLaunchPrefetchType::kUtilityStorage:
return kPrefetchArgument8;
case AppLaunchPrefetchType::kUtilityOther:
return kPrefetchArgument8;
}
}
}
bool ChildProcessLauncherHelper::IsUsingLaunchOptions() {
return true;
}

@ -101,7 +101,8 @@
#include "base/win/access_token.h"
#include "base/win/security_descriptor.h"
#include "base/win/win_util.h"
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "content/browser/child_process_launcher_helper.h"
#include "content/public/common/prefetch_type_win.h"
#include "sandbox/policy/win/sandbox_win.h"
#include "sandbox/win/src/sandbox_policy.h"
#include "sandbox/win/src/window.h"
@ -1294,11 +1295,11 @@ bool GpuProcessHost::LaunchGpuProcess() {
if (kind_ == GPU_PROCESS_KIND_INFO_COLLECTION &&
base::FeatureList::IsEnabled(
features::kGpuInfoCollectionSeparatePrefetch)) {
cmd_line->AppendArgNative(app_launch_prefetch::GetPrefetchSwitch(
app_launch_prefetch::SubprocessType::kGPUInfo));
cmd_line->AppendArg(internal::ChildProcessLauncherHelper::GetPrefetchSwitch(
AppLaunchPrefetchType::kGPUInfo));
} else {
cmd_line->AppendArgNative(app_launch_prefetch::GetPrefetchSwitch(
app_launch_prefetch::SubprocessType::kGPU));
cmd_line->AppendArg(internal::ChildProcessLauncherHelper::GetPrefetchSwitch(
AppLaunchPrefetchType::kGPU));
}
#endif // BUILDFLAG(IS_WIN)

@ -17,7 +17,6 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "content/browser/browser_child_process_host_impl.h"
#include "content/browser/child_process_host_impl.h"
#include "content/browser/plugin_service_impl.h"
@ -236,8 +235,8 @@ bool PpapiPluginProcessHost::Init(const ContentPluginInfo& info) {
BrowserChildProcessHostImpl::CopyTraceStartupFlags(cmd_line.get());
#if BUILDFLAG(IS_WIN)
cmd_line->AppendArgNative(
app_launch_prefetch::GetPrefetchSwitch(SubprocessType::kPpapi));
cmd_line->AppendArg(internal::ChildProcessLauncherHelper::GetPrefetchSwitch(
AppLaunchPrefetchType::kPpapi));
#endif // BUILDFLAG(IS_WIN)
// These switches are forwarded to plugin pocesses.

@ -261,10 +261,11 @@
#if BUILDFLAG(IS_WIN)
#include "base/win/scoped_com_initializer.h"
#include "base/win/windows_version.h"
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "content/browser/child_process_launcher_helper.h"
#include "content/browser/renderer_host/dwrite_font_proxy_impl_win.h"
#include "content/public/common/font_cache_dispatcher_win.h"
#include "content/public/common/font_cache_win.mojom.h"
#include "content/public/common/prefetch_type_win.h"
#include "ui/display/win/dpi.h"
#endif
@ -3289,11 +3290,13 @@ void RenderProcessHostImpl::AppendRendererCommandLine(
#if BUILDFLAG(IS_WIN)
if (command_line->HasSwitch(kExtensionProcess)) {
command_line->AppendArgNative(app_launch_prefetch::GetPrefetchSwitch(
app_launch_prefetch::SubprocessType::kExtension));
command_line->AppendArg(
internal::ChildProcessLauncherHelper::GetPrefetchSwitch(
AppLaunchPrefetchType::kExtension));
} else {
command_line->AppendArgNative(app_launch_prefetch::GetPrefetchSwitch(
app_launch_prefetch::SubprocessType::kRenderer));
command_line->AppendArg(
internal::ChildProcessLauncherHelper::GetPrefetchSwitch(
AppLaunchPrefetchType::kRenderer));
}
#endif // BUILDFLAG(IS_WIN)

@ -68,7 +68,8 @@
#endif
#if BUILDFLAG(IS_WIN)
#include "components/app_launch_prefetch/app_launch_prefetch.h"
#include "content/browser/child_process_launcher_helper.h"
#include "content/public/common/prefetch_type_win.h"
#include "media/capture/capture_switches.h"
#include "services/audio/public/mojom/audio_service.mojom.h"
#include "services/network/public/mojom/network_service.mojom.h"
@ -111,20 +112,19 @@ base::ScopedFD PassNetworkContextParentDirs(
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#if BUILDFLAG(IS_WIN)
base::CommandLine::StringPieceType UtilityToAppLaunchPrefetchArg(
std::string_view UtilityToAppLaunchPrefetchArg(
const std::string& utility_type) {
// Set the default prefetch type for utility processes.
app_launch_prefetch::SubprocessType prefetch_type =
app_launch_prefetch::SubprocessType::kUtilityOther;
AppLaunchPrefetchType prefetch_type = AppLaunchPrefetchType::kUtilityOther;
if (utility_type == network::mojom::NetworkService::Name_) {
prefetch_type = app_launch_prefetch::SubprocessType::kUtilityNetworkService;
prefetch_type = AppLaunchPrefetchType::kUtilityNetworkService;
} else if (utility_type == storage::mojom::StorageService::Name_) {
prefetch_type = app_launch_prefetch::SubprocessType::kUtilityStorage;
prefetch_type = AppLaunchPrefetchType::kUtilityStorage;
} else if (utility_type == audio::mojom::AudioService::Name_) {
prefetch_type = app_launch_prefetch::SubprocessType::kUtilityAudio;
prefetch_type = AppLaunchPrefetchType::kUtilityAudio;
}
return app_launch_prefetch::GetPrefetchSwitch(prefetch_type);
return internal::ChildProcessLauncherHelper::GetPrefetchSwitch(prefetch_type);
}
#endif // BUILDFLAG(IS_WIN)
@ -319,7 +319,7 @@ bool UtilityProcessHost::StartProcess() {
cmd_line->AppendSwitchASCII(switches::kLang, locale);
#if BUILDFLAG(IS_WIN)
cmd_line->AppendArgNative(UtilityToAppLaunchPrefetchArg(metrics_name_));
cmd_line->AppendArg(UtilityToAppLaunchPrefetchArg(metrics_name_));
#endif // BUILDFLAG(IS_WIN)
sandbox::policy::SetCommandLineFlagsForSandboxType(cmd_line.get(),

@ -220,6 +220,7 @@ source_set("common_sources") {
if (is_win) {
sources += [
"font_cache_dispatcher_win.h",
"prefetch_type_win.h",
"sandbox_init_win.h",
]
}

@ -361,6 +361,14 @@ BASE_FEATURE(kEnableServiceWorkersForChromeScheme,
"EnableServiceWorkersForChromeScheme",
base::FEATURE_DISABLED_BY_DEFAULT);
#if BUILDFLAG(IS_WIN)
// If enabled use the expanded range for the prefetch cmd line option.
BASE_FEATURE(kExpandedPrefetchRange,
"ExpandedPrefetchRange",
base::FEATURE_DISABLED_BY_DEFAULT);
#endif // BUILDFLAG(IS_WIN)
// Enables JavaScript API to intermediate federated identity requests.
// Note that actual exposure of the FedCM API to web content is controlled
// by the flag in RuntimeEnabledFeatures on the blink side. See also

@ -89,6 +89,9 @@ CONTENT_EXPORT BASE_DECLARE_FEATURE(
kEnableMachineLearningModelLoaderWebPlatformApi);
CONTENT_EXPORT BASE_DECLARE_FEATURE(kEnableServiceWorkersForChromeScheme);
CONTENT_EXPORT BASE_DECLARE_FEATURE(kEnableServiceWorkersForChromeUntrusted);
#if BUILDFLAG(IS_WIN)
CONTENT_EXPORT BASE_DECLARE_FEATURE(kExpandedPrefetchRange);
#endif
CONTENT_EXPORT BASE_DECLARE_FEATURE(kFedCm);
CONTENT_EXPORT BASE_DECLARE_FEATURE(kFedCmAuthz);
CONTENT_EXPORT BASE_DECLARE_FEATURE(kFedCmAutoSelectedFlag);

@ -0,0 +1,33 @@
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_COMMON_PREFETCH_TYPE_WIN_H_
#define CONTENT_PUBLIC_COMMON_PREFETCH_TYPE_WIN_H_
namespace content {
// These are the App Launch PreFetch (ALPF) splits we do based on process
// type and subtype to differentiate file and offset usage within the files
// accessed by the different variations of the browser processes with the
// same process name.
enum class AppLaunchPrefetchType {
kBrowser,
kBrowserBackground,
kCatchAll,
kCrashpad,
kExtension,
kGPU,
kGPUInfo,
kPpapi,
kRenderer,
kUtilityAudio,
kUtilityNetworkService,
kUtilityStorage,
kUtilityOther
};
} // namespace content
#endif // CONTENT_PUBLIC_COMMON_PREFETCH_TYPE_WIN_H_