Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(500)

Side by Side Diff: Source/bindings/core/v8/V8DOMConfiguration.h

Issue 1278983003: Adding allocator annotations to blink classes and structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed patch conflict Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/bindings/core/v8/V8DOMActivityLogger.h ('k') | Source/bindings/core/v8/V8DOMWrapper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 19 matching lines...) Expand all
30 #define V8DOMConfiguration_h 30 #define V8DOMConfiguration_h
31 31
32 #include "bindings/core/v8/V8Binding.h" 32 #include "bindings/core/v8/V8Binding.h"
33 #include "bindings/core/v8/V8DOMWrapper.h" 33 #include "bindings/core/v8/V8DOMWrapper.h"
34 #include "core/CoreExport.h" 34 #include "core/CoreExport.h"
35 #include <v8.h> 35 #include <v8.h>
36 36
37 namespace blink { 37 namespace blink {
38 38
39 class CORE_EXPORT V8DOMConfiguration final { 39 class CORE_EXPORT V8DOMConfiguration final {
40 DISALLOW_ALLOCATION();
41 WTF_MAKE_NONCOPYABLE(V8DOMConfiguration);
40 public: 42 public:
41 // The following Configuration structs and install methods are used for 43 // The following Configuration structs and install methods are used for
42 // setting multiple properties on ObjectTemplate / FunctionTemplate, used 44 // setting multiple properties on ObjectTemplate / FunctionTemplate, used
43 // from the generated bindings initialization (ConfigureXXXTemplate). 45 // from the generated bindings initialization (ConfigureXXXTemplate).
44 // This greatly reduces the binary size by moving from code driven setup to 46 // This greatly reduces the binary size by moving from code driven setup to
45 // data table driven setup. 47 // data table driven setup.
46 48
47 enum ExposeConfiguration { 49 enum ExposeConfiguration {
48 ExposedToAllScripts, 50 ExposedToAllScripts,
49 OnlyExposedToPrivateScript, 51 OnlyExposedToPrivateScript,
50 }; 52 };
51 53
52 // Bitflags to show where the member will be defined. 54 // Bitflags to show where the member will be defined.
53 enum PropertyLocationConfiguration { 55 enum PropertyLocationConfiguration {
54 OnInstance = 1 << 0, 56 OnInstance = 1 << 0,
55 OnPrototype = 1 << 1, 57 OnPrototype = 1 << 1,
56 OnInterface = 1 << 2, 58 OnInterface = 1 << 2,
57 }; 59 };
58 60
59 enum HolderCheckConfiguration { 61 enum HolderCheckConfiguration {
60 CheckHolder, 62 CheckHolder,
61 DoNotCheckHolder, 63 DoNotCheckHolder,
62 }; 64 };
63 65
64 // AttributeConfiguration translates into calls to SetAccessor() on either 66 // AttributeConfiguration translates into calls to SetAccessor() on either
65 // the instance or the prototype ObjectTemplate, based on |instanceOrPrototy peConfiguration|. 67 // the instance or the prototype ObjectTemplate, based on |instanceOrPrototy peConfiguration|.
66 struct AttributeConfiguration { 68 struct AttributeConfiguration {
69 WTF_MAKE_NONCOPYABLE(AttributeConfiguration);
70 DISALLOW_ALLOCATION();
67 const char* const name; 71 const char* const name;
68 v8::AccessorNameGetterCallback getter; 72 v8::AccessorNameGetterCallback getter;
69 v8::AccessorNameSetterCallback setter; 73 v8::AccessorNameSetterCallback setter;
70 v8::AccessorNameGetterCallback getterForMainWorld; 74 v8::AccessorNameGetterCallback getterForMainWorld;
71 v8::AccessorNameSetterCallback setterForMainWorld; 75 v8::AccessorNameSetterCallback setterForMainWorld;
72 const WrapperTypeInfo* data; 76 const WrapperTypeInfo* data;
73 v8::AccessControl settings; 77 v8::AccessControl settings;
74 v8::PropertyAttribute attribute; 78 v8::PropertyAttribute attribute;
75 unsigned exposeConfiguration : 1; // ExposeConfiguration 79 unsigned exposeConfiguration : 1; // ExposeConfiguration
76 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura tion 80 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura tion
77 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration 81 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration
78 }; 82 };
79 83
80 static void installAttributes(v8::Isolate*, v8::Local<v8::ObjectTemplate> in stanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Attribute Configuration*, size_t attributeCount); 84 static void installAttributes(v8::Isolate*, v8::Local<v8::ObjectTemplate> in stanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Attribute Configuration*, size_t attributeCount);
81 85
82 static void installAttribute(v8::Isolate*, v8::Local<v8::ObjectTemplate> ins tanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const AttributeC onfiguration&); 86 static void installAttribute(v8::Isolate*, v8::Local<v8::ObjectTemplate> ins tanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTemplate, const AttributeC onfiguration&);
83 87
84 // AccessorConfiguration translates into calls to SetAccessorProperty() 88 // AccessorConfiguration translates into calls to SetAccessorProperty()
85 // on prototype ObjectTemplate. 89 // on prototype ObjectTemplate.
86 struct AccessorConfiguration { 90 struct AccessorConfiguration {
91 WTF_MAKE_NONCOPYABLE(AccessorConfiguration);
92 DISALLOW_ALLOCATION();
87 const char* const name; 93 const char* const name;
88 v8::FunctionCallback getter; 94 v8::FunctionCallback getter;
89 v8::FunctionCallback setter; 95 v8::FunctionCallback setter;
90 v8::FunctionCallback getterForMainWorld; 96 v8::FunctionCallback getterForMainWorld;
91 v8::FunctionCallback setterForMainWorld; 97 v8::FunctionCallback setterForMainWorld;
92 const WrapperTypeInfo* data; 98 const WrapperTypeInfo* data;
93 v8::AccessControl settings; 99 v8::AccessControl settings;
94 v8::PropertyAttribute attribute; 100 v8::PropertyAttribute attribute;
95 unsigned exposeConfiguration : 1; // ExposeConfiguration 101 unsigned exposeConfiguration : 1; // ExposeConfiguration
96 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura tion 102 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura tion
(...skipping 13 matching lines...) Expand all
110 ConstantTypeUnsignedLong, 116 ConstantTypeUnsignedLong,
111 ConstantTypeFloat, 117 ConstantTypeFloat,
112 ConstantTypeDouble, 118 ConstantTypeDouble,
113 ConstantTypeString 119 ConstantTypeString
114 }; 120 };
115 121
116 // ConstantConfiguration translates into calls to Set() for setting up an 122 // ConstantConfiguration translates into calls to Set() for setting up an
117 // object's constants. It sets the constant on both the FunctionTemplate and 123 // object's constants. It sets the constant on both the FunctionTemplate and
118 // the ObjectTemplate. PropertyAttributes is always ReadOnly. 124 // the ObjectTemplate. PropertyAttributes is always ReadOnly.
119 struct ConstantConfiguration { 125 struct ConstantConfiguration {
126 WTF_MAKE_NONCOPYABLE(ConstantConfiguration);
127 DISALLOW_ALLOCATION();
120 const char* const name; 128 const char* const name;
121 int ivalue; 129 int ivalue;
122 double dvalue; 130 double dvalue;
123 const char* const svalue; 131 const char* const svalue;
124 ConstantType type; 132 ConstantType type;
125 }; 133 };
126 134
127 // Constant installation 135 // Constant installation
128 // 136 //
129 // installConstants and installConstant are used for simple constants. They 137 // installConstants and installConstant are used for simple constants. They
130 // install constants using v8::Template::Set(), which results in a property 138 // install constants using v8::Template::Set(), which results in a property
131 // that is much faster to access from scripts. 139 // that is much faster to access from scripts.
132 // installConstantWithGetter is used when some C++ code needs to be executed 140 // installConstantWithGetter is used when some C++ code needs to be executed
133 // when the constant is accessed, e.g. to handle deprecation or measuring 141 // when the constant is accessed, e.g. to handle deprecation or measuring
134 // usage. The property appears the same to scripts, but is slower to access. 142 // usage. The property appears the same to scripts, but is slower to access.
135 static void installConstants(v8::Isolate*, v8::Local<v8::FunctionTemplate> f unctionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Consta ntConfiguration*, size_t constantCount); 143 static void installConstants(v8::Isolate*, v8::Local<v8::FunctionTemplate> f unctionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Consta ntConfiguration*, size_t constantCount);
136 144
137 static void installConstant(v8::Isolate*, v8::Local<v8::FunctionTemplate> fu nctionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Constan tConfiguration&); 145 static void installConstant(v8::Isolate*, v8::Local<v8::FunctionTemplate> fu nctionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, const Constan tConfiguration&);
138 146
139 static void installConstantWithGetter(v8::Isolate*, v8::Local<v8::FunctionTe mplate> functionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, con st char* name, v8::AccessorNameGetterCallback); 147 static void installConstantWithGetter(v8::Isolate*, v8::Local<v8::FunctionTe mplate> functionDescriptor, v8::Local<v8::ObjectTemplate> prototypeTemplate, con st char* name, v8::AccessorNameGetterCallback);
140 148
141 // MethodConfiguration translates into calls to Set() for setting up an 149 // MethodConfiguration translates into calls to Set() for setting up an
142 // object's callbacks. It sets the method on both the FunctionTemplate or 150 // object's callbacks. It sets the method on both the FunctionTemplate or
143 // the ObjectTemplate. 151 // the ObjectTemplate.
144 struct MethodConfiguration { 152 struct MethodConfiguration {
153 WTF_MAKE_NONCOPYABLE(MethodConfiguration);
154 DISALLOW_ALLOCATION();
145 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return v8At omicString(isolate, name); } 155 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return v8At omicString(isolate, name); }
146 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) cons t 156 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) cons t
147 { 157 {
148 return world.isMainWorld() && callbackForMainWorld ? callbackForMain World : callback; 158 return world.isMainWorld() && callbackForMainWorld ? callbackForMain World : callback;
149 } 159 }
150 160
151 const char* const name; 161 const char* const name;
152 v8::FunctionCallback callback; 162 v8::FunctionCallback callback;
153 v8::FunctionCallback callbackForMainWorld; 163 v8::FunctionCallback callbackForMainWorld;
154 int length; 164 int length;
155 ExposeConfiguration exposeConfiguration; 165 ExposeConfiguration exposeConfiguration;
156 }; 166 };
157 167
158 struct SymbolKeyedMethodConfiguration { 168 struct SymbolKeyedMethodConfiguration {
169 WTF_MAKE_NONCOPYABLE(SymbolKeyedMethodConfiguration);
170 DISALLOW_ALLOCATION();
159 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return getS ymbol(isolate); } 171 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return getS ymbol(isolate); }
160 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const 172 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const
161 { 173 {
162 return callback; 174 return callback;
163 } 175 }
164 176
165 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*); 177 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*);
166 v8::FunctionCallback callback; 178 v8::FunctionCallback callback;
167 // SymbolKeyedMethodConfiguration doesn't support per-world bindings. 179 // SymbolKeyedMethodConfiguration doesn't support per-world bindings.
168 int length; 180 int length;
(...skipping 12 matching lines...) Expand all
181 const AttributeConfiguration*, size_t attributeCount, 193 const AttributeConfiguration*, size_t attributeCount,
182 const AccessorConfiguration*, size_t accessorCount, 194 const AccessorConfiguration*, size_t accessorCount,
183 const MethodConfiguration*, size_t callbackCount); 195 const MethodConfiguration*, size_t callbackCount);
184 196
185 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrappe rTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*)); 197 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrappe rTypeInfo*, void (*)(v8::Local<v8::FunctionTemplate>, v8::Isolate*));
186 }; 198 };
187 199
188 } // namespace blink 200 } // namespace blink
189 201
190 #endif // V8DOMConfiguration_h 202 #endif // V8DOMConfiguration_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8DOMActivityLogger.h ('k') | Source/bindings/core/v8/V8DOMWrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698