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

Unified Diff: gin/modules/module_runner_delegate.cc

Issue 467263006: JavaScript Content Handler Version 0.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes per review feedback. Created 6 years, 3 months 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/modules/module_runner_delegate.cc
diff --git a/gin/modules/module_runner_delegate.cc b/gin/modules/module_runner_delegate.cc
index 16b5afd0303ba8a8819cbe54aef25ec8c4c24a84..fc6d390c78aaf71a6a0217fe11e15bfeccdb4821 100644
--- a/gin/modules/module_runner_delegate.cc
+++ b/gin/modules/module_runner_delegate.cc
@@ -4,6 +4,8 @@
#include "gin/modules/module_runner_delegate.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "gin/modules/module_registry.h"
#include "gin/object_template_builder.h"
#include "gin/public/context_holder.h"
@@ -18,8 +20,22 @@ ModuleRunnerDelegate::ModuleRunnerDelegate(
ModuleRunnerDelegate::~ModuleRunnerDelegate() {
}
+namespace {
+
+v8::Local<v8::Value> CallModuleGetter(ModuleGetter getter,
+ v8::Isolate* isolate) {
+ return getter(isolate);
+}
+
+} // namespace
+
void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id,
ModuleGetter getter) {
+ builtin_modules_[id] = base::Bind(CallModuleGetter, base::Unretained(getter));
Aaron Boodman 2014/09/11 05:24:53 It's not possible to just do: base::Bind(ModuleGe
hansmuller 2014/09/11 16:44:43 Sorry about that, I didn't need to insert the tram
+}
+
+void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id,
+ const ModuleGetterCallback& getter) {
builtin_modules_[id] = getter;
}
@@ -46,9 +62,10 @@ void ModuleRunnerDelegate::DidCreateContext(ShellRunner* runner) {
ModuleRegistry* registry = ModuleRegistry::From(context);
v8::Isolate* isolate = runner->GetContextHolder()->isolate();
+
for (BuiltinModuleMap::const_iterator it = builtin_modules_.begin();
it != builtin_modules_.end(); ++it) {
- registry->AddBuiltinModule(isolate, it->first, it->second(isolate));
+ registry->AddBuiltinModule(isolate, it->first, it->second.Run(isolate));
}
}

Powered by Google App Engine
This is Rietveld 408576698