| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 Loading... |
| 54 // ScriptWrappable provides a way to map from/to C++ DOM implementation to/from | 54 // ScriptWrappable provides a way to map from/to C++ DOM implementation to/from |
| 55 // JavaScript object (platform object). ToV8() converts a ScriptWrappable to | 55 // JavaScript object (platform object). ToV8() converts a ScriptWrappable to |
| 56 // a v8::Object and toScriptWrappable() converts a v8::Object back to | 56 // a v8::Object and toScriptWrappable() converts a v8::Object back to |
| 57 // a ScriptWrappable. v8::Object as platform object is called "wrapper object". | 57 // a ScriptWrappable. v8::Object as platform object is called "wrapper object". |
| 58 // The wrapepr object for the main world is stored in ScriptWrappable. Wrapper | 58 // The wrapepr object for the main world is stored in ScriptWrappable. Wrapper |
| 59 // objects for other worlds are stored in DOMWrapperMap. | 59 // objects for other worlds are stored in DOMWrapperMap. |
| 60 class CORE_EXPORT ScriptWrappable : public TraceWrapperBase { | 60 class CORE_EXPORT ScriptWrappable : public TraceWrapperBase { |
| 61 WTF_MAKE_NONCOPYABLE(ScriptWrappable); | 61 WTF_MAKE_NONCOPYABLE(ScriptWrappable); |
| 62 | 62 |
| 63 public: | 63 public: |
| 64 ScriptWrappable() {} | 64 ScriptWrappable() { |
| 65 #if DCHECK_IS_ON() |
| 66 // If this DCHECK() triggers, you're attempting to embed a ScriptWrappable |
| 67 // inside a static local singleton, which is unsafe. |
| 68 // See |DEFINE_STATIC_LOCAL()| documentation for further details. |
| 69 DCHECK(ThreadState::current()->canAllocateScriptWrappable()); |
| 70 #endif |
| 71 } |
| 65 | 72 |
| 66 bool isScriptWrappable() const override { return true; } | 73 bool isScriptWrappable() const override { return true; } |
| 67 | 74 |
| 68 template <typename T> | 75 template <typename T> |
| 69 T* toImpl() { | 76 T* toImpl() { |
| 70 // All ScriptWrappables are managed by the Blink GC heap; check that | 77 // All ScriptWrappables are managed by the Blink GC heap; check that |
| 71 // |T| is a garbage collected type. | 78 // |T| is a garbage collected type. |
| 72 static_assert( | 79 static_assert( |
| 73 sizeof(T) && WTF::IsGarbageCollectedType<T>::value, | 80 sizeof(T) && WTF::IsGarbageCollectedType<T>::value, |
| 74 "Classes implementing ScriptWrappable must be garbage collected."); | 81 "Classes implementing ScriptWrappable must be garbage collected."); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 #define DECLARE_WRAPPERTYPEINFO() \ | 226 #define DECLARE_WRAPPERTYPEINFO() \ |
| 220 public: \ | 227 public: \ |
| 221 const WrapperTypeInfo* wrapperTypeInfo() const override; \ | 228 const WrapperTypeInfo* wrapperTypeInfo() const override; \ |
| 222 \ | 229 \ |
| 223 private: \ | 230 private: \ |
| 224 typedef void end_of_define_wrappertypeinfo_not_reached_t | 231 typedef void end_of_define_wrappertypeinfo_not_reached_t |
| 225 | 232 |
| 226 } // namespace blink | 233 } // namespace blink |
| 227 | 234 |
| 228 #endif // ScriptWrappable_h | 235 #endif // ScriptWrappable_h |
| OLD | NEW |