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
3 // found in the LICENSE file.
5 #include "base/message_loop/message_loop.h"
6 #include "gin/public/isolate_holder.h"
7 #include "mojo/apps/js/mojo_runner_delegate.h"
8 #include "mojo/public/cpp/gles2/gles2.h"
9 #include "mojo/public/cpp/system/core.h"
10 #include "mojo/public/cpp/system/macros.h"
16 #define MOJO_APPS_JS_EXPORT __declspec(dllexport)
19 #define MOJO_APPS_JS_EXPORT __attribute__((visibility("default")))
25 void Start(MojoHandle pipe, const std::string& module) {
26 base::MessageLoop loop;
28 gin::IsolateHolder instance(gin::IsolateHolder::kStrictMode);
29 MojoRunnerDelegate delegate;
30 gin::ShellRunner runner(&delegate, instance.isolate());
31 delegate.Start(&runner, pipe, module);
33 base::MessageLoop::current()->Run();
39 extern "C" MOJO_APPS_JS_EXPORT MojoResult CDECL MojoMain(MojoHandle pipe) {
40 mojo::GLES2Initializer gles2;
41 mojo::apps::Start(pipe, "mojo/apps/js/main");
42 return MOJO_RESULT_OK;