From e43baadd5b88da3fd58b7d5a3f546875bccc46a4 Mon Sep 17 00:00:00 2001 From: jam Date: Thu, 12 Nov 2015 15:23:43 -0800 Subject: Remove duplication between Mandoline and mojo_runner main functions. Review URL: https://codereview.chromium.org/1440053002 Cr-Commit-Position: refs/heads/master@{#359431} --- mandoline/app/desktop/BUILD.gn | 2 - mandoline/app/desktop/launcher_process.cc | 68 ------------------------------- mandoline/app/desktop/launcher_process.h | 15 ------- mandoline/app/desktop/main.cc | 30 ++------------ 4 files changed, 3 insertions(+), 112 deletions(-) delete mode 100644 mandoline/app/desktop/launcher_process.cc delete mode 100644 mandoline/app/desktop/launcher_process.h (limited to 'mandoline') diff --git a/mandoline/app/desktop/BUILD.gn b/mandoline/app/desktop/BUILD.gn index ac6d769..e43c193 100644 --- a/mandoline/app/desktop/BUILD.gn +++ b/mandoline/app/desktop/BUILD.gn @@ -11,8 +11,6 @@ group("desktop") { executable("mandoline") { sources = [ "../register_local_aliases.cc", - "launcher_process.cc", - "launcher_process.h", "main.cc", ] diff --git a/mandoline/app/desktop/launcher_process.cc b/mandoline/app/desktop/launcher_process.cc deleted file mode 100644 index 60f5e32..0000000 --- a/mandoline/app/desktop/launcher_process.cc +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include -#include - -#include -#include - -#include "base/base_switches.h" -#include "base/bind.h" -#include "base/command_line.h" -#include "base/files/file_util.h" -#include "base/message_loop/message_loop.h" -#include "base/path_service.h" -#include "base/synchronization/waitable_event.h" -#include "base/trace_event/trace_event.h" -#include "components/tracing/trace_config_file.h" -#include "components/tracing/tracing_switches.h" -#include "mandoline/app/desktop/launcher_process.h" -#include "mojo/runner/context.h" -#include "mojo/runner/switches.h" -#include "mojo/shell/switches.h" - -namespace mandoline { - -int LauncherProcessMain(int argc, char** argv) { - mojo::runner::Tracer tracer; - base::CommandLine* command_line = - base::CommandLine::ForCurrentProcess(); - if (!command_line->HasSwitch(switches::kMojoSingleProcess)) - command_line->AppendSwitch(switches::kEnableMultiprocess); - command_line->AppendSwitch("use-new-edk"); - - bool trace_startup = command_line->HasSwitch(switches::kTraceStartup); - if (trace_startup) { - tracer.Start( - command_line->GetSwitchValueASCII(switches::kTraceStartup), - command_line->GetSwitchValueASCII(switches::kTraceStartupDuration), - "mandoline.trace"); - } - - // We want the runner::Context to outlive the MessageLoop so that pipes are - // all gracefully closed / error-out before we try to shut the Context down. - mojo::runner::Context shell_context; - { - base::MessageLoop message_loop; - base::FilePath shell_dir; - PathService::Get(base::DIR_MODULE, &shell_dir); - if (!shell_context.Init(shell_dir)) { - return 0; - } - - message_loop.PostTask(FROM_HERE, - base::Bind(&mojo::runner::Context::Run, - base::Unretained(&shell_context), - GURL("mojo:desktop_ui"))); - message_loop.Run(); - - // Must be called before |message_loop| is destroyed. - shell_context.Shutdown(); - } - - return 0; -} - -} // namespace mandoline diff --git a/mandoline/app/desktop/launcher_process.h b/mandoline/app/desktop/launcher_process.h deleted file mode 100644 index 045b303..0000000 --- a/mandoline/app/desktop/launcher_process.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MANDOLINE_APP_DESKTOP_LAUNCHER_PROCESS_H_ -#define MANDOLINE_APP_DESKTOP_LAUNCHER_PROCESS_H_ - -namespace mandoline { - -// Main method for the launcher process. -int LauncherProcessMain(int argc, char** argv); - -} // namespace mandoline - -#endif // MANDOLINE_APP_DESKTOP_LAUNCHER_PROCESS_H_ diff --git a/mandoline/app/desktop/main.cc b/mandoline/app/desktop/main.cc index 989d8ec..ddfe4dd9 100644 --- a/mandoline/app/desktop/main.cc +++ b/mandoline/app/desktop/main.cc @@ -2,33 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/at_exit.h" -#include "base/command_line.h" -#include "base/debug/stack_trace.h" -#include "base/process/launch.h" -#include "mandoline/app/desktop/launcher_process.h" -#include "mojo/runner/host/child_process.h" -#include "mojo/runner/host/switches.h" -#include "mojo/runner/init.h" +#include "mojo/runner/desktop/main_helper.h" int main(int argc, char** argv) { - base::CommandLine::Init(argc, argv); - const base::CommandLine& command_line = - *base::CommandLine::ForCurrentProcess(); - - base::AtExitManager at_exit; - mojo::runner::InitializeLogging(); - mojo::runner::WaitForDebuggerIfNecessary(); - -#if !defined(OFFICIAL_BUILD) - base::debug::EnableInProcessStackDumping(); -#if defined(OS_WIN) - base::RouteStdioToConsole(false); -#endif -#endif - - if (command_line.HasSwitch(switches::kChildProcess)) - return mojo::runner::ChildProcessMain(); - - return mandoline::LauncherProcessMain(argc, argv); + return mojo::runner::RunnerMain(argc, argv, GURL("mojo:desktop_ui"), + base::Closure()); } -- cgit v1.1