Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdio.h> | 5 #include <stdio.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 | 7 |
| 8 #include <algorithm> | |
| 9 #include <iostream> | 8 #include <iostream> |
| 10 | 9 |
| 11 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| 12 #include "base/bind.h" | 11 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 14 #include "base/debug/stack_trace.h" | 13 #include "base/debug/stack_trace.h" |
| 15 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 16 #include "base/i18n/icu_util.h" | 15 #include "base/i18n/icu_util.h" |
| 17 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 18 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 19 #include "base/synchronization/waitable_event.h" | 18 #include "base/synchronization/waitable_event.h" |
| 20 #include "base/threading/platform_thread.h" | 19 #include "base/threading/platform_thread.h" |
| 21 #include "mojo/shell/standalone/context.h" | 20 #include "mojo/shell/standalone/context.h" |
| 22 #include "mojo/shell/switches.h" | 21 #include "mojo/shell/switches.h" |
| 23 | 22 |
| 24 namespace mojo { | 23 namespace mojo { |
| 25 namespace shell { | 24 namespace shell { |
| 26 | 25 |
| 27 int LauncherProcessMain(const GURL& mojo_url, const base::Closure& callback) { | 26 int LauncherProcessMain() { |
| 28 #if !defined(OFFICIAL_BUILD) | 27 #if !defined(OFFICIAL_BUILD) |
| 29 base::debug::EnableInProcessStackDumping(); | 28 base::debug::EnableInProcessStackDumping(); |
| 30 #endif | 29 #endif |
| 31 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 30 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 32 // http://crbug.com/546644 | 31 // http://crbug.com/546644 |
| 33 command_line->AppendSwitch(switches::kNoSandbox); | 32 command_line->AppendSwitch(switches::kNoSandbox); |
| 34 | 33 |
| 35 base::PlatformThread::SetName("mojo_runner"); | 34 base::PlatformThread::SetName("mojo_runner"); |
| 36 | 35 |
| 37 // We want the Context to outlive the MessageLoop so that pipes are all | 36 // We want the Context to outlive the MessageLoop so that pipes are all |
| 38 // gracefully closed / error-out before we try to shut the Context down. | 37 // gracefully closed / error-out before we try to shut the Context down. |
| 39 Context shell_context; | 38 Context shell_context; |
| 40 { | 39 { |
| 41 base::MessageLoop message_loop; | 40 base::MessageLoop message_loop; |
| 42 base::FilePath shell_dir; | 41 base::FilePath shell_dir; |
| 43 PathService::Get(base::DIR_MODULE, &shell_dir); | 42 PathService::Get(base::DIR_MODULE, &shell_dir); |
| 44 CHECK(base::i18n::InitializeICU()); | 43 CHECK(base::i18n::InitializeICU()); |
| 45 shell_context.Init(shell_dir); | 44 shell_context.Init(shell_dir); |
| 46 | 45 |
| 47 if (mojo_url.is_empty()) { | 46 message_loop.PostTask( |
| 48 message_loop.PostTask( | 47 FROM_HERE, |
| 49 FROM_HERE, | 48 base::Bind(&Context::RunCommandLineApplication, |
| 50 base::Bind(&Context::RunCommandLineApplication, | 49 base::Unretained(&shell_context))); |
| 51 base::Unretained(&shell_context), base::Closure())); | 50 |
| 52 } else { | |
| 53 message_loop.PostTask( | |
| 54 FROM_HERE, base::Bind(&mojo::shell::Context::Run, | |
| 55 base::Unretained(&shell_context), mojo_url)); | |
| 56 } | |
| 57 message_loop.Run(); | 51 message_loop.Run(); |
|
sky
2016/02/19 05:20:51
I think RunCommandLineApplication should be respon
| |
| 58 | 52 |
| 59 // Must be called before |message_loop| is destroyed. | 53 // Must be called before |message_loop| is destroyed. |
| 60 shell_context.Shutdown(); | 54 shell_context.Shutdown(); |
| 61 } | 55 } |
| 62 | 56 |
| 63 return 0; | 57 return 0; |
| 64 } | 58 } |
| 65 | 59 |
| 66 } // namespace shell | 60 } // namespace shell |
| 67 } // namespace mojo | 61 } // namespace mojo |
| OLD | NEW |