Skip to content

Commit

Permalink
Reland "Move zygote code to service_manager"
Browse files Browse the repository at this point in the history
Relanding the move zygote to the service manager. It was causing an TSAN
failure that now cannot be reproduced.

Original description:

"This CL moves the zygote code from content/ to
services/service_manager/zygote. This involves moving some switches from
content_switches.h to services/service_manager/embedder/switches.h and
moving some codes from content/public/common/result_codes.h to the new
services/service_manager/embedder/result_codes.h."

Tbr: avi@chromium.org
Tbr: sky@chromium.org
Tbr: scottmg@chromium.org
Tbr: rockot@chromium.org
Tbr: slan@chromium.org
Tbr: eseckler@chromium.org
Tbr: rsesek@chromium.org
Bug: 831846
Change-Id: Ief3c55a1d76ab0b0ded922770d14402c0c3b37b9
Reviewed-on: https://chromium-review.googlesource.com/1048040
Reviewed-by: Ken Rockot <rockot@chromium.org>
Reviewed-by: Eric Seckler <eseckler@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Jay Civelli <jcivelli@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
Reviewed-by: Stephen Lanham <slan@chromium.org>
Commit-Queue: Jay Civelli <jcivelli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559276}
  • Loading branch information
jcivelli-google authored and Commit Bot committed May 16, 2018
1 parent 2028c1d commit 668c097
Show file tree
Hide file tree
Showing 144 changed files with 759 additions and 577 deletions.
4 changes: 2 additions & 2 deletions android_webview/browser/aw_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int AwBrowserMainParts::PreEarlyInitialization() {
DCHECK(!main_message_loop_.get());
main_message_loop_.reset(new base::MessageLoopForUI);
base::MessageLoopCurrentForUI::Get()->Start();
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;
}

int AwBrowserMainParts::PreCreateThreads() {
Expand Down Expand Up @@ -130,7 +130,7 @@ int AwBrowserMainParts::PreCreateThreads() {
aw_field_trial_creator_.SetUpFieldTrials();
}

return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;
}

