Cleanup features for COM initialization in utility processes.
The features have been enabled by default for a while and are ready to be cleaned up. Fixed: 348014083 Change-Id: I53c4b42541aadd525ffb547bc8cd023689f87402 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6369016 Auto-Submit: Francois Pierre Doray <fdoray@chromium.org> Commit-Queue: Francois Pierre Doray <fdoray@chromium.org> Reviewed-by: Patrick Monette <pmonette@chromium.org> Reviewed-by: Nasko Oskov <nasko@chromium.org> Cr-Commit-Position: refs/heads/main@{#1435124}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
526d27325d
commit
f768ec31e7
chrome
browser
common
services
util_win
content
@ -4,7 +4,6 @@
|
||||
|
||||
#include "chrome/browser/win/util_win_service.h"
|
||||
|
||||
#include "chrome/common/chrome_features.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "chrome/services/util_win/public/mojom/util_win.mojom.h"
|
||||
#include "content/public/browser/service_process_host.h"
|
||||
@ -13,9 +12,7 @@
|
||||
mojo::Remote<chrome::mojom::UtilWin> LaunchUtilWinServiceInstance() {
|
||||
content::ServiceProcessHost::Options options;
|
||||
options.WithDisplayName(IDS_UTILITY_PROCESS_UTILITY_WIN_NAME);
|
||||
if (base::FeatureList::IsEnabled(features::kUtilWinProcessUsesUiPump)) {
|
||||
options.WithExtraCommandLineSwitches({switches::kMessageLoopTypeUi});
|
||||
}
|
||||
options.WithExtraCommandLineSwitches({switches::kMessageLoopTypeUi});
|
||||
|
||||
// Runs with kNoSandbox from sandbox.mojom.Sandbox.
|
||||
return content::ServiceProcessHost::Launch<chrome::mojom::UtilWin>(
|
||||
|
@ -1579,11 +1579,6 @@ BASE_FEATURE(kUmaStorageDimensions,
|
||||
BASE_FEATURE(kWin10AcceleratedDefaultBrowserFlow,
|
||||
"Win10AcceleratedDefaultBrowserFlow",
|
||||
base::FEATURE_ENABLED_BY_DEFAULT);
|
||||
|
||||
// When enabled, a UI pump is requested for the UtilWin utility process.
|
||||
BASE_FEATURE(kUtilWinProcessUsesUiPump,
|
||||
"UtilWinProcessUsesUiPump",
|
||||
base::FEATURE_ENABLED_BY_DEFAULT);
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
// Enables writing basic system profile to the persistent histograms files
|
||||
|
@ -941,9 +941,6 @@ BASE_DECLARE_FEATURE(kUseManagedPrintJobOptionsInPrintPreview);
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
COMPONENT_EXPORT(CHROME_FEATURES)
|
||||
BASE_DECLARE_FEATURE(kWin10AcceleratedDefaultBrowserFlow);
|
||||
|
||||
COMPONENT_EXPORT(CHROME_FEATURES)
|
||||
BASE_DECLARE_FEATURE(kUtilWinProcessUsesUiPump);
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
COMPONENT_EXPORT(CHROME_FEATURES)
|
||||
|
@ -28,35 +28,21 @@
|
||||
#include "base/win/shortcut.h"
|
||||
#include "base/win/win_util.h"
|
||||
#include "chrome/browser/win/conflicts/module_info_util.h"
|
||||
#include "chrome/common/chrome_features.h"
|
||||
#include "chrome/installer/util/registry_util.h"
|
||||
#include "chrome/installer/util/taskbar_util.h"
|
||||
#include "chrome/services/util_win/av_products.h"
|
||||
#include "chrome/services/util_win/tpm_metrics.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "third_party/metrics_proto/system_profile.pb.h"
|
||||
#include "ui/shell_dialogs/execute_select_file_win.h"
|
||||
|
||||
namespace {
|
||||
|
||||
bool COMAlreadyInitialized() {
|
||||
if (base::FeatureList::IsEnabled(features::kUtilWinProcessUsesUiPump) &&
|
||||
base::FeatureList::IsEnabled(
|
||||
features::kUtilityWithUiPumpInitializesCom)) {
|
||||
base::win::AssertComApartmentType(base::win::ComApartmentType::STA);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// This class checks if the current executable is pinned to the taskbar. It also
|
||||
// keeps track of the errors that occurs that prevents it from getting a result.
|
||||
class IsPinnedToTaskbarHelper {
|
||||
public:
|
||||
IsPinnedToTaskbarHelper() {
|
||||
if (!COMAlreadyInitialized()) {
|
||||
scoped_com_initializer_.emplace();
|
||||
}
|
||||
base::win::AssertComApartmentType(base::win::ComApartmentType::STA);
|
||||
}
|
||||
|
||||
IsPinnedToTaskbarHelper(const IsPinnedToTaskbarHelper&) = delete;
|
||||
@ -88,7 +74,6 @@ class IsPinnedToTaskbarHelper {
|
||||
const installer::ProgramCompare& program_compare);
|
||||
|
||||
bool error_occured_ = false;
|
||||
std::optional<base::win::ScopedCOMInitializer> scoped_com_initializer_;
|
||||
};
|
||||
|
||||
std::wstring IsPinnedToTaskbarHelper::LoadShellResourceString(
|
||||
@ -263,12 +248,7 @@ void UtilWinImpl::IsPinnedToTaskbar(IsPinnedToTaskbarCallback callback) {
|
||||
void UtilWinImpl::UnpinShortcuts(
|
||||
const std::vector<base::FilePath>& shortcut_paths,
|
||||
UnpinShortcutsCallback callback) {
|
||||
// TODO(crbug.com/348014083): This exists to preserve an old behavior in
|
||||
// an experiment control group. Remove after experiment is complete.
|
||||
std::optional<base::win::ScopedCOMInitializer> scoped_com_initializer;
|
||||
if (!COMAlreadyInitialized()) {
|
||||
scoped_com_initializer.emplace();
|
||||
}
|
||||
base::win::AssertComApartmentType(base::win::ComApartmentType::STA);
|
||||
|
||||
for (const auto& shortcut_path : shortcut_paths)
|
||||
UnpinShortcutFromTaskbar(shortcut_path);
|
||||
@ -281,16 +261,7 @@ void UtilWinImpl::CreateOrUpdateShortcuts(
|
||||
const std::vector<base::win::ShortcutProperties>& properties,
|
||||
base::win::ShortcutOperation operation,
|
||||
CreateOrUpdateShortcutsCallback callback) {
|
||||
// TODO(crbug.com/348014083): This exists to preserve an old behavior in
|
||||
// an experiment control group. Remove after experiment is complete.
|
||||
std::optional<base::win::ScopedCOMInitializer> scoped_com_initializer;
|
||||
if (!COMAlreadyInitialized()) {
|
||||
scoped_com_initializer.emplace();
|
||||
if (!scoped_com_initializer->Succeeded()) {
|
||||
std::move(callback).Run(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
base::win::AssertComApartmentType(base::win::ComApartmentType::STA);
|
||||
|
||||
bool ret = true;
|
||||
for (size_t i = 0; i < shortcut_paths.size(); ++i) {
|
||||
@ -309,12 +280,7 @@ void UtilWinImpl::CallExecuteSelectFile(
|
||||
int32_t file_type_index,
|
||||
const std::u16string& default_extension,
|
||||
CallExecuteSelectFileCallback callback) {
|
||||
// TODO(crbug.com/348014083): This exists to preserve an old behavior in
|
||||
// an experiment control group. Remove after experiment is complete.
|
||||
std::optional<base::win::ScopedCOMInitializer> scoped_com_initializer;
|
||||
if (!COMAlreadyInitialized()) {
|
||||
scoped_com_initializer.emplace();
|
||||
}
|
||||
base::win::AssertComApartmentType(base::win::ComApartmentType::STA);
|
||||
|
||||
base::win::EnableHighDPISupport();
|
||||
|
||||
@ -337,12 +303,7 @@ void UtilWinImpl::InspectModule(const base::FilePath& module_path,
|
||||
|
||||
void UtilWinImpl::GetAntiVirusProducts(bool report_full_names,
|
||||
GetAntiVirusProductsCallback callback) {
|
||||
// TODO(crbug.com/348014083): This exists to preserve an old behavior in
|
||||
// an experiment control group. Remove after experiment is complete.
|
||||
std::optional<base::win::ScopedCOMInitializer> scoped_com_initializer;
|
||||
if (!COMAlreadyInitialized()) {
|
||||
scoped_com_initializer.emplace();
|
||||
}
|
||||
base::win::AssertComApartmentType(base::win::ComApartmentType::STA);
|
||||
std::move(callback).Run(::GetAntiVirusProducts(report_full_names));
|
||||
}
|
||||
|
||||
|
@ -1090,12 +1090,6 @@ const base::FeatureParam<FontDataServiceTypefaceType>
|
||||
kFontDataServiceTypefaceType{&kFontDataServiceAllWebContents, "typeface",
|
||||
FontDataServiceTypefaceType::kDwrite,
|
||||
&font_data_service_typeface};
|
||||
|
||||
// Whether a utility process configured to use a "UI" message pump should also
|
||||
// initialize COM.
|
||||
BASE_FEATURE(kUtilityWithUiPumpInitializesCom,
|
||||
"UtilityWithUiPumpInitializesCom",
|
||||
base::FEATURE_ENABLED_BY_DEFAULT);
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
// When enabled, OOPIFs will not try to reuse compatible processes from
|
||||
|
@ -243,7 +243,6 @@ enum class FontDataServiceTypefaceType {
|
||||
};
|
||||
extern const base::FeatureParam<FontDataServiceTypefaceType>
|
||||
kFontDataServiceTypefaceType;
|
||||
CONTENT_EXPORT BASE_DECLARE_FEATURE(kUtilityWithUiPumpInitializesCom);
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
CONTENT_EXPORT BASE_DECLARE_FEATURE(kDisableProcessReuse);
|
||||
CONTENT_EXPORT BASE_DECLARE_FEATURE(kServiceWorkerAutoPreload);
|
||||
|
@ -359,9 +359,7 @@ int UtilityMain(MainFunctionParams parameters) {
|
||||
|
||||
#elif BUILDFLAG(IS_WIN)
|
||||
std::optional<base::win::ScopedCOMInitializer> scoped_com_initializer;
|
||||
if (message_pump_type == base::MessagePumpType::UI &&
|
||||
base::FeatureList::IsEnabled(
|
||||
features::kUtilityWithUiPumpInitializesCom)) {
|
||||
if (message_pump_type == base::MessagePumpType::UI) {
|
||||
scoped_com_initializer.emplace();
|
||||
CHECK(scoped_com_initializer->Succeeded());
|
||||
}
|
||||
|
Reference in New Issue
Block a user