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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 ScriptWrappable* object, | 201 ScriptWrappable* object, |
202 const WrapperTypeInfo* wrapperTypeInfo, | 202 const WrapperTypeInfo* wrapperTypeInfo, |
203 v8::Local<v8::Object>& wrapper) WARN_UNUSED_RETURN { | 203 v8::Local<v8::Object>& wrapper) WARN_UNUSED_RETURN { |
204 ASSERT(object); | 204 ASSERT(object); |
205 ASSERT(!wrapper.IsEmpty()); | 205 ASSERT(!wrapper.IsEmpty()); |
206 if (m_isMainWorld) | 206 if (m_isMainWorld) |
207 return object->setWrapper(isolate, wrapperTypeInfo, wrapper); | 207 return object->setWrapper(isolate, wrapperTypeInfo, wrapper); |
208 return m_wrapperMap->set(object, wrapperTypeInfo, wrapper); | 208 return m_wrapperMap->set(object, wrapperTypeInfo, wrapper); |
209 } | 209 } |
210 | 210 |
211 // We can use a wrapper stored in a ScriptWrappable when we're in the main wor
ld. | 211 // We can use a wrapper stored in a ScriptWrappable when we're in the main |
212 // This method does the fast check if we're in the main world. If this method
returns true, | 212 // world. This method does the fast check if we're in the main world. If this |
213 // it is guaranteed that we're in the main world. On the other hand, if this m
ethod returns | 213 // method returns true, it is guaranteed that we're in the main world. On the |
214 // false, nothing is guaranteed (we might be in the main world). | 214 // other hand, if this method returns false, nothing is guaranteed (we might |
| 215 // be in the main world). |
215 static bool canUseScriptWrappable(Node*) { | 216 static bool canUseScriptWrappable(Node*) { |
216 // This helper function itself doesn't use the argument, but we have to | 217 // This helper function itself doesn't use the argument, but we have to |
217 // make sure that the argument is type of Node* because Node and its | 218 // make sure that the argument is type of Node* because Node and its |
218 // subclasses satisfy the following two conditions. | 219 // subclasses satisfy the following two conditions. |
219 // 1. Nodes never exist in worker. | 220 // 1. Nodes never exist in worker. |
220 // 2. Node inherits from ScriptWrappable. | 221 // 2. Node inherits from ScriptWrappable. |
221 // and if there exists no isolated world, we're sure that we're in the | 222 // and if there exists no isolated world, we're sure that we're in the |
222 // main world and we can use ScriptWrappable's wrapper. | 223 // main world and we can use ScriptWrappable's wrapper. |
223 return !DOMWrapperWorld::isolatedWorldsExist(); | 224 return !DOMWrapperWorld::isolatedWorldsExist(); |
224 } | 225 } |
(...skipping 24 matching lines...) Expand all Loading... |
249 DOMWrapperMap<ScriptWrappable>::PersistentValueMapTraits::DisposeWeak( | 250 DOMWrapperMap<ScriptWrappable>::PersistentValueMapTraits::DisposeWeak( |
250 const v8::WeakCallbackInfo<WeakCallbackDataType>& data) { | 251 const v8::WeakCallbackInfo<WeakCallbackDataType>& data) { |
251 auto wrapperTypeInfo = reinterpret_cast<WrapperTypeInfo*>( | 252 auto wrapperTypeInfo = reinterpret_cast<WrapperTypeInfo*>( |
252 data.GetInternalField(v8DOMWrapperTypeIndex)); | 253 data.GetInternalField(v8DOMWrapperTypeIndex)); |
253 wrapperTypeInfo->wrapperDestroyed(); | 254 wrapperTypeInfo->wrapperDestroyed(); |
254 } | 255 } |
255 | 256 |
256 } // namespace blink | 257 } // namespace blink |
257 | 258 |
258 #endif // DOMDataStore_h | 259 #endif // DOMDataStore_h |
OLD | NEW |