| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool containsWrapper() const { return !m_wrapper.IsEmpty(); } | 152 bool containsWrapper() const { return !m_wrapper.IsEmpty(); } |
| 153 | 153 |
| 154 #if !ENABLE(OILPAN) | 154 #if !ENABLE(OILPAN) |
| 155 protected: | 155 protected: |
| 156 virtual ~ScriptWrappable() | 156 virtual ~ScriptWrappable() |
| 157 { | 157 { |
| 158 // We must not get deleted as long as we contain a wrapper. If this happ
ens, we screwed up ref | 158 // We must not get deleted as long as we contain a wrapper. If this happ
ens, we screwed up ref |
| 159 // counting somewhere. Crash here instead of crashing during a later gc
cycle. | 159 // counting somewhere. Crash here instead of crashing during a later gc
cycle. |
| 160 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!containsWrapper()); | 160 SECURITY_CHECK(!containsWrapper()); |
| 161 } | 161 } |
| 162 #endif | 162 #endif |
| 163 // With Oilpan we don't need a ScriptWrappable destructor. | 163 // With Oilpan we don't need a ScriptWrappable destructor. |
| 164 // | 164 // |
| 165 // - 'RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!containsWrapper())' is not n
eeded | 165 // - 'RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!containsWrapper())' is not n
eeded |
| 166 // because Oilpan is not using reference counting at all. If containsWrapper
() is true, | 166 // because Oilpan is not using reference counting at all. If containsWrapper
() is true, |
| 167 // it means that ScriptWrappable still has a wrapper. In this case, the dest
ructor | 167 // it means that ScriptWrappable still has a wrapper. In this case, the dest
ructor |
| 168 // must not be called since the wrapper has a persistent handle back to this
ScriptWrappable object. | 168 // must not be called since the wrapper has a persistent handle back to this
ScriptWrappable object. |
| 169 // Assuming that Oilpan's GC is correct (If we cannot assume this, a lot of
more things are | 169 // Assuming that Oilpan's GC is correct (If we cannot assume this, a lot of
more things are |
| 170 // already broken), we must not hit the RELEASE_ASSERT. | 170 // already broken), we must not hit the RELEASE_ASSERT. |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 void disposeWrapper(const v8::WeakCallbackInfo<ScriptWrappable>& data) | 173 void disposeWrapper(const v8::WeakCallbackInfo<ScriptWrappable>& data) |
| 174 { | 174 { |
| 175 auto scriptWrappable = reinterpret_cast<ScriptWrappable*>(data.GetIntern
alField(v8DOMWrapperObjectIndex)); | 175 auto scriptWrappable = reinterpret_cast<ScriptWrappable*>(data.GetIntern
alField(v8DOMWrapperObjectIndex)); |
| 176 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptWrappable == this); | 176 SECURITY_CHECK(scriptWrappable == this); |
| 177 RELEASE_ASSERT(containsWrapper()); | 177 RELEASE_ASSERT(containsWrapper()); |
| 178 m_wrapper.Reset(); | 178 m_wrapper.Reset(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 static void firstWeakCallback(const v8::WeakCallbackInfo<ScriptWrappable>& d
ata) | 181 static void firstWeakCallback(const v8::WeakCallbackInfo<ScriptWrappable>& d
ata) |
| 182 { | 182 { |
| 183 auto scriptWrappable = data.GetParameter(); | 183 auto scriptWrappable = data.GetParameter(); |
| 184 scriptWrappable->disposeWrapper(data); | 184 scriptWrappable->disposeWrapper(data); |
| 185 | 185 |
| 186 auto wrapperTypeInfo = reinterpret_cast<WrapperTypeInfo*>(data.GetIntern
alField(v8DOMWrapperTypeIndex)); | 186 auto wrapperTypeInfo = reinterpret_cast<WrapperTypeInfo*>(data.GetIntern
alField(v8DOMWrapperTypeIndex)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // in X's cpp code, and instantiate X, i.e. "template class X;". | 242 // in X's cpp code, and instantiate X, i.e. "template class X;". |
| 243 #define DECLARE_WRAPPERTYPEINFO() \ | 243 #define DECLARE_WRAPPERTYPEINFO() \ |
| 244 public: \ | 244 public: \ |
| 245 const WrapperTypeInfo* wrapperTypeInfo() const override; \ | 245 const WrapperTypeInfo* wrapperTypeInfo() const override; \ |
| 246 private: \ | 246 private: \ |
| 247 typedef void end_of_define_wrappertypeinfo_not_reached_t | 247 typedef void end_of_define_wrappertypeinfo_not_reached_t |
| 248 | 248 |
| 249 } // namespace blink | 249 } // namespace blink |
| 250 | 250 |
| 251 #endif // ScriptWrappable_h | 251 #endif // ScriptWrappable_h |
| OLD | NEW |