| 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/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "mojo/shell/child_process.h" | 10 #include "mojo/shell/child_process.h" |
| 11 #include "mojo/shell/context.h" | 11 #include "mojo/shell/context.h" |
| 12 #include "mojo/shell/init.h" | 12 #include "mojo/shell/init.h" |
| 13 #include "mojo/shell/run.h" | 13 #include "mojo/shell/run.h" |
| 14 #include "mojo/shell/switches.h" | 14 #include "mojo/shell/switches.h" |
| 15 #include "ui/gl/gl_surface.h" | 15 #include "ui/gl/gl_surface.h" |
| 16 | 16 |
| 17 int main(int argc, char** argv) { | 17 int main(int argc, char** argv) { |
| 18 base::AtExitManager at_exit; | 18 base::AtExitManager at_exit; |
| 19 base::CommandLine::Init(argc, argv); | 19 base::CommandLine::Init(argc, argv); |
| 20 mojo::shell::InitializeLogging(); | 20 mojo::shell::InitializeLogging(); |
| 21 | 21 |
| 22 // TODO(vtl): Unify parent and child process cases to the extent possible. | 22 // TODO(vtl): Unify parent and child process cases to the extent possible. |
| 23 if (scoped_ptr<mojo::shell::ChildProcess> child_process = | 23 if (scoped_ptr<mojo::shell::ChildProcess> child_process = |
| 24 mojo::shell::ChildProcess::Create( | 24 mojo::shell::ChildProcess::Create( |
| 25 *base::CommandLine::ForCurrentProcess())) { | 25 *base::CommandLine::ForCurrentProcess())) { |
| 26 child_process->Main(); | 26 child_process->Main(); |
| 27 } else { | 27 } else { |
| 28 gfx::GLSurface::InitializeOneOff(); | 28 gfx::GLSurface::InitializeOneOff(); |
| 29 | 29 |
| 30 base::MessageLoop message_loop; | |
| 31 mojo::shell::Context shell_context; | 30 mojo::shell::Context shell_context; |
| 31 { |
| 32 base::MessageLoop message_loop; |
| 33 shell_context.Init(); |
| 32 | 34 |
| 33 const base::CommandLine& command_line = | 35 const base::CommandLine& command_line = |
| 34 *base::CommandLine::ForCurrentProcess(); | 36 *base::CommandLine::ForCurrentProcess(); |
| 35 if (command_line.HasSwitch(switches::kOrigin)) { | 37 if (command_line.HasSwitch(switches::kOrigin)) { |
| 36 shell_context.mojo_url_resolver()->SetBaseURL( | 38 shell_context.mojo_url_resolver()->SetBaseURL( |
| 37 GURL(command_line.GetSwitchValueASCII(switches::kOrigin))); | 39 GURL(command_line.GetSwitchValueASCII(switches::kOrigin))); |
| 40 } |
| 41 |
| 42 std::vector<GURL> app_urls; |
| 43 base::CommandLine::StringVector args = command_line.GetArgs(); |
| 44 for (base::CommandLine::StringVector::const_iterator it = args.begin(); |
| 45 it != args.end(); |
| 46 ++it) |
| 47 app_urls.push_back(GURL(*it)); |
| 48 |
| 49 message_loop.PostTask(FROM_HERE, |
| 50 base::Bind(mojo::shell::Run, |
| 51 &shell_context, |
| 52 app_urls)); |
| 53 message_loop.Run(); |
| 38 } | 54 } |
| 39 | |
| 40 std::vector<GURL> app_urls; | |
| 41 base::CommandLine::StringVector args = command_line.GetArgs(); | |
| 42 for (base::CommandLine::StringVector::const_iterator it = args.begin(); | |
| 43 it != args.end(); | |
| 44 ++it) | |
| 45 app_urls.push_back(GURL(*it)); | |
| 46 | |
| 47 message_loop.PostTask(FROM_HERE, | |
| 48 base::Bind(mojo::shell::Run, | |
| 49 &shell_context, | |
| 50 app_urls)); | |
| 51 | |
| 52 message_loop.Run(); | |
| 53 } | 55 } |
| 54 | |
| 55 return 0; | 56 return 0; |
| 56 } | 57 } |
| OLD | NEW |