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

Unified Diff: Source/bindings/core/v8/WrapperTypeInfo.h

Issue 456683002: bindings: Introduces type-check for the internal pointers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/core/v8/V8WindowShell.cpp ('k') | Source/bindings/core/v8/custom/V8ArrayBufferCustom.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/WrapperTypeInfo.h
diff --git a/Source/bindings/core/v8/WrapperTypeInfo.h b/Source/bindings/core/v8/WrapperTypeInfo.h
index 9019c91037a2af47fa38417dc74fc3a023cb81b0..f912abbeb7957bf4eeb48a756fb5ea59e584702e 100644
--- a/Source/bindings/core/v8/WrapperTypeInfo.h
+++ b/Source/bindings/core/v8/WrapperTypeInfo.h
@@ -41,6 +41,7 @@ namespace blink {
class ActiveDOMObject;
class EventTarget;
class Node;
+class ScriptWrappableBase;
static const int v8DOMWrapperTypeIndex = static_cast<int>(gin::kWrapperInfoIndex);
static const int v8DOMWrapperObjectIndex = static_cast<int>(gin::kEncodedValueIndex);
@@ -52,10 +53,10 @@ static const uint16_t v8DOMNodeClassId = 1;
static const uint16_t v8DOMObjectClassId = 2;
typedef v8::Handle<v8::FunctionTemplate> (*DomTemplateFunction)(v8::Isolate*);
-typedef void (*DerefObjectFunction)(void*);
+typedef void (*DerefObjectFunction)(ScriptWrappableBase* internalPointer);
typedef ActiveDOMObject* (*ToActiveDOMObjectFunction)(v8::Handle<v8::Object>);
typedef EventTarget* (*ToEventTargetFunction)(v8::Handle<v8::Object>);
-typedef void (*ResolveWrapperReachabilityFunction)(void*, const v8::Persistent<v8::Object>&, v8::Isolate*);
+typedef void (*ResolveWrapperReachabilityFunction)(ScriptWrappableBase* internalPointer, const v8::Persistent<v8::Object>&, v8::Isolate*);
typedef void (*InstallPerContextEnabledPrototypePropertiesFunction)(v8::Handle<v8::Object>, v8::Isolate*);
enum WrapperTypePrototype {
@@ -69,9 +70,9 @@ enum GCType {
RefCountedObject,
};
-inline void setObjectGroup(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate)
+inline void setObjectGroup(ScriptWrappableBase* internalPointer, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate)
{
- isolate->SetObjectGroupId(wrapper, v8::UniqueId(reinterpret_cast<intptr_t>(object)));
+ isolate->SetObjectGroupId(wrapper, v8::UniqueId(reinterpret_cast<intptr_t>(internalPointer)));
}
// This struct provides a way to store a bunch of information that is helpful when unwrapping
@@ -125,12 +126,12 @@ struct WrapperTypeInfo {
return toEventTargetFunction(object);
}
- void visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) const
+ void visitDOMWrapper(ScriptWrappableBase* internalPointer, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) const
{
if (!visitDOMWrapperFunction)
- setObjectGroup(object, wrapper, isolate);
+ setObjectGroup(internalPointer, wrapper, isolate);
else
- visitDOMWrapperFunction(object, wrapper, isolate);
+ visitDOMWrapperFunction(internalPointer, wrapper, isolate);
}
// This field must be the first member of the struct WrapperTypeInfo. This is also checked by a COMPILE_ASSERT() below.
@@ -166,14 +167,9 @@ inline T* getInternalField(v8::Handle<v8::Object> wrapper)
return static_cast<T*>(wrapper->GetAlignedPointerFromInternalField(offset));
}
-inline void* toNative(const v8::Persistent<v8::Object>& wrapper)
+inline ScriptWrappableBase* toInternalPointer(v8::Handle<v8::Object> wrapper)
{
- return getInternalField<void, v8DOMWrapperObjectIndex>(wrapper);
-}
-
-inline void* toNative(v8::Handle<v8::Object> wrapper)
-{
- return getInternalField<void, v8DOMWrapperObjectIndex>(wrapper);
+ return getInternalField<ScriptWrappableBase, v8DOMWrapperObjectIndex>(wrapper);
}
inline const WrapperTypeInfo* toWrapperTypeInfo(const v8::Persistent<v8::Object>& wrapper)
@@ -208,11 +204,11 @@ inline void releaseObject(v8::Handle<v8::Object> wrapper)
delete handle;
#else
ASSERT(typeInfo->derefObjectFunction);
- typeInfo->derefObjectFunction(toNative(wrapper));
+ typeInfo->derefObjectFunction(toInternalPointer(wrapper));
#endif
} else {
ASSERT(typeInfo->derefObjectFunction);
- typeInfo->derefObjectFunction(toNative(wrapper));
+ typeInfo->derefObjectFunction(toInternalPointer(wrapper));
}
}
« no previous file with comments | « Source/bindings/core/v8/V8WindowShell.cpp ('k') | Source/bindings/core/v8/custom/V8ArrayBufferCustom.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698