| OLD | NEW |
| 1 // Copyright 2013 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/message_loop/message_loop.h" | 5 #include "base/i18n/icu_util.h" |
| 6 #include "gin/public/isolate_holder.h" | 6 #include "mojo/apps/js/js_content_handler_app.h" |
| 7 #include "mojo/apps/js/mojo_runner_delegate.h" | 7 #include "mojo/public/c/system/main.h" |
| 8 #include "mojo/public/cpp/system/core.h" | 8 #include "mojo/public/cpp/application/application_runner_chromium.h" |
| 9 #include "mojo/public/cpp/system/macros.h" | |
| 10 | 9 |
| 11 #if defined(WIN32) | |
| 12 #if !defined(CDECL) | |
| 13 #define CDECL __cdecl | |
| 14 #endif | |
| 15 #define MOJO_APPS_JS_EXPORT __declspec(dllexport) | |
| 16 #else | |
| 17 #define CDECL | |
| 18 #define MOJO_APPS_JS_EXPORT __attribute__((visibility("default"))) | |
| 19 #endif | |
| 20 | 10 |
| 21 namespace mojo { | 11 MojoResult MojoMain(MojoHandle shell_handle) { |
| 22 namespace apps { | 12 base::i18n::InitializeICU(); |
| 23 | 13 mojo::ApplicationRunnerChromium runner(new mojo::apps::JSContentHandlerApp()); |
| 24 void Start(MojoHandle pipe, const std::string& module) { | 14 return runner.Run(shell_handle); |
| 25 base::MessageLoop loop; | |
| 26 | |
| 27 gin::IsolateHolder instance(gin::IsolateHolder::kStrictMode); | |
| 28 MojoRunnerDelegate delegate; | |
| 29 gin::ShellRunner runner(&delegate, instance.isolate()); | |
| 30 delegate.Start(&runner, pipe, module); | |
| 31 | |
| 32 base::MessageLoop::current()->Run(); | |
| 33 } | 15 } |
| 34 | 16 |
| 35 } // namespace apps | |
| 36 } // namespace mojo | |
| 37 | |
| 38 extern "C" MOJO_APPS_JS_EXPORT MojoResult CDECL MojoMain(MojoHandle pipe) { | |
| 39 mojo::apps::Start(pipe, "mojo/apps/js/main"); | |
| 40 return MOJO_RESULT_OK; | |
| 41 } | |
| OLD | NEW |