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

Unified Diff: Source/bindings/v8/DOMDataStore.h

Issue 26792002: Reland: Reland: Implement new Blink IDL attribute [SetReference] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: mark NodeFilter Dependent Created 7 years, 2 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/tests/results/V8TestInterface.cpp ('k') | Source/bindings/v8/DOMWrapperMap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/DOMDataStore.h
diff --git a/Source/bindings/v8/DOMDataStore.h b/Source/bindings/v8/DOMDataStore.h
index 64b040d3f2e9b062eca45b3968dc16d4299658bf..154d8d8d1ba09d407e5ce8afe1ac3631045edb46 100644
--- a/Source/bindings/v8/DOMDataStore.h
+++ b/Source/bindings/v8/DOMDataStore.h
@@ -101,6 +101,20 @@ public:
}
template<typename V8T, typename T>
+ static void setWrapperReference(const v8::Persistent<v8::Object>& parent, T* child, v8::Isolate* isolate)
+ {
+ if (ScriptWrappable::wrapperCanBeStoredInObject(child) && !canExistInWorker(child)) {
+ if (LIKELY(!DOMWrapperWorld::isolatedWorldsExist())) {
+ UnsafePersistent<v8::Object> unsafePersistent = ScriptWrappable::getUnsafeWrapperFromObject(child);
+ // Security: always guard against malicious tampering.
+ RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(unsafePersistent.isEmpty() || unsafePersistent.value()->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == V8T::toInternalPointer(child));
+ unsafePersistent.setReferenceFrom(parent, isolate);
+ }
+ }
+ current(isolate)->template setReference<V8T>(parent, child, isolate);
+ }
+
+ template<typename V8T, typename T>
static void setWrapper(T* object, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperConfiguration& configuration)
{
if (ScriptWrappable::wrapperCanBeStoredInObject(object) && !canExistInWorker(object)) {
@@ -127,6 +141,16 @@ public:
}
template<typename V8T, typename T>
+ inline void setReference(const v8::Persistent<v8::Object>& parent, T* child, v8::Isolate* isolate)
+ {
+ if (ScriptWrappable::wrapperCanBeStoredInObject(child) && m_type == MainWorld) {
+ ScriptWrappable::getUnsafeWrapperFromObject(child).setReferenceFrom(parent, isolate);
+ return;
+ }
+ m_wrapperMap.setReference(parent, V8T::toInternalPointer(child), isolate);
+ }
+
+ template<typename V8T, typename T>
inline bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, T* object)
{
if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == MainWorld)
« no previous file with comments | « Source/bindings/tests/results/V8TestInterface.cpp ('k') | Source/bindings/v8/DOMWrapperMap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698