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