| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <stdio.h> | |
| 6 #include <string.h> | |
| 7 | |
| 8 #include <algorithm> | |
| 9 #include <iostream> | |
| 10 | |
| 11 #include "base/base_switches.h" | |
| 12 #include "base/bind.h" | |
| 13 #include "base/command_line.h" | |
| 14 #include "base/files/file_util.h" | |
| 15 #include "base/message_loop/message_loop.h" | |
| 16 #include "base/path_service.h" | |
| 17 #include "base/synchronization/waitable_event.h" | |
| 18 #include "base/trace_event/trace_event.h" | |
| 19 #include "components/tracing/trace_config_file.h" | |
| 20 #include "components/tracing/tracing_switches.h" | |
| 21 #include "mandoline/app/desktop/launcher_process.h" | |
| 22 #include "mojo/runner/context.h" | |
| 23 #include "mojo/runner/switches.h" | |
| 24 #include "mojo/shell/switches.h" | |
| 25 | |
| 26 namespace mandoline { | |
| 27 | |
| 28 int LauncherProcessMain(int argc, char** argv) { | |
| 29 mojo::runner::Tracer tracer; | |
| 30 base::CommandLine* command_line = | |
| 31 base::CommandLine::ForCurrentProcess(); | |
| 32 if (!command_line->HasSwitch(switches::kMojoSingleProcess)) | |
| 33 command_line->AppendSwitch(switches::kEnableMultiprocess); | |
| 34 command_line->AppendSwitch("use-new-edk"); | |
| 35 // http://crbug.com/546644 | |
| 36 command_line->AppendSwitch(switches::kMojoNoSandbox); | |
| 37 | |
| 38 bool trace_startup = command_line->HasSwitch(switches::kTraceStartup); | |
| 39 if (trace_startup) { | |
| 40 tracer.Start( | |
| 41 command_line->GetSwitchValueASCII(switches::kTraceStartup), | |
| 42 command_line->GetSwitchValueASCII(switches::kTraceStartupDuration), | |
| 43 "mandoline.trace"); | |
| 44 } | |
| 45 | |
| 46 // We want the runner::Context to outlive the MessageLoop so that pipes are | |
| 47 // all gracefully closed / error-out before we try to shut the Context down. | |
| 48 mojo::runner::Context shell_context; | |
| 49 { | |
| 50 base::MessageLoop message_loop; | |
| 51 base::FilePath shell_dir; | |
| 52 PathService::Get(base::DIR_MODULE, &shell_dir); | |
| 53 if (!shell_context.Init(shell_dir)) { | |
| 54 return 0; | |
| 55 } | |
| 56 | |
| 57 message_loop.PostTask(FROM_HERE, | |
| 58 base::Bind(&mojo::runner::Context::Run, | |
| 59 base::Unretained(&shell_context), | |
| 60 GURL("mojo:desktop_ui"))); | |
| 61 message_loop.Run(); | |
| 62 | |
| 63 // Must be called before |message_loop| is destroyed. | |
| 64 shell_context.Shutdown(); | |
| 65 } | |
| 66 | |
| 67 return 0; | |
| 68 } | |
| 69 | |
| 70 } // namespace mandoline | |
| OLD | NEW |