[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 1 | // 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_PER_ISOLATE_DATA_H_ | ||||
6 | #define GIN_PER_ISOLATE_DATA_H_ | ||||
7 | |||||
8 | #include <map> | ||||
9 | |||||
10 | #include "base/basictypes.h" | ||||
[email protected] | c07006b | 2013-11-20 03:01:44 | [diff] [blame] | 11 | #include "gin/public/wrapper_info.h" |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 12 | #include "v8/include/v8.h" |
13 | |||||
14 | namespace gin { | ||||
15 | |||||
16 | class PerIsolateData { | ||||
17 | public: | ||||
18 | explicit PerIsolateData(v8::Isolate* isolate); | ||||
19 | ~PerIsolateData(); | ||||
20 | |||||
21 | static PerIsolateData* From(v8::Isolate* isolate); | ||||
22 | |||||
[email protected] | e87f312 | 2013-11-12 00:41:27 | [diff] [blame] | 23 | void SetObjectTemplate(WrapperInfo* info, |
24 | v8::Local<v8::ObjectTemplate> object_template); | ||||
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 25 | void SetFunctionTemplate(WrapperInfo* info, |
26 | v8::Local<v8::FunctionTemplate> function_template); | ||||
[email protected] | e87f312 | 2013-11-12 00:41:27 | [diff] [blame] | 27 | |
28 | v8::Local<v8::ObjectTemplate> GetObjectTemplate(WrapperInfo* info); | ||||
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 29 | v8::Local<v8::FunctionTemplate> GetFunctionTemplate(WrapperInfo* info); |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 30 | |
31 | private: | ||||
32 | typedef std::map< | ||||
33 | WrapperInfo*, v8::Eternal<v8::ObjectTemplate> > ObjectTemplateMap; | ||||
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 34 | typedef std::map< |
35 | WrapperInfo*, v8::Eternal<v8::FunctionTemplate> > FunctionTemplateMap; | ||||
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 36 | |
37 | v8::Isolate* isolate_; | ||||
38 | ObjectTemplateMap object_templates_; | ||||
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 39 | FunctionTemplateMap function_templates_; |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 40 | |
41 | DISALLOW_COPY_AND_ASSIGN(PerIsolateData); | ||||
42 | }; | ||||
43 | |||||
44 | } // namespace gin | ||||
45 | |||||
46 | #endif // GIN_PER_ISOLATE_DATA_H_ |