| 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> | 8 #include <algorithm> |
| 9 #include <iostream> | 9 #include <iostream> |
| 10 | 10 |
| 11 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/stack_trace.h" | 14 #include "base/debug/stack_trace.h" |
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 16 #include "base/i18n/icu_util.h" |
| 16 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 18 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
| 19 #include "base/threading/platform_thread.h" | 20 #include "base/threading/platform_thread.h" |
| 20 #include "mojo/shell/standalone/context.h" | 21 #include "mojo/shell/standalone/context.h" |
| 21 #include "mojo/shell/standalone/switches.h" | 22 #include "mojo/shell/standalone/switches.h" |
| 22 #include "mojo/shell/switches.h" | 23 #include "mojo/shell/switches.h" |
| 23 | 24 |
| 24 namespace mojo { | 25 namespace mojo { |
| 25 namespace shell { | 26 namespace shell { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 38 | 39 |
| 39 base::PlatformThread::SetName("mojo_runner"); | 40 base::PlatformThread::SetName("mojo_runner"); |
| 40 | 41 |
| 41 // We want the Context to outlive the MessageLoop so that pipes are all | 42 // We want the Context to outlive the MessageLoop so that pipes are all |
| 42 // gracefully closed / error-out before we try to shut the Context down. | 43 // gracefully closed / error-out before we try to shut the Context down. |
| 43 Context shell_context; | 44 Context shell_context; |
| 44 { | 45 { |
| 45 base::MessageLoop message_loop; | 46 base::MessageLoop message_loop; |
| 46 base::FilePath shell_dir; | 47 base::FilePath shell_dir; |
| 47 PathService::Get(base::DIR_MODULE, &shell_dir); | 48 PathService::Get(base::DIR_MODULE, &shell_dir); |
| 49 CHECK(base::i18n::InitializeICU()); |
| 48 shell_context.Init(shell_dir); | 50 shell_context.Init(shell_dir); |
| 49 | 51 |
| 50 if (mojo_url.is_empty()) { | 52 if (mojo_url.is_empty()) { |
| 51 message_loop.PostTask( | 53 message_loop.PostTask( |
| 52 FROM_HERE, | 54 FROM_HERE, |
| 53 base::Bind(&Context::RunCommandLineApplication, | 55 base::Bind(&Context::RunCommandLineApplication, |
| 54 base::Unretained(&shell_context), base::Closure())); | 56 base::Unretained(&shell_context), base::Closure())); |
| 55 } else { | 57 } else { |
| 56 message_loop.PostTask( | 58 message_loop.PostTask( |
| 57 FROM_HERE, base::Bind(&mojo::shell::Context::Run, | 59 FROM_HERE, base::Bind(&mojo::shell::Context::Run, |
| 58 base::Unretained(&shell_context), mojo_url)); | 60 base::Unretained(&shell_context), mojo_url)); |
| 59 } | 61 } |
| 60 message_loop.Run(); | 62 message_loop.Run(); |
| 61 | 63 |
| 62 // Must be called before |message_loop| is destroyed. | 64 // Must be called before |message_loop| is destroyed. |
| 63 shell_context.Shutdown(); | 65 shell_context.Shutdown(); |
| 64 } | 66 } |
| 65 | 67 |
| 66 return 0; | 68 return 0; |
| 67 } | 69 } |
| 68 | 70 |
| 69 } // namespace shell | 71 } // namespace shell |
| 70 } // namespace mojo | 72 } // namespace mojo |
| OLD | NEW |