[Gin] Add documentation to explain how Gin works
This code is likely to evolve over time, but we've reached a stage where the
basic structure is mostly in place. This CL documents this structure so that
future developers will understand what we have in mind now.
[email protected]
BUG=none
Review URL: https://codereview.chromium.org/88913006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237485 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gin/per_isolate_data.h b/gin/per_isolate_data.h
index 7ed9da74..4801125 100644
--- a/gin/per_isolate_data.h
+++ b/gin/per_isolate_data.h
@@ -13,6 +13,8 @@
namespace gin {
+// There is one instance of PerIsolateData per v8::Isolate managed by Gin. This
+// class stores all the Gin-related data that varies per isolate.
class PerIsolateData {
public:
explicit PerIsolateData(v8::Isolate* isolate);
@@ -20,11 +22,18 @@
static PerIsolateData* From(v8::Isolate* isolate);
+ // Each isolate is associated with a collection of v8::ObjectTemplates and
+ // v8::FunctionTemplates. Typically these template objects are created
+ // lazily.
void SetObjectTemplate(WrapperInfo* info,
v8::Local<v8::ObjectTemplate> object_template);
void SetFunctionTemplate(WrapperInfo* info,
v8::Local<v8::FunctionTemplate> function_template);
+ // These are low-level functions for retrieving object or function templates
+ // stored in this object. Because these templates are often created lazily,
+ // most clients should call higher-level functions that know how to populate
+ // these templates if they haven't already been created.
v8::Local<v8::ObjectTemplate> GetObjectTemplate(WrapperInfo* info);
v8::Local<v8::FunctionTemplate> GetFunctionTemplate(WrapperInfo* info);
@@ -34,6 +43,8 @@
typedef std::map<
WrapperInfo*, v8::Eternal<v8::FunctionTemplate> > FunctionTemplateMap;
+ // PerIsolateData doesn't actually own |isolate_|. Instead, the isolate is
+ // owned by the IsolateHolder, which also owns the PerIsolateData.
v8::Isolate* isolate_;
ObjectTemplateMap object_templates_;
FunctionTemplateMap function_templates_;