Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1509)

Unified Diff: mojo/apps/js/mojo_runner_delegate.cc

Issue 90203002: [Mojo] Remove static "bootstrap" state in mojo_js (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CHECK, CHECK, CHECK Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/apps/js/mojo_runner_delegate.h ('k') | mojo/apps/js/threading.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/apps/js/mojo_runner_delegate.cc
diff --git a/mojo/apps/js/mojo_runner_delegate.cc b/mojo/apps/js/mojo_runner_delegate.cc
index 610ede4090006d18bdd123983bb888f201b87d59..c74bf5018215046e53bec475bd02b1753e509c94 100644
--- a/mojo/apps/js/mojo_runner_delegate.cc
+++ b/mojo/apps/js/mojo_runner_delegate.cc
@@ -4,11 +4,13 @@
#include "mojo/apps/js/mojo_runner_delegate.h"
+#include "base/bind.h"
#include "base/path_service.h"
+#include "gin/converter.h"
#include "gin/modules/console.h"
#include "gin/modules/module_registry.h"
#include "gin/try_catch.h"
-#include "mojo/apps/js/bootstrap.h"
+#include "mojo/apps/js/threading.h"
#include "mojo/public/bindings/js/core.h"
#include "mojo/public/bindings/js/support.h"
@@ -27,11 +29,22 @@ std::vector<base::FilePath> GetModuleSearchPaths() {
return search_paths;
}
+void StartCallback(base::WeakPtr<gin::Runner> runner,
+ MojoHandle pipe,
+ v8::Handle<v8::Value> module) {
+ v8::Isolate* isolate = runner->isolate();
+ v8::Handle<v8::Function> start;
+ CHECK(gin::ConvertFromV8(isolate, module, &start));
+
+ v8::Handle<v8::Value> args[] = { gin::ConvertToV8(isolate, pipe) };
+ runner->Call(start, runner->global(), 1, args);
+}
+
} // namespace
MojoRunnerDelegate::MojoRunnerDelegate()
: ModuleRunnerDelegate(GetModuleSearchPaths()) {
- AddBuiltinModule(Bootstrap::kModuleName, Bootstrap::GetTemplate);
+ AddBuiltinModule(Threading::kModuleName, Threading::GetTemplate);
AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetTemplate);
AddBuiltinModule(js::Core::kModuleName, js::Core::GetTemplate);
AddBuiltinModule(js::Support::kModuleName, js::Support::GetTemplate);
@@ -40,6 +53,16 @@ MojoRunnerDelegate::MojoRunnerDelegate()
MojoRunnerDelegate::~MojoRunnerDelegate() {
}
+void MojoRunnerDelegate::Start(gin::Runner* runner,
+ MojoHandle pipe,
+ const std::string& module) {
+ gin::Runner::Scope scope(runner);
+ gin::ModuleRegistry* registry = gin::ModuleRegistry::From(runner->context());
+ registry->LoadModule(runner->isolate(), module,
+ base::Bind(StartCallback, runner->GetWeakPtr(), pipe));
+ AttemptToLoadMoreModules(runner);
+}
+
void MojoRunnerDelegate::UnhandledException(gin::Runner* runner,
gin::TryCatch& try_catch) {
gin::ModuleRunnerDelegate::UnhandledException(runner, try_catch);
« no previous file with comments | « mojo/apps/js/mojo_runner_delegate.h ('k') | mojo/apps/js/threading.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698