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

Side by Side Diff: Source/bindings/v8/DOMDataStore.h

Issue 14623025: Revert "Revert "Replace ScriptWrappable pointer masking with back-pointer check in DOMDataStore."" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/v8/ScriptWrappable.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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 template<typename T, typename HolderContainer, typename Wrappable> 54 template<typename T, typename HolderContainer, typename Wrappable>
55 static v8::Handle<v8::Object> getWrapperFast(T* object, const HolderContaine r& container, Wrappable* holder) 55 static v8::Handle<v8::Object> getWrapperFast(T* object, const HolderContaine r& container, Wrappable* holder)
56 { 56 {
57 // What we'd really like to check here is whether we're in the 57 // What we'd really like to check here is whether we're in the
58 // main world or in an isolated world. The fastest way to do that 58 // main world or in an isolated world. The fastest way to do that
59 // is to check that there is no isolated world and the 'object' 59 // is to check that there is no isolated world and the 'object'
60 // is an object that can exist in the main world. The second fastest 60 // is an object that can exist in the main world. The second fastest
61 // way is to check whether the wrappable's wrapper is the same as 61 // way is to check whether the wrappable's wrapper is the same as
62 // the holder. 62 // the holder.
63 if ((!DOMWrapperWorld::isolatedWorldsExist() && !canExistInWorker(object )) || holderContainsWrapper(container, holder)) { 63 if ((!DOMWrapperWorld::isolatedWorldsExist() && !canExistInWorker(object )) || holderContainsWrapper(container, holder)) {
64 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 64 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) {
65 return ScriptWrappable::getUnsafeWrapperFromObject(object).handl e(); 65 v8::Handle<v8::Object> result = ScriptWrappable::getUnsafeWrappe rFromObject(object).handle();
66 // Security: always guard against malicious tampering.
67 RELEASE_ASSERT(result.IsEmpty() || result->GetAlignedPointerFrom InternalField(v8DOMWrapperObjectIndex) == static_cast<void*>(object));
68 return result;
69 }
66 return mainWorldStore()->m_wrapperMap.get(object); 70 return mainWorldStore()->m_wrapperMap.get(object);
67 } 71 }
68 return current(container.GetIsolate())->get(object); 72 return current(container.GetIsolate())->get(object);
69 } 73 }
70 74
71 template<typename T> 75 template<typename T>
72 static v8::Handle<v8::Object> getWrapper(T* object, v8::Isolate* isolate) 76 static v8::Handle<v8::Object> getWrapper(T* object, v8::Isolate* isolate)
73 { 77 {
74 if (ScriptWrappable::wrapperCanBeStoredInObject(object) && !canExistInWo rker(object)) { 78 if (ScriptWrappable::wrapperCanBeStoredInObject(object) && !canExistInWo rker(object)) {
75 if (LIKELY(!DOMWrapperWorld::isolatedWorldsExist())) 79 if (LIKELY(!DOMWrapperWorld::isolatedWorldsExist())) {
76 return ScriptWrappable::getUnsafeWrapperFromObject(object).handl e(); 80 v8::Handle<v8::Object> result = ScriptWrappable::getUnsafeWrappe rFromObject(object).handle();
81 // Security: always guard against malicious tampering.
82 RELEASE_ASSERT(result.IsEmpty() || result->GetAlignedPointerFrom InternalField(v8DOMWrapperObjectIndex) == static_cast<void*>(object));
83 return result;
84 }
77 } 85 }
78 return current(isolate)->get(object); 86 return current(isolate)->get(object);
79 } 87 }
80 88
81 template<typename T> 89 template<typename T>
82 static v8::Handle<v8::Object> getWrapperForMainWorld(T* object) 90 static v8::Handle<v8::Object> getWrapperForMainWorld(T* object)
83 { 91 {
84 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 92 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
85 return ScriptWrappable::getUnsafeWrapperFromObject(object).handle(); 93 return ScriptWrappable::getUnsafeWrapperFromObject(object).handle();
86 return mainWorldStore()->get(object); 94 return mainWorldStore()->get(object);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 WrapperTypeInfo* type = toWrapperTypeInfo(wrapper); 160 WrapperTypeInfo* type = toWrapperTypeInfo(wrapper);
153 ASSERT(type->derefObjectFunction); 161 ASSERT(type->derefObjectFunction);
154 void* key = static_cast<void*>(toNative(wrapper)); 162 void* key = static_cast<void*>(toNative(wrapper));
155 map->removeAndDispose(key, wrapper, isolate); 163 map->removeAndDispose(key, wrapper, isolate);
156 type->derefObject(key); 164 type->derefObject(key);
157 } 165 }
158 166
159 } // namespace WebCore 167 } // namespace WebCore
160 168
161 #endif // DOMDataStore_h 169 #endif // DOMDataStore_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/v8/ScriptWrappable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698