diff --git a/shell/browser/relauncher.cc b/shell/browser/relauncher.cc index 93deae119b62..f2200d817ad3 100644 --- a/shell/browser/relauncher.cc +++ b/shell/browser/relauncher.cc @@ -23,6 +23,24 @@ #include "base/posix/eintr_wrapper.h" #endif +namespace { + +// The argument separating arguments intended for the relauncher process from +// those intended for the relaunched process. "---" is chosen instead of "--" +// because CommandLine interprets "--" as meaning "end of switches", but +// for many purposes, the relauncher process' CommandLine ought to interpret +// arguments intended for the relaunched process, to get the correct settings +// for such things as logging and the user-data-dir in case it affects crash +// reporting. +constexpr base::CommandLine::CharType kRelauncherArgSeparator[] = + FILE_PATH_LITERAL("---"); + +// The "type" argument identifying a relauncher process ("--type=relauncher"). +constexpr base::CommandLine::CharType kRelauncherTypeArg[] = + FILE_PATH_LITERAL("--type=relauncher"); + +} // namespace + namespace relauncher { namespace internal { @@ -31,9 +49,6 @@ namespace internal { const int kRelauncherSyncFD = STDERR_FILENO + 1; #endif -const CharType* kRelauncherTypeArg = FILE_PATH_LITERAL("--type=relauncher"); -const CharType* kRelauncherArgSeparator = FILE_PATH_LITERAL("---"); - } // namespace internal bool RelaunchApp(const StringVector& argv) { @@ -58,7 +73,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper, const StringVector& argv) { StringVector relaunch_argv; relaunch_argv.push_back(helper.value()); - relaunch_argv.push_back(internal::kRelauncherTypeArg); + relaunch_argv.push_back(kRelauncherTypeArg); // Relauncher process has its own --type=relauncher which // is not recognized by the service_manager, explicitly set // the sandbox type to avoid CHECK failure in @@ -68,7 +83,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper, relaunch_argv.insert(relaunch_argv.end(), relauncher_args.begin(), relauncher_args.end()); - relaunch_argv.push_back(internal::kRelauncherArgSeparator); + relaunch_argv.push_back(kRelauncherArgSeparator); relaunch_argv.insert(relaunch_argv.end(), argv.begin(), argv.end()); @@ -147,7 +162,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper, int RelauncherMain(const content::MainFunctionParams& main_parameters) { const StringVector& argv = electron::ElectronCommandLine::argv(); - if (argv.size() < 4 || argv[1] != internal::kRelauncherTypeArg) { + if (argv.size() < 4 || argv[1] != kRelauncherTypeArg) { LOG(ERROR) << "relauncher process invoked with unexpected arguments"; return 1; } @@ -162,7 +177,7 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) { for (size_t argv_index = 2; argv_index < argv.size(); ++argv_index) { const StringType& arg(argv[argv_index]); if (!in_relauncher_args) { - if (arg == internal::kRelauncherArgSeparator) { + if (arg == kRelauncherArgSeparator) { in_relauncher_args = true; } else { relauncher_args.push_back(arg); diff --git a/shell/browser/relauncher.h b/shell/browser/relauncher.h index 47106a2c0d7b..00f45654726e 100644 --- a/shell/browser/relauncher.h +++ b/shell/browser/relauncher.h @@ -41,7 +41,6 @@ struct MainFunctionParams; namespace relauncher { -using CharType = base::CommandLine::CharType; using StringType = base::CommandLine::StringType; using StringVector = base::CommandLine::StringVector; @@ -83,18 +82,6 @@ namespace internal { extern const int kRelauncherSyncFD; #endif -// The "type" argument identifying a relauncher process ("--type=relauncher"). -extern const CharType* kRelauncherTypeArg; - -// The argument separating arguments intended for the relauncher process from -// those intended for the relaunched process. "---" is chosen instead of "--" -// because CommandLine interprets "--" as meaning "end of switches", but -// for many purposes, the relauncher process' CommandLine ought to interpret -// arguments intended for the relaunched process, to get the correct settings -// for such things as logging and the user-data-dir in case it affects crash -// reporting. -extern const CharType* kRelauncherArgSeparator; - #if BUILDFLAG(IS_WIN) StringType GetWaitEventName(base::ProcessId pid); diff --git a/shell/browser/relauncher_win.cc b/shell/browser/relauncher_win.cc index 5d0d0d2ed61a..9adb2bf19c81 100644 --- a/shell/browser/relauncher_win.cc +++ b/shell/browser/relauncher_win.cc @@ -19,8 +19,6 @@ namespace relauncher::internal { namespace { -const CharType* kWaitEventName = L"ElectronRelauncherWaitEvent"; - struct PROCESS_BASIC_INFORMATION { union { NTSTATUS ExitStatus; @@ -98,8 +96,8 @@ StringType AddQuoteForArg(const StringType& arg) { } // namespace StringType GetWaitEventName(base::ProcessId pid) { - return base::StrCat( - {kWaitEventName, L"-", base::NumberToWString(static_cast(pid))}); + return base::StrCat({L"ElectronRelauncherWaitEvent-", + base::NumberToWString(static_cast(pid))}); } StringType ArgvToCommandLineString(const StringVector& argv) {