#ifndef GIN_MODULES_MODULE_RUNNER_DELEGATE_H_
#define GIN_MODULES_MODULE_RUNNER_DELEGATE_H_
#include <map>
#include "base/compiler_specific.h"
#include "gin/gin_export.h"
#include "gin/modules/file_module_provider.h"
#include "gin/shell_runner.h"
namespace gin {
typedef v8::Local<v8::Value> (*ModuleGetter)(v8::Isolate* isolate);
class GIN_EXPORT ModuleRunnerDelegate : public ShellRunnerDelegate {
public:
explicit ModuleRunnerDelegate(
const std::vector<base::FilePath>& search_paths);
virtual ~ModuleRunnerDelegate();
void AddBuiltinModule(const std::string& id, ModuleGetter getter);
protected:
void AttemptToLoadMoreModules(Runner* runner);
private:
typedef std::map<std::string, ModuleGetter> BuiltinModuleMap;
virtual v8::Handle<v8::ObjectTemplate> GetGlobalTemplate(
ShellRunner* runner,
v8::Isolate* isolate) OVERRIDE;
virtual void DidCreateContext(ShellRunner* runner) OVERRIDE;
virtual void DidRunScript(ShellRunner* runner) OVERRIDE;
BuiltinModuleMap builtin_modules_;
FileModuleProvider module_provider_;
DISALLOW_COPY_AND_ASSIGN(ModuleRunnerDelegate);
};
}
#endif