blob: a66695f1a602097e5ab8c077719dc6630bdb7a61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GIN_MODULES_MODULE_RUNNER_DELEGATE_H_
#define GIN_MODULES_MODULE_RUNNER_DELEGATE_H_
#include <map>
#include "base/compiler_specific.h"
#include "gin/modules/file_module_provider.h"
#include "gin/runner.h"
namespace gin {
typedef v8::Local<v8::ObjectTemplate> (*ModuleTemplateGetter)(
v8::Isolate* isolate);
class ModuleRunnerDelegate : public RunnerDelegate {
public:
explicit ModuleRunnerDelegate(
const std::vector<base::FilePath>& search_paths);
virtual ~ModuleRunnerDelegate();
void AddBuiltinModule(const std::string& id, ModuleTemplateGetter templ);
private:
typedef std::map<std::string, ModuleTemplateGetter> BuiltinModuleMap;
// From RunnerDelegate:
virtual v8::Handle<v8::ObjectTemplate> GetGlobalTemplate(
Runner* runner) OVERRIDE;
virtual void DidCreateContext(Runner* runner) OVERRIDE;
virtual void DidRunScript(Runner* runner,
v8::Handle<v8::Script> script) OVERRIDE;
BuiltinModuleMap builtin_modules_;
FileModuleProvider module_provider_;
DISALLOW_COPY_AND_ASSIGN(ModuleRunnerDelegate);
};
} // namespace gin
#endif // GIN_MODULES_MODULE_RUNNER_DELEGATE_H_
|