|
@@ -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);
|