blob: a66695f1a602097e5ab8c077719dc6630bdb7a61 [file] [log] [blame]
[email protected]855ab432013-11-18 17:09:361// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef GIN_MODULES_MODULE_RUNNER_DELEGATE_H_
6#define GIN_MODULES_MODULE_RUNNER_DELEGATE_H_
7
[email protected]fd5cf7fd2013-11-18 23:05:128#include <map>
9
[email protected]855ab432013-11-18 17:09:3610#include "base/compiler_specific.h"
11#include "gin/modules/file_module_provider.h"
12#include "gin/runner.h"
13
14namespace gin {
15
[email protected]fd5cf7fd2013-11-18 23:05:1216typedef v8::Local<v8::ObjectTemplate> (*ModuleTemplateGetter)(
17 v8::Isolate* isolate);
18
[email protected]855ab432013-11-18 17:09:3619class ModuleRunnerDelegate : public RunnerDelegate {
20 public:
[email protected]467834b32013-11-22 07:30:5521 explicit ModuleRunnerDelegate(
22 const std::vector<base::FilePath>& search_paths);
[email protected]855ab432013-11-18 17:09:3623 virtual ~ModuleRunnerDelegate();
24
[email protected]fd5cf7fd2013-11-18 23:05:1225 void AddBuiltinModule(const std::string& id, ModuleTemplateGetter templ);
26
[email protected]855ab432013-11-18 17:09:3627 private:
[email protected]fd5cf7fd2013-11-18 23:05:1228 typedef std::map<std::string, ModuleTemplateGetter> BuiltinModuleMap;
29
[email protected]855ab432013-11-18 17:09:3630 // From RunnerDelegate:
31 virtual v8::Handle<v8::ObjectTemplate> GetGlobalTemplate(
32 Runner* runner) OVERRIDE;
[email protected]fd5cf7fd2013-11-18 23:05:1233 virtual void DidCreateContext(Runner* runner) OVERRIDE;
[email protected]855ab432013-11-18 17:09:3634 virtual void DidRunScript(Runner* runner,
35 v8::Handle<v8::Script> script) OVERRIDE;
36
[email protected]fd5cf7fd2013-11-18 23:05:1237 BuiltinModuleMap builtin_modules_;
[email protected]855ab432013-11-18 17:09:3638 FileModuleProvider module_provider_;
39
40 DISALLOW_COPY_AND_ASSIGN(ModuleRunnerDelegate);
41};
42
43} // namespace gin
44
45#endif // GIN_MODULES_MODULE_RUNNER_DELEGATE_H_