refactor: initialize feature list earlier (#17922)
This commit is contained in:
parent
132137081a
commit
53c453567f
6 changed files with 51 additions and 19 deletions
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "atom/app/atom_content_client.h"
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/feature_list.h"
|
||||
#include "atom/browser/relauncher.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "atom/renderer/atom_renderer_client.h"
|
||||
|
@ -247,6 +248,10 @@ void AtomMainDelegate::PreSandboxStartup() {
|
|||
}
|
||||
|
||||
void AtomMainDelegate::PreCreateMainMessageLoop() {
|
||||
// This is initialized early because the service manager reads some feature
|
||||
// flags and we need to make sure the feature list is initialized before the
|
||||
// service manager reads the features.
|
||||
InitializeFeatureList();
|
||||
#if defined(OS_MACOSX)
|
||||
RegisterAtomCrApp();
|
||||
#endif
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "atom/browser/atom_web_ui_controller_factory.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/browser_process_impl.h"
|
||||
#include "atom/browser/feature_list.h"
|
||||
#include "atom/browser/javascript_environment.h"
|
||||
#include "atom/browser/media/media_capture_devices_dispatcher.h"
|
||||
#include "atom/browser/node_debugger.h"
|
||||
|
@ -197,23 +198,6 @@ int X11EmptyIOErrorHandler(Display* d) {
|
|||
|
||||
} // namespace
|
||||
|
||||
void AtomBrowserMainParts::InitializeFeatureList() {
|
||||
auto* cmd_line = base::CommandLine::ForCurrentProcess();
|
||||
auto enable_features =
|
||||
cmd_line->GetSwitchValueASCII(::switches::kEnableFeatures);
|
||||
auto disable_features =
|
||||
cmd_line->GetSwitchValueASCII(::switches::kDisableFeatures);
|
||||
// Disable creation of spare renderer process with site-per-process mode,
|
||||
// it interferes with our process preference tracking for non sandboxed mode.
|
||||
// Can be reenabled when our site instance policy is aligned with chromium
|
||||
// when node integration is enabled.
|
||||
disable_features +=
|
||||
std::string(",") + features::kSpareRendererForSitePerProcess.name;
|
||||
auto feature_list = std::make_unique<base::FeatureList>();
|
||||
feature_list->InitializeFromCommandLine(enable_features, disable_features);
|
||||
base::FeatureList::SetInstance(std::move(feature_list));
|
||||
}
|
||||
|
||||
// static
|
||||
AtomBrowserMainParts* AtomBrowserMainParts::self_ = nullptr;
|
||||
|
||||
|
@ -271,7 +255,6 @@ void AtomBrowserMainParts::RegisterDestructionCallback(
|
|||
}
|
||||
|
||||
int AtomBrowserMainParts::PreEarlyInitialization() {
|
||||
InitializeFeatureList();
|
||||
field_trial_list_ = std::make_unique<base::FieldTrialList>(nullptr);
|
||||
#if defined(USE_X11)
|
||||
views::LinuxUI::SetInstance(BuildGtkUi());
|
||||
|
|
|
@ -87,7 +87,6 @@ class AtomBrowserMainParts : public content::BrowserMainParts {
|
|||
void PostDestroyThreads() override;
|
||||
|
||||
private:
|
||||
void InitializeFeatureList();
|
||||
void PreMainMessageLoopStartCommon();
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
|
|
31
atom/browser/feature_list.cc
Normal file
31
atom/browser/feature_list.cc
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) 2019 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "electron/atom/browser/feature_list.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/base_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
void InitializeFeatureList() {
|
||||
auto* cmd_line = base::CommandLine::ForCurrentProcess();
|
||||
auto enable_features =
|
||||
cmd_line->GetSwitchValueASCII(::switches::kEnableFeatures);
|
||||
auto disable_features =
|
||||
cmd_line->GetSwitchValueASCII(::switches::kDisableFeatures);
|
||||
// Disable creation of spare renderer process with site-per-process mode,
|
||||
// it interferes with our process preference tracking for non sandboxed mode.
|
||||
// Can be reenabled when our site instance policy is aligned with chromium
|
||||
// when node integration is enabled.
|
||||
disable_features +=
|
||||
std::string(",") + features::kSpareRendererForSitePerProcess.name;
|
||||
base::FeatureList::InitializeInstance(enable_features, disable_features);
|
||||
}
|
||||
|
||||
} // namespace atom
|
12
atom/browser/feature_list.h
Normal file
12
atom/browser/feature_list.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) 2019 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_FEATURE_LIST_H_
|
||||
#define ATOM_BROWSER_FEATURE_LIST_H_
|
||||
|
||||
namespace atom {
|
||||
void InitializeFeatureList();
|
||||
}
|
||||
|
||||
#endif // ATOM_BROWSER_FEATURE_LIST_H_
|
|
@ -131,6 +131,8 @@ filenames = {
|
|||
"atom/browser/api/atom_api_app.cc",
|
||||
"atom/browser/font_defaults.cc",
|
||||
"atom/browser/font_defaults.h",
|
||||
"atom/browser/feature_list.cc",
|
||||
"atom/browser/feature_list.h",
|
||||
"atom/browser/api/atom_api_app.h",
|
||||
"atom/browser/api/atom_api_auto_updater.cc",
|
||||
"atom/browser/api/atom_api_auto_updater.h",
|
||||
|
|
Loading…
Reference in a new issue