diff options
Diffstat (limited to 'mojo/apps/js/main.cc')
-rw-r--r-- | mojo/apps/js/main.cc | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/mojo/apps/js/main.cc b/mojo/apps/js/main.cc index 1ad084b..0706182 100644 --- a/mojo/apps/js/main.cc +++ b/mojo/apps/js/main.cc @@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/message_loop/message_loop.h" #include "gin/public/isolate_holder.h" +#include "mojo/apps/js/bootstrap.h" +#include "mojo/apps/js/mojo_runner_delegate.h" +#include "mojo/common/bindings_support_impl.h" #include "mojo/public/system/core_cpp.h" #include "mojo/public/system/macros.h" @@ -16,8 +20,32 @@ #define MOJO_APPS_JS_EXPORT __attribute__((visibility("default"))) #endif -extern "C" MOJO_APPS_JS_EXPORT MojoResult CDECL MojoMain(MojoHandle pipe) { +namespace mojo { +namespace apps { + +void RunMojoJS(MojoHandle pipe) { gin::IsolateHolder instance; - // TODO(abarth): Load JS off the network and execute it. + Bootstrap::SetInitialHandle(pipe); + + MojoRunnerDelegate delegate; + gin::Runner runner(&delegate, instance.isolate()); + + { + gin::Runner::Scope scope(&runner); + runner.Run("define(['mojo/apps/js/main'], function(main) {});"); + } + + base::MessageLoop::current()->Run(); +} + +} // namespace apps +} // namespace mojo + +extern "C" MOJO_APPS_JS_EXPORT MojoResult CDECL MojoMain(MojoHandle pipe) { + base::MessageLoop loop; + mojo::common::BindingsSupportImpl bindings_support; + mojo::BindingsSupport::Set(&bindings_support); + mojo::apps::RunMojoJS(pipe); + mojo::BindingsSupport::Set(NULL); return MOJO_RESULT_OK; } |