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

Side by Side 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, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/tests/results/V8TestInterface.cpp ('k') | Source/bindings/v8/DOMWrapperMap.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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 v8::Handle<v8::Object> result = ScriptWrappable::getUnsafeWrappe rFromObject(object).newLocal(isolate); 94 v8::Handle<v8::Object> result = ScriptWrappable::getUnsafeWrappe rFromObject(object).newLocal(isolate);
95 // Security: always guard against malicious tampering. 95 // Security: always guard against malicious tampering.
96 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(result.IsEmpty() || res ult->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == V8T::toInter nalPointer(object)); 96 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(result.IsEmpty() || res ult->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == V8T::toInter nalPointer(object));
97 return result; 97 return result;
98 } 98 }
99 } 99 }
100 return current(isolate)->template get<V8T>(object, isolate); 100 return current(isolate)->template get<V8T>(object, isolate);
101 } 101 }
102 102
103 template<typename V8T, typename T> 103 template<typename V8T, typename T>
104 static void setWrapperReference(const v8::Persistent<v8::Object>& parent, T* child, v8::Isolate* isolate)
105 {
106 if (ScriptWrappable::wrapperCanBeStoredInObject(child) && !canExistInWor ker(child)) {
107 if (LIKELY(!DOMWrapperWorld::isolatedWorldsExist())) {
108 UnsafePersistent<v8::Object> unsafePersistent = ScriptWrappable: :getUnsafeWrapperFromObject(child);
109 // Security: always guard against malicious tampering.
110 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(unsafePersistent.isEmpt y() || unsafePersistent.value()->GetAlignedPointerFromInternalField(v8DOMWrapper ObjectIndex) == V8T::toInternalPointer(child));
111 unsafePersistent.setReferenceFrom(parent, isolate);
112 }
113 }
114 current(isolate)->template setReference<V8T>(parent, child, isolate);
115 }
116
117 template<typename V8T, typename T>
104 static void setWrapper(T* object, v8::Handle<v8::Object> wrapper, v8::Isolat e* isolate, const WrapperConfiguration& configuration) 118 static void setWrapper(T* object, v8::Handle<v8::Object> wrapper, v8::Isolat e* isolate, const WrapperConfiguration& configuration)
105 { 119 {
106 if (ScriptWrappable::wrapperCanBeStoredInObject(object) && !canExistInWo rker(object)) { 120 if (ScriptWrappable::wrapperCanBeStoredInObject(object) && !canExistInWo rker(object)) {
107 if (LIKELY(!DOMWrapperWorld::isolatedWorldsExist())) { 121 if (LIKELY(!DOMWrapperWorld::isolatedWorldsExist())) {
108 ScriptWrappable::setWrapperInObject(object, wrapper, isolate, co nfiguration); 122 ScriptWrappable::setWrapperInObject(object, wrapper, isolate, co nfiguration);
109 return; 123 return;
110 } 124 }
111 } 125 }
112 return current(isolate)->template set<V8T>(object, wrapper, isolate, con figuration); 126 return current(isolate)->template set<V8T>(object, wrapper, isolate, con figuration);
113 } 127 }
114 128
115 template<typename V8T, typename T> 129 template<typename V8T, typename T>
116 static bool containsWrapper(T* object, v8::Isolate* isolate) 130 static bool containsWrapper(T* object, v8::Isolate* isolate)
117 { 131 {
118 return current(isolate)->template containsWrapper<V8T>(object); 132 return current(isolate)->template containsWrapper<V8T>(object);
119 } 133 }
120 134
121 template<typename V8T, typename T> 135 template<typename V8T, typename T>
122 inline v8::Handle<v8::Object> get(T* object, v8::Isolate* isolate) 136 inline v8::Handle<v8::Object> get(T* object, v8::Isolate* isolate)
123 { 137 {
124 if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == Mai nWorld) 138 if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == Mai nWorld)
125 return ScriptWrappable::getUnsafeWrapperFromObject(object).newLocal( isolate); 139 return ScriptWrappable::getUnsafeWrapperFromObject(object).newLocal( isolate);
126 return m_wrapperMap.newLocal(V8T::toInternalPointer(object), isolate); 140 return m_wrapperMap.newLocal(V8T::toInternalPointer(object), isolate);
127 } 141 }
128 142
129 template<typename V8T, typename T> 143 template<typename V8T, typename T>
144 inline void setReference(const v8::Persistent<v8::Object>& parent, T* child, v8::Isolate* isolate)
145 {
146 if (ScriptWrappable::wrapperCanBeStoredInObject(child) && m_type == Main World) {
147 ScriptWrappable::getUnsafeWrapperFromObject(child).setReferenceFrom( parent, isolate);
148 return;
149 }
150 m_wrapperMap.setReference(parent, V8T::toInternalPointer(child), isolate );
151 }
152
153 template<typename V8T, typename T>
130 inline bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, T* ob ject) 154 inline bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, T* ob ject)
131 { 155 {
132 if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == Mai nWorld) 156 if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == Mai nWorld)
133 return ScriptWrappable::setReturnValue(returnValue, object); 157 return ScriptWrappable::setReturnValue(returnValue, object);
134 return m_wrapperMap.setReturnValueFrom(returnValue, V8T::toInternalPoint er(object)); 158 return m_wrapperMap.setReturnValueFrom(returnValue, V8T::toInternalPoint er(object));
135 } 159 }
136 160
137 template<typename V8T, typename T> 161 template<typename V8T, typename T>
138 inline bool containsWrapper(T* object) 162 inline bool containsWrapper(T* object)
139 { 163 {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return holder == *unsafePersistent.persistent(); 197 return holder == *unsafePersistent.persistent();
174 } 198 }
175 199
176 WrapperWorldType m_type; 200 WrapperWorldType m_type;
177 DOMWrapperMap<void> m_wrapperMap; 201 DOMWrapperMap<void> m_wrapperMap;
178 }; 202 };
179 203
180 } // namespace WebCore 204 } // namespace WebCore
181 205
182 #endif // DOMDataStore_h 206 #endif // DOMDataStore_h
OLDNEW
« 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