void AwBrowserMainParts::PreMainMessageLoopRun() {
Expand Down
1 change: 1 addition & 0 deletions apps/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include_rules = [
# app_shell may depend on apps, but not vice versa.
"-extensions/shell",
"+net/base",
"+services/service_manager",
]

specific_include_rules = {
Expand Down
3 changes: 3 additions & 0 deletions chrome/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ include_rules = [
"-webkit",
"-tools",

# Required for process launching.
"+services/service_manager",

# Allow inclusion of WebKit API files.
"+third_party/blink/public/common",
"+third_party/blink/public/platform",
Expand Down
1 change: 0 additions & 1 deletion chrome/android/java/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ include_rules = [

"+device/gamepad/android/java",
"+device/geolocation/android/java",
"+services/service_manager/public/java",
]

specific_include_rules = {
Expand Down
2 changes: 0 additions & 2 deletions chrome/android/javatests/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ include_rules = [

"+device/geolocation/android/java",
"+device/geolocation/android/javatests",

"+services/service_manager/public/java",
]

specific_include_rules = {
Expand Down
1 change: 0 additions & 1 deletion chrome/app/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ include_rules = [
"+native_client/src/trusted/service_runtime/osx",
"+remoting/client/plugin",
"+sandbox",
"+services/service_manager",
"+services/ui/public",
"+third_party/breakpad/breakpad",
"+third_party/crashpad/crashpad",
Expand Down
3 changes: 2 additions & 1 deletion chrome/app/chrome_crash_reporter_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "chrome/installer/util/google_update_settings.h"
#include "components/crash/core/common/crash_keys.h"
#include "content/public/common/content_switches.h"
#include "services/service_manager/embedder/switches.h"

#if defined(OS_POSIX) && !defined(OS_MACOSX)
#include "components/upload_list/crash_upload_list.h"
Expand Down Expand Up @@ -133,7 +134,7 @@ bool ChromeCrashReporterClient::EnableBreakpadForProcess(
const std::string& process_type) {
return process_type == switches::kRendererProcess ||
process_type == switches::kPpapiPluginProcess ||
process_type == switches::kZygoteProcess ||
process_type == service_manager::switches::kZygoteProcess ||
process_type == switches::kGpuProcess ||
process_type == switches::kUtilityProcess;
}
13 changes: 7 additions & 6 deletions chrome/app/chrome_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void AdjustLinuxOOMScore(const std::string& process_type) {
process_type == switches::kNaClLoaderNonSfiProcess) {
score = kPluginScore;
#endif
} else if (process_type == switches::kZygoteProcess ||
} else if (process_type == service_manager::switches::kZygoteProcess ||
process_type ==
service_manager::switches::kProcessTypeServiceManager ||
process_type.empty()) {
Expand Down Expand Up @@ -299,7 +299,7 @@ bool SubprocessNeedsResourceBundle(const std::string& process_type) {
return
#if defined(OS_LINUX)
// The zygote process opens the resources for the renderers.
process_type == switches::kZygoteProcess ||
process_type == service_manager::switches::kZygoteProcess ||
#endif
#if defined(OS_MACOSX)
// Mac needs them too for scrollbar related images and for sandbox
Expand Down Expand Up @@ -817,13 +817,13 @@ void ChromeMainDelegate::PreSandboxStartup() {
// browser process as a command line flag.
#if !BUILDFLAG(ENABLE_NACL)
DCHECK(command_line.HasSwitch(switches::kLang) ||
process_type == switches::kZygoteProcess ||
process_type == service_manager::switches::kZygoteProcess ||
process_type == switches::kGpuProcess ||
process_type == switches::kPpapiBrokerProcess ||
process_type == switches::kPpapiPluginProcess);
#else
DCHECK(command_line.HasSwitch(switches::kLang) ||
process_type == switches::kZygoteProcess ||
process_type == service_manager::switches::kZygoteProcess ||
process_type == switches::kGpuProcess ||
process_type == switches::kNaClLoaderProcess ||
process_type == switches::kPpapiBrokerProcess ||
Expand Down Expand Up @@ -892,7 +892,7 @@ void ChromeMainDelegate::PreSandboxStartup() {

#if defined(OS_POSIX) && !defined(OS_MACOSX)
// Zygote needs to call InitCrashReporter() in RunZygote().
if (process_type != switches::kZygoteProcess) {
if (process_type != service_manager::switches::kZygoteProcess) {
#if defined(OS_ANDROID)
if (process_type.empty()) {
breakpad::InitCrashReporter(process_type);
Expand Down Expand Up @@ -1015,7 +1015,8 @@ bool ChromeMainDelegate::DelaySandboxInitialization(
}
#elif defined(OS_LINUX)
void ChromeMainDelegate::ZygoteStarting(
std::vector<std::unique_ptr<content::ZygoteForkDelegate>>* delegates) {
std::vector<std::unique_ptr<service_manager::ZygoteForkDelegate>>*
delegates) {
#if defined(OS_CHROMEOS)
chromeos::ReloadElfTextInHugePages();
#endif
Expand Down
5 changes: 3 additions & 2 deletions chrome/app/chrome_main_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ class ChromeMainDelegate : public content::ContentMainDelegate {
bool ShouldSendMachPort(const std::string& process_type) override;
bool DelaySandboxInitialization(const std::string& process_type) override;
#elif defined(OS_LINUX)
void ZygoteStarting(std::vector<std::unique_ptr<content::ZygoteForkDelegate>>*
delegates) override;
void ZygoteStarting(
std::vector<std::unique_ptr<service_manager::ZygoteForkDelegate>>*
delegates) override;
void ZygoteForked() override;
#endif
bool ShouldEnableProfilerRecording() override;
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3081,6 +3081,7 @@ jumbo_split_static_library("browser") {
configs += [ "//build/config/linux:x11" ]
deps += [ "//ui/gfx/x" ]
}
deps += [ "//services/service_manager/zygote" ]
}

if (is_desktop_linux) {
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ include_rules = [
"+services/proxy_resolver/public/mojom",
"+services/resource_coordinator/public/cpp",
"+services/resource_coordinator/public/mojom",
"+services/service_manager",
"+services/shape_detection/public/mojom",
"+services/ui/common",
"+services/ui/public",
Expand Down
30 changes: 15 additions & 15 deletions chrome/browser/chrome_browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ ChromeBrowserMainParts::ChromeBrowserMainParts(
std::unique_ptr<ui::DataPack> data_pack)
: parameters_(parameters),
parsed_command_line_(parameters.command_line),
result_code_(content::RESULT_CODE_NORMAL_EXIT),
result_code_(service_manager::RESULT_CODE_NORMAL_EXIT),
ui_thread_profiler_(ThreadProfiler::CreateAndStartOnMainThread()),
should_call_pre_main_loop_start_startup_on_variations_service_(
!parameters.ui_task),
Expand Down Expand Up @@ -1086,7 +1086,7 @@ int ChromeBrowserMainParts::PreEarlyInitialization() {
}
// Continue on and show error later (once UI has been initialized and main
// message loop is running).
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;
}
return load_local_state_result;
}
Expand Down Expand Up @@ -1139,7 +1139,7 @@ int ChromeBrowserMainParts::PreCreateThreads() {
TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads");
result_code_ = PreCreateThreadsImpl();

if (result_code_ == content::RESULT_CODE_NORMAL_EXIT) {
if (result_code_ == service_manager::RESULT_CODE_NORMAL_EXIT) {
#if !defined(OS_ANDROID)
// These members must be initialized before exiting this function normally.
DCHECK(master_prefs_.get());
Expand Down Expand Up @@ -1184,7 +1184,7 @@ int ChromeBrowserMainParts::LoadLocalState(
}

const int apply_first_run_result = ApplyFirstRunPrefs();
if (apply_first_run_result != content::RESULT_CODE_NORMAL_EXIT)
if (apply_first_run_result != service_manager::RESULT_CODE_NORMAL_EXIT)
return apply_first_run_result;

browser_process_->SetApplicationLocale(locale);
Expand All @@ -1199,7 +1199,7 @@ int ChromeBrowserMainParts::LoadLocalState(
// tasks.
SetupFieldTrials();

return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;
}

int ChromeBrowserMainParts::ApplyFirstRunPrefs() {
Expand All @@ -1210,7 +1210,7 @@ int ChromeBrowserMainParts::ApplyFirstRunPrefs() {
// browser's profile_manager object is created, but after ResourceBundle
// is initialized.
if (!first_run::IsChromeFirstRun())
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;

first_run::ProcessMasterPreferencesResult pmp_result =
first_run::ProcessMasterPreferences(user_data_dir_, master_prefs_.get());
Expand Down Expand Up @@ -1252,7 +1252,7 @@ int ChromeBrowserMainParts::ApplyFirstRunPrefs() {
local_state->SetBoolean(prefs::kWelcomePageOnOSUpgradeEnabled, false);
#endif
#endif // !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;
}

int ChromeBrowserMainParts::PreCreateThreadsImpl() {
Expand Down Expand Up @@ -1431,7 +1431,7 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() {
// which is used in SetupMetrics().
SetupMetrics();

return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;
}

void ChromeBrowserMainParts::PostCreateThreads() {
Expand Down Expand Up @@ -1644,7 +1644,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
}

return shell_integration::SetAsDefaultBrowser()
? static_cast<int>(content::RESULT_CODE_NORMAL_EXIT)
? static_cast<int>(service_manager::RESULT_CODE_NORMAL_EXIT)
: static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED);
}

Expand All @@ -1660,7 +1660,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
if (parsed_command_line().HasSwitch(switches::kPackExtension)) {
extensions::StartupHelper extension_startup_helper;
if (extension_startup_helper.PackExtension(parsed_command_line()))
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;
return chrome::RESULT_CODE_PACK_EXTENSION_ERROR;
}

Expand Down Expand Up @@ -1691,7 +1691,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// expected.
if (parsed_command_line().HasSwitch(switches::kTestType))
return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED;
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;

case ProcessSingleton::PROFILE_IN_USE:
return chrome::RESULT_CODE_PROFILE_IN_USE;
Expand Down Expand Up @@ -1751,15 +1751,15 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
}
#else
// We don't support retention experiments on Mac or Linux.
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;
#endif // defined(OS_WIN)
}
#endif // !defined(OS_ANDROID)

#if defined(OS_WIN)
// Do the tasks if chrome has been upgraded while it was last running.
if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line()))
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;

// Check if there is any machine level Chrome installed on the current
// machine. If yes and the current Chrome process is user level, we do not
Expand Down Expand Up @@ -1789,7 +1789,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
user_data_dir_,
parsed_command_line());
if (!profile_)
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;

#if !defined(OS_ANDROID)
const base::TimeTicks start_time_step2 = base::TimeTicks::Now();
Expand Down Expand Up @@ -1843,7 +1843,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// The first run dialog is modal, and spins a RunLoop, which could receive
// a SIGTERM, and call chrome::AttemptExit(). Exit cleanly in that case.
if (browser_shutdown::IsTryingToQuit())
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;

if (!master_prefs_->suppress_first_run_default_browser_prompt) {
browser_creator_->set_show_main_browser_window(
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chrome_browser_main_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ChromeBrowserMainPartsPosix::ChromeBrowserMainPartsPosix(

int ChromeBrowserMainPartsPosix::PreEarlyInitialization() {
const int result = ChromeBrowserMainParts::PreEarlyInitialization();
if (result != content::RESULT_CODE_NORMAL_EXIT)
if (result != service_manager::RESULT_CODE_NORMAL_EXIT)
return result;

// We need to accept SIGCHLD, even though our handler is a no-op because
Expand All @@ -124,7 +124,7 @@ int ChromeBrowserMainPartsPosix::PreEarlyInitialization() {
action.sa_handler = SIGCHLDHandler;
CHECK(sigaction(SIGCHLD, &action, NULL) == 0);

return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;
}

void ChromeBrowserMainPartsPosix::PostMainMessageLoopStart() {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_browser_main_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ int ChromeBrowserMainPartsWin::HandleIconsCommands(
ShellExecute(NULL, NULL, L"appwiz.cpl", NULL, NULL, SW_SHOWNORMAL);

// Exit as we are not launching the browser.
return content::RESULT_CODE_NORMAL_EXIT;
return service_manager::RESULT_CODE_NORMAL_EXIT;
}
// We don't hide icons so we shouldn't do anything special to show them
return chrome::RESULT_CODE_UNSUPPORTED_PARAM;
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
#include "services/preferences/public/cpp/in_process_service_factory.h"
#include "services/preferences/public/mojom/preferences.mojom.h"
#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
#include "services/service_manager/embedder/switches.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/mojom/connector.mojom.h"
#include "services/service_manager/sandbox/sandbox_type.h"
Expand Down Expand Up @@ -2040,7 +2041,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
arraysize(kSwitchNames));
#endif
} else if (process_type == switches::kZygoteProcess) {
} else if (process_type == service_manager::switches::kZygoteProcess) {
static const char* const kSwitchNames[] = {
// Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
switches::kDisableBundledPpapiFlash,
Expand Down Expand Up @@ -3166,7 +3167,7 @@ void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
#else
int crash_signal_fd = GetCrashSignalFD(command_line);
if (crash_signal_fd >= 0) {
mappings->Share(kCrashDumpSignal, crash_signal_fd);
mappings->Share(service_manager::kCrashDumpSignal, crash_signal_fd);
}
#endif // defined(OS_ANDROID)
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/memory_details.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "ui/base/l10n/l10n_util.h"

#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
#include "content/public/browser/zygote_host_linux.h"
#include "services/service_manager/zygote/zygote_host_linux.h"
#endif

#if BUILDFLAG(ENABLE_EXTENSIONS)
Expand Down Expand Up @@ -342,7 +342,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
}

#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
if (content::ZygoteHost::GetInstance()->IsZygotePid(process.pid)) {
if (service_manager::ZygoteHost::GetInstance()->IsZygotePid(process.pid)) {
process.process_type = content::PROCESS_TYPE_ZYGOTE;
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/zygote_host_linux.h"
#include "services/service_manager/zygote/zygote_host_linux.h"
#include "ui/wm/public/activation_client.h"

using base::ProcessHandle;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/uninstall_browser_prompt.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace chrome {

// Asks user for uninstall confirmation and returns one of these values:
// content::RESULT_CODE_NORMAL_EXIT,
// service_manager::RESULT_CODE_NORMAL_EXIT,
// chrome::RESULT_CODE_UNINSTALL_DELETE_PROFILE or
// chrome::RESULT_CODE_UNINSTALL_USER_CANCEL.
int ShowUninstallBrowserPrompt();
Expand Down
Loading

0 comments on commit 668c097

Please sign in to comment.