| 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. | |
| 9 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 10 #include "mojo/common/message_pump_mojo.h" // TODO(vtl): Remove. | |
| 11 #include "mojo/public/cpp/environment/environment.h" | 9 #include "mojo/public/cpp/environment/environment.h" |
| 12 #include "mojo/shell/child_process.h" | 10 #include "mojo/shell/child_process.h" |
| 13 #include "mojo/shell/child_process_host.h" // TODO(vtl): Remove. | |
| 14 #include "mojo/shell/context.h" | 11 #include "mojo/shell/context.h" |
| 15 #include "mojo/shell/init.h" | 12 #include "mojo/shell/init.h" |
| 16 #include "mojo/shell/run.h" | 13 #include "mojo/shell/run.h" |
| 17 #include "mojo/shell/switches.h" | 14 #include "mojo/shell/switches.h" |
| 18 #include "ui/gl/gl_surface.h" | 15 #include "ui/gl/gl_surface.h" |
| 19 | 16 |
| 20 namespace { | |
| 21 | |
| 22 // TODO(vtl): Remove. | |
| 23 class TestChildProcessHostDelegate | |
| 24 : public mojo::shell::ChildProcessHost::Delegate { | |
| 25 public: | |
| 26 TestChildProcessHostDelegate() {} | |
| 27 virtual ~TestChildProcessHostDelegate() {} | |
| 28 virtual void WillStart() OVERRIDE { | |
| 29 VLOG(2) << "TestChildProcessHostDelegate::WillStart()"; | |
| 30 } | |
| 31 virtual void DidStart(bool success) OVERRIDE { | |
| 32 VLOG(2) << "TestChildProcessHostDelegate::DidStart(" << success << ")"; | |
| 33 base::MessageLoop::current()->QuitWhenIdle(); | |
| 34 } | |
| 35 }; | |
| 36 | |
| 37 } // namespace | |
| 38 | |
| 39 int main(int argc, char** argv) { | 17 int main(int argc, char** argv) { |
| 40 base::AtExitManager at_exit; | 18 base::AtExitManager at_exit; |
| 41 mojo::Environment env; | 19 mojo::Environment env; |
| 42 base::CommandLine::Init(argc, argv); | 20 base::CommandLine::Init(argc, argv); |
| 43 mojo::shell::InitializeLogging(); | 21 mojo::shell::InitializeLogging(); |
| 44 | 22 |
| 45 // TODO(vtl): Move this a proper test (and remove includes marked "remove"). | |
| 46 if (base::CommandLine::ForCurrentProcess()->HasSwitch("run-test-child")) { | |
| 47 base::MessageLoop message_loop( | |
| 48 scoped_ptr<base::MessagePump>(new mojo::common::MessagePumpMojo())); | |
| 49 | |
| 50 mojo::shell::Context context; | |
| 51 TestChildProcessHostDelegate child_process_host_delegate; | |
| 52 mojo::shell::ChildProcessHost child_process_host( | |
| 53 &context, &child_process_host_delegate, | |
| 54 mojo::shell::ChildProcess::TYPE_TEST); | |
| 55 child_process_host.Start(); | |
| 56 message_loop.Run(); | |
| 57 int exit_code = child_process_host.Join(); | |
| 58 VLOG(2) << "Joined child: exit_code = " << exit_code; | |
| 59 return 0; | |
| 60 } | |
| 61 | |
| 62 // TODO(vtl): Unify parent and child process cases to the extent possible. | 23 // TODO(vtl): Unify parent and child process cases to the extent possible. |
| 63 if (scoped_ptr<mojo::shell::ChildProcess> child_process = | 24 if (scoped_ptr<mojo::shell::ChildProcess> child_process = |
| 64 mojo::shell::ChildProcess::Create( | 25 mojo::shell::ChildProcess::Create( |
| 65 *base::CommandLine::ForCurrentProcess())) { | 26 *base::CommandLine::ForCurrentProcess())) { |
| 66 child_process->Main(); | 27 child_process->Main(); |
| 67 } else { | 28 } else { |
| 68 gfx::GLSurface::InitializeOneOff(); | 29 gfx::GLSurface::InitializeOneOff(); |
| 69 | 30 |
| 70 base::MessageLoop message_loop; | 31 base::MessageLoop message_loop; |
| 71 mojo::shell::Context shell_context; | 32 mojo::shell::Context shell_context; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 87 message_loop.PostTask(FROM_HERE, | 48 message_loop.PostTask(FROM_HERE, |
| 88 base::Bind(mojo::shell::Run, | 49 base::Bind(mojo::shell::Run, |
| 89 &shell_context, | 50 &shell_context, |
| 90 app_urls)); | 51 app_urls)); |
| 91 | 52 |
| 92 message_loop.Run(); | 53 message_loop.Run(); |
| 93 } | 54 } |
| 94 | 55 |
| 95 return 0; | 56 return 0; |
| 96 } | 57 } |
| OLD | NEW |