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

Unified Diff: gin/modules/module_runner_delegate.cc

Issue 69843003: Implement Mojo message codec in JavaScript (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Aaron's comments 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 | « gin/modules/module_runner_delegate.h ('k') | gin/test/file_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/modules/module_runner_delegate.cc
diff --git a/gin/modules/module_runner_delegate.cc b/gin/modules/module_runner_delegate.cc
index e029a93fda8c0feed797ffc1124dd1f474e976df..50b9f5e71db7859ae3382f2139eed3a84e691c33 100644
--- a/gin/modules/module_runner_delegate.cc
+++ b/gin/modules/module_runner_delegate.cc
@@ -15,6 +15,11 @@ ModuleRunnerDelegate::ModuleRunnerDelegate(const base::FilePath& module_base)
ModuleRunnerDelegate::~ModuleRunnerDelegate() {
}
+void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id,
+ ModuleTemplateGetter templ) {
+ builtin_modules_[id] = templ;
+}
+
v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate(
Runner* runner) {
v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
@@ -22,6 +27,19 @@ v8::Handle<v8::ObjectTemplate> ModuleRunnerDelegate::GetGlobalTemplate(
return templ;
}
+void ModuleRunnerDelegate::DidCreateContext(Runner* runner) {
+ RunnerDelegate::DidCreateContext(runner);
+
+ v8::Handle<v8::Context> context = runner->context();
+ ModuleRegistry* registry = ModuleRegistry::From(context);
+
+ for (BuiltinModuleMap::const_iterator it = builtin_modules_.begin();
+ it != builtin_modules_.end(); ++it) {
+ registry->AddBuiltinModule(runner->isolate(), it->first,
+ it->second(runner->isolate()));
+ }
+}
+
void ModuleRunnerDelegate::DidRunScript(Runner* runner,
v8::Handle<v8::Script> script) {
ModuleRegistry* registry = ModuleRegistry::From(runner->context());
« no previous file with comments | « gin/modules/module_runner_delegate.h ('k') | gin/test/file_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698