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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" // TODO(vtl): Remove. | 8 #include "base/macros.h" // TODO(vtl): Remove. |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "mojo/common/message_pump_mojo.h" // TODO(vtl): Remove. | 10 #include "mojo/common/message_pump_mojo.h" // TODO(vtl): Remove. |
(...skipping 20 matching lines...) Expand all Loading... |
31 VLOG(2) << "TestChildProcessHostDelegate::DidStart(" << success << ")"; | 31 VLOG(2) << "TestChildProcessHostDelegate::DidStart(" << success << ")"; |
32 base::MessageLoop::current()->QuitWhenIdle(); | 32 base::MessageLoop::current()->QuitWhenIdle(); |
33 } | 33 } |
34 }; | 34 }; |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 int main(int argc, char** argv) { | 38 int main(int argc, char** argv) { |
39 base::AtExitManager at_exit; | 39 base::AtExitManager at_exit; |
40 mojo::Environment env; | 40 mojo::Environment env; |
41 CommandLine::Init(argc, argv); | 41 base::CommandLine::Init(argc, argv); |
42 mojo::shell::InitializeLogging(); | 42 mojo::shell::InitializeLogging(); |
43 | 43 |
44 // TODO(vtl): Move this a proper test (and remove includes marked "remove"). | 44 // TODO(vtl): Move this a proper test (and remove includes marked "remove"). |
45 if (CommandLine::ForCurrentProcess()->HasSwitch("run-test-child")) { | 45 if (base::CommandLine::ForCurrentProcess()->HasSwitch("run-test-child")) { |
46 base::MessageLoop message_loop( | 46 base::MessageLoop message_loop( |
47 scoped_ptr<base::MessagePump>(new mojo::common::MessagePumpMojo())); | 47 scoped_ptr<base::MessagePump>(new mojo::common::MessagePumpMojo())); |
48 | 48 |
49 mojo::shell::Context context; | 49 mojo::shell::Context context; |
50 TestChildProcessHostDelegate child_process_host_delegate; | 50 TestChildProcessHostDelegate child_process_host_delegate; |
51 mojo::shell::ChildProcessHost child_process_host( | 51 mojo::shell::ChildProcessHost child_process_host( |
52 &context, &child_process_host_delegate, | 52 &context, &child_process_host_delegate, |
53 mojo::shell::ChildProcess::TYPE_TEST); | 53 mojo::shell::ChildProcess::TYPE_TEST); |
54 child_process_host.Start(); | 54 child_process_host.Start(); |
55 message_loop.Run(); | 55 message_loop.Run(); |
56 int exit_code = child_process_host.Join(); | 56 int exit_code = child_process_host.Join(); |
57 VLOG(2) << "Joined child: exit_code = " << exit_code; | 57 VLOG(2) << "Joined child: exit_code = " << exit_code; |
58 return 0; | 58 return 0; |
59 } | 59 } |
60 | 60 |
61 // TODO(vtl): Unify parent and child process cases to the extent possible. | 61 // TODO(vtl): Unify parent and child process cases to the extent possible. |
62 if (scoped_ptr<mojo::shell::ChildProcess> child_process = | 62 if (scoped_ptr<mojo::shell::ChildProcess> child_process = |
63 mojo::shell::ChildProcess::Create( | 63 mojo::shell::ChildProcess::Create( |
64 *CommandLine::ForCurrentProcess())) { | 64 *base::CommandLine::ForCurrentProcess())) { |
65 child_process->Main(); | 65 child_process->Main(); |
66 } else { | 66 } else { |
67 gfx::GLSurface::InitializeOneOff(); | 67 gfx::GLSurface::InitializeOneOff(); |
68 | 68 |
69 base::MessageLoop message_loop; | 69 base::MessageLoop message_loop; |
70 mojo::shell::Context context; | 70 mojo::shell::Context context; |
71 message_loop.PostTask(FROM_HERE, base::Bind(mojo::shell::Run, &context)); | 71 message_loop.PostTask(FROM_HERE, base::Bind(mojo::shell::Run, &context)); |
72 | 72 |
73 message_loop.Run(); | 73 message_loop.Run(); |
74 } | 74 } |
75 | 75 |
76 return 0; | 76 return 0; |
77 } | 77 } |
OLD | NEW |