| OLD | NEW | 
|---|
| 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  Loading... | 
| 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 UnsafePersistent<v8::Object> getWrapperPersistent(T* object, v8::Isol
     ate* isolate) | 
|  | 105     { | 
|  | 106         if (ScriptWrappable::wrapperCanBeStoredInObject(object) && !canExistInWo
     rker(object)) { | 
|  | 107             if (LIKELY(!DOMWrapperWorld::isolatedWorldsExist())) { | 
|  | 108                 UnsafePersistent<v8::Object> unsafePersistent = ScriptWrappable:
     :getUnsafeWrapperFromObject(object); | 
|  | 109                 // Security: always guard against malicious tampering. | 
|  | 110                 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(unsafePersistent.isEmpt
     y() || unsafePersistent.value()->GetAlignedPointerFromInternalField(v8DOMWrapper
     ObjectIndex) == V8T::toInternalPointer(object)); | 
|  | 111                 return unsafePersistent; | 
|  | 112             } | 
|  | 113         } | 
|  | 114         return current(isolate)->template getPersistent<V8T>(object, 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 UnsafePersistent<v8::Object> getPersistent(T* object, v8::Isolate* is
     olate) | 
|  | 145     { | 
|  | 146         if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == Mai
     nWorld) | 
|  | 147             return ScriptWrappable::getUnsafeWrapperFromObject(object); | 
|  | 148         return m_wrapperMap.get(V8T::toInternalPointer(object)); | 
|  | 149     } | 
|  | 150 | 
|  | 151     template<typename V8T, typename T> | 
| 130     inline bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, T* ob
     ject) | 152     inline bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, T* ob
     ject) | 
| 131     { | 153     { | 
| 132         if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == Mai
     nWorld) | 154         if (ScriptWrappable::wrapperCanBeStoredInObject(object) && m_type == Mai
     nWorld) | 
| 133             return ScriptWrappable::setReturnValue(returnValue, object); | 155             return ScriptWrappable::setReturnValue(returnValue, object); | 
| 134         return m_wrapperMap.setReturnValueFrom(returnValue, V8T::toInternalPoint
     er(object)); | 156         return m_wrapperMap.setReturnValueFrom(returnValue, V8T::toInternalPoint
     er(object)); | 
| 135     } | 157     } | 
| 136 | 158 | 
| 137     template<typename V8T, typename T> | 159     template<typename V8T, typename T> | 
| 138     inline bool containsWrapper(T* object) | 160     inline bool containsWrapper(T* object) | 
| 139     { | 161     { | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 173         return holder == *persistent; | 195         return holder == *persistent; | 
| 174     } | 196     } | 
| 175 | 197 | 
| 176     WrapperWorldType m_type; | 198     WrapperWorldType m_type; | 
| 177     DOMWrapperMap<void> m_wrapperMap; | 199     DOMWrapperMap<void> m_wrapperMap; | 
| 178 }; | 200 }; | 
| 179 | 201 | 
| 180 } // namespace WebCore | 202 } // namespace WebCore | 
| 181 | 203 | 
| 182 #endif // DOMDataStore_h | 204 #endif // DOMDataStore_h | 
| OLD | NEW | 
|---|