diff options
author | hansmuller <hansmuller@chromium.org> | 2014-09-12 11:53:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-12 19:00:00 +0000 |
commit | b2cf607c2035b942e36ceed49cc770cf15fb1db2 (patch) | |
tree | ea3f513881335b3d7136653b255dd2dbc0daca19 /gin | |
parent | 56f97b71a4a88d7d016fcf4b1b3d37bc56691e35 (diff) | |
download | chromium_src-b2cf607c2035b942e36ceed49cc770cf15fb1db2.zip chromium_src-b2cf607c2035b942e36ceed49cc770cf15fb1db2.tar.gz chromium_src-b2cf607c2035b942e36ceed49cc770cf15fb1db2.tar.bz2 |
JavaScript Content Handler Version 0.0
BUG=403645
Review URL: https://codereview.chromium.org/467263006
Cr-Commit-Position: refs/heads/master@{#294621}
Diffstat (limited to 'gin')
-rw-r--r-- | gin/modules/module_runner_delegate.cc | 10 | ||||
-rw-r--r-- | gin/modules/module_runner_delegate.h | 7 |
2 files changed, 15 insertions, 2 deletions
diff --git a/gin/modules/module_runner_delegate.cc b/gin/modules/module_runner_delegate.cc index 16b5afd..9d8ce2e 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" @@ -20,6 +22,11 @@ ModuleRunnerDelegate::~ModuleRunnerDelegate() { void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id, ModuleGetter getter) { + builtin_modules_[id] = base::Bind(getter); +} + +void ModuleRunnerDelegate::AddBuiltinModule(const std::string& id, + const ModuleGetterCallback& getter) { builtin_modules_[id] = getter; } @@ -46,9 +53,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)); } } diff --git a/gin/modules/module_runner_delegate.h b/gin/modules/module_runner_delegate.h index 09d4582..df91f63 100644 --- a/gin/modules/module_runner_delegate.h +++ b/gin/modules/module_runner_delegate.h @@ -7,14 +7,17 @@ #include <map> +#include "base/callback.h" #include "base/compiler_specific.h" #include "gin/gin_export.h" #include "gin/modules/file_module_provider.h" #include "gin/shell_runner.h" +#include "v8/include/v8.h" namespace gin { typedef v8::Local<v8::Value> (*ModuleGetter)(v8::Isolate* isolate); +typedef base::Callback<v8::Local<v8::Value>(v8::Isolate*)> ModuleGetterCallback; // Emebedders that use AMD modules will probably want to use a RunnerDelegate // that inherits from ModuleRunnerDelegate. ModuleRunnerDelegate lets embedders @@ -26,12 +29,14 @@ class GIN_EXPORT ModuleRunnerDelegate : public ShellRunnerDelegate { virtual ~ModuleRunnerDelegate(); void AddBuiltinModule(const std::string& id, ModuleGetter getter); + void AddBuiltinModule(const std::string& id, + const ModuleGetterCallback& getter); protected: void AttemptToLoadMoreModules(Runner* runner); private: - typedef std::map<std::string, ModuleGetter> BuiltinModuleMap; + typedef std::map<std::string, ModuleGetterCallback> BuiltinModuleMap; // From ShellRunnerDelegate: virtual v8::Handle<v8::ObjectTemplate> GetGlobalTemplate( |