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

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

Issue 209713003: Make DOMWrapperWorld::current() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | « Source/bindings/v8/CustomElementWrapper.cpp ('k') | Source/bindings/v8/DOMDataStore.cpp » ('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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 static bool setReturnValueFromWrapperFast(v8::ReturnValue<v8::Value> returnV alue, T* object, v8::Local<v8::Object> holder, Wrappable* wrappable) 67 static bool setReturnValueFromWrapperFast(v8::ReturnValue<v8::Value> returnV alue, T* object, v8::Local<v8::Object> holder, Wrappable* wrappable)
68 { 68 {
69 if (canUseScriptWrappable(object)) 69 if (canUseScriptWrappable(object))
70 return ScriptWrappable::setReturnValueWithSecurityCheck<V8T>(returnV alue, object); 70 return ScriptWrappable::setReturnValueWithSecurityCheck<V8T>(returnV alue, object);
71 // The second fastest way to check if we're in the main world is to chec k if 71 // The second fastest way to check if we're in the main world is to chec k if
72 // the wrappable's wrapper is the same as the holder. 72 // the wrappable's wrapper is the same as the holder.
73 // FIXME: Investigate if it's worth having this check for performance. 73 // FIXME: Investigate if it's worth having this check for performance.
74 if (holderContainsWrapper(holder, wrappable)) { 74 if (holderContainsWrapper(holder, wrappable)) {
75 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 75 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
76 return ScriptWrappable::setReturnValueWithSecurityCheck<V8T>(ret urnValue, object); 76 return ScriptWrappable::setReturnValueWithSecurityCheck<V8T>(ret urnValue, object);
77 return DOMWrapperWorld::mainWorld()->domDataStore().m_wrapperMap.set ReturnValueFrom(returnValue, V8T::toInternalPointer(object)); 77 return DOMWrapperWorld::mainWorld().domDataStore().m_wrapperMap.setR eturnValueFrom(returnValue, V8T::toInternalPointer(object));
78 } 78 }
79 return current(returnValue.GetIsolate()).template setReturnValueFrom<V8T >(returnValue, object); 79 return current(returnValue.GetIsolate()).template setReturnValueFrom<V8T >(returnValue, object);
80 } 80 }
81 81
82 template<typename V8T, typename T> 82 template<typename V8T, typename T>
83 static bool setReturnValueFromWrapper(v8::ReturnValue<v8::Value> returnValue , T* object) 83 static bool setReturnValueFromWrapper(v8::ReturnValue<v8::Value> returnValue , T* object)
84 { 84 {
85 if (canUseScriptWrappable(object)) 85 if (canUseScriptWrappable(object))
86 return ScriptWrappable::setReturnValueWithSecurityCheck<V8T>(returnV alue, object); 86 return ScriptWrappable::setReturnValueWithSecurityCheck<V8T>(returnV alue, object);
87 return current(returnValue.GetIsolate()).template setReturnValueFrom<V8T >(returnValue, object); 87 return current(returnValue.GetIsolate()).template setReturnValueFrom<V8T >(returnValue, object);
88 } 88 }
89 89
90 template<typename V8T, typename T> 90 template<typename V8T, typename T>
91 static bool setReturnValueFromWrapperForMainWorld(v8::ReturnValue<v8::Value> returnValue, T* object) 91 static bool setReturnValueFromWrapperForMainWorld(v8::ReturnValue<v8::Value> returnValue, T* object)
92 { 92 {
93 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 93 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
94 return ScriptWrappable::setReturnValue(returnValue, object); 94 return ScriptWrappable::setReturnValue(returnValue, object);
95 return DOMWrapperWorld::mainWorld()->domDataStore().m_wrapperMap.setRetu rnValueFrom(returnValue, V8T::toInternalPointer(object)); 95 return DOMWrapperWorld::mainWorld().domDataStore().m_wrapperMap.setRetur nValueFrom(returnValue, V8T::toInternalPointer(object));
96 } 96 }
97 97
98 template<typename V8T, typename T> 98 template<typename V8T, typename T>
99 static v8::Handle<v8::Object> getWrapper(T* object, v8::Isolate* isolate) 99 static v8::Handle<v8::Object> getWrapper(T* object, v8::Isolate* isolate)
100 { 100 {
101 if (canUseScriptWrappable(object)) { 101 if (canUseScriptWrappable(object)) {
102 v8::Handle<v8::Object> result = ScriptWrappable::getUnsafeWrapperFro mObject(object).newLocal(isolate); 102 v8::Handle<v8::Object> result = ScriptWrappable::getUnsafeWrapperFro mObject(object).newLocal(isolate);
103 // Security: always guard against malicious tampering. 103 // Security: always guard against malicious tampering.
104 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(result.IsEmpty() || result- >GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == V8T::toInternalP ointer(object)); 104 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(result.IsEmpty() || result- >GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex) == V8T::toInternalP ointer(object));
105 return result; 105 return result;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return holder == *unsafePersistent.persistent(); 199 return holder == *unsafePersistent.persistent();
200 } 200 }
201 201
202 bool m_isMainWorld; 202 bool m_isMainWorld;
203 DOMWrapperMap<void> m_wrapperMap; 203 DOMWrapperMap<void> m_wrapperMap;
204 }; 204 };
205 205
206 } // namespace WebCore 206 } // namespace WebCore
207 207
208 #endif // DOMDataStore_h 208 #endif // DOMDataStore_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/CustomElementWrapper.cpp ('k') | Source/bindings/v8/DOMDataStore.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698