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

Unified Diff: gin/runner.cc

Issue 62333018: Implement Asynchronous Module Definition API for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar testing 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
Index: gin/runner.cc
diff --git a/gin/runner.cc b/gin/runner.cc
index ec701b7e5a320ced9cf577a8d2bfaf867ebb7629..4b0b6f9b69d3562733b319439e2904915198bc1b 100644
--- a/gin/runner.cc
+++ b/gin/runner.cc
@@ -7,55 +7,52 @@
#include "gin/converter.h"
using v8::Context;
-using v8::Function;
using v8::Handle;
using v8::HandleScope;
using v8::Isolate;
-using v8::Local;
using v8::Object;
+using v8::ObjectTemplate;
using v8::Script;
-using v8::String;
-using v8::Value;
namespace gin {
+RunnerDelegate::RunnerDelegate() {
+}
+
RunnerDelegate::~RunnerDelegate() {
}
+Handle<ObjectTemplate> RunnerDelegate::GetGlobalTemplate(Runner* runner) {
+ return Handle<ObjectTemplate>();
+}
+
+void RunnerDelegate::DidCreateContext(Runner* runner) {
+}
+
Runner::Runner(RunnerDelegate* delegate, Isolate* isolate)
- : delegate_(delegate),
- isolate_(isolate) {
- HandleScope handle_scope(isolate_);
- context_.Reset(isolate_, Context::New(isolate_));
+ : ContextHolder(isolate),
+ delegate_(delegate) {
+ HandleScope handle_scope(isolate);
+ SetContext(Context::New(isolate, NULL, delegate_->GetGlobalTemplate(this)));
+
+ v8::Context::Scope scope(context());
+ delegate_->DidCreateContext(this);
}
Runner::~Runner() {
- // TODO(abarth): Figure out how to set kResetInDestructor to true.
- context_.Reset();
}
-void Runner::Run(Handle<Script> script) {
- script->Run();
- Handle<Function> main = GetMain();
- if (main.IsEmpty())
- return;
- Handle<Value> argv[] = { delegate_->CreateRootObject(this) };
- main->Call(global(), 1, argv);
+void Runner::Run(const std::string& script) {
+ Run(Script::New(StringToV8(isolate(), script)));
}
-v8::Handle<v8::Function> Runner::GetMain() {
- Handle<Value> property = global()->Get(StringToSymbol(isolate_, "main"));
- if (property.IsEmpty())
- return v8::Handle<v8::Function>();
- Handle<Function> main;
- if (!ConvertFromV8(property, &main))
- return v8::Handle<v8::Function>();
- return main;
+void Runner::Run(Handle<Script> script) {
+ script->Run();
}
Runner::Scope::Scope(Runner* runner)
- : handle_scope_(runner->isolate_),
- scope_(Local<Context>::New(runner->isolate_, runner->context_)) {
+ : handle_scope_(runner->isolate()),
+ scope_(runner->context()) {
}
Runner::Scope::~Scope() {
« gin/modules/module_registry.cc ('K') | « gin/runner.h ('k') | gin/runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698