| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "mojo/edk/embedder/embedder.h" | 11 #include "mojo/edk/embedder/embedder.h" |
| 12 #include "mojo/edk/embedder/simple_platform_support.h" | 12 #include "mojo/edk/embedder/simple_platform_support.h" |
| 13 #include "mojo/shell/external_application_registrar_connection.h" | 13 #include "mojo/shell/external_application_registrar_connection.h" |
| 14 #include "mojo/shell/in_process_dynamic_service_runner.h" | 14 #include "mojo/shell/in_process_dynamic_service_runner.h" |
| 15 #include "mojo/shell/init.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 const char kAppPath[] = "app-path"; | 19 const char kAppPath[] = "app-path"; |
| 19 const char kAppURL[] = "app-url"; | 20 const char kAppURL[] = "app-url"; |
| 20 const char kShellPath[] = "shell-path"; | 21 const char kShellPath[] = "shell-path"; |
| 21 } | 22 } |
| 22 | 23 |
| 23 class Launcher { | 24 class Launcher { |
| 24 public: | 25 public: |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
| 93 int main(int argc, wchar_t** argv) { | 94 int main(int argc, wchar_t** argv) { |
| 94 #else | 95 #else |
| 95 int main(int argc, char** argv) { | 96 int main(int argc, char** argv) { |
| 96 #endif | 97 #endif |
| 97 base::AtExitManager at_exit; | 98 base::AtExitManager at_exit; |
| 98 mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( | 99 mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( |
| 99 new mojo::embedder::SimplePlatformSupport())); | 100 new mojo::embedder::SimplePlatformSupport())); |
| 100 base::CommandLine command_line(argc, argv); | 101 |
| 101 Launcher launcher(&command_line); | 102 base::CommandLine::Init(argc, argv); |
| 103 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 104 mojo::shell::InitializeLogging(); |
| 105 |
| 106 Launcher launcher(command_line); |
| 102 int result = launcher.Connect(); | 107 int result = launcher.Connect(); |
| 103 if (result < 0) { | 108 if (result < 0) { |
| 104 LOG(ERROR) << "Error(" << result << ") connecting on socket " | 109 LOG(ERROR) << "Error(" << result << ") connecting on socket " |
| 105 << command_line.GetSwitchValueASCII(kShellPath); | 110 << command_line->GetSwitchValueASCII(kShellPath); |
| 106 return MOJO_RESULT_INVALID_ARGUMENT; | 111 return MOJO_RESULT_INVALID_ARGUMENT; |
| 107 } | 112 } |
| 108 | 113 |
| 109 if (!launcher.Register()) { | 114 if (!launcher.Register()) { |
| 110 LOG(ERROR) << "Error registering " | 115 LOG(ERROR) << "Error registering " |
| 111 << command_line.GetSwitchValueASCII(kAppURL); | 116 << command_line->GetSwitchValueASCII(kAppURL); |
| 112 return MOJO_RESULT_INVALID_ARGUMENT; | 117 return MOJO_RESULT_INVALID_ARGUMENT; |
| 113 } | 118 } |
| 114 | 119 |
| 115 launcher.Run(); | 120 launcher.Run(); |
| 116 return MOJO_RESULT_OK; | 121 return MOJO_RESULT_OK; |
| 117 } | 122 } |
| OLD | NEW |