OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef Persistent_h | 5 #ifndef Persistent_h |
6 #define Persistent_h | 6 #define Persistent_h |
7 | 7 |
8 #include "platform/heap/Heap.h" | 8 #include "platform/heap/Heap.h" |
9 #include "platform/heap/Member.h" | 9 #include "platform/heap/Member.h" |
10 #include "platform/heap/PersistentNode.h" | 10 #include "platform/heap/PersistentNode.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 PersistentBase* registerAsStaticReference() { | 157 PersistentBase* registerAsStaticReference() { |
158 if (m_persistentNode) { | 158 if (m_persistentNode) { |
159 ASSERT(ThreadState::current()); | 159 ASSERT(ThreadState::current()); |
160 ThreadState::current()->registerStaticPersistentNode(m_persistentNode, | 160 ThreadState::current()->registerStaticPersistentNode(m_persistentNode, |
161 nullptr); | 161 nullptr); |
162 LEAK_SANITIZER_IGNORE_OBJECT(this); | 162 LEAK_SANITIZER_IGNORE_OBJECT(this); |
163 } | 163 } |
164 return this; | 164 return this; |
165 } | 165 } |
166 | 166 |
| 167 #if DCHECK_IS_ON() |
| 168 static void enterNoScriptWrappableScope() { |
| 169 DCHECK(ThreadState::current()); |
| 170 ThreadState::current()->enterNoScriptWrappableScope(); |
| 171 } |
| 172 |
| 173 static void leaveNoScriptWrappableScope() { |
| 174 DCHECK(ThreadState::current()); |
| 175 ThreadState::current()->leaveNoScriptWrappableScope(); |
| 176 } |
| 177 #endif |
| 178 |
167 protected: | 179 protected: |
168 NO_SANITIZE_ADDRESS | 180 NO_SANITIZE_ADDRESS |
169 T* atomicGet() { | 181 T* atomicGet() { |
170 return reinterpret_cast<T*>(acquireLoad(reinterpret_cast<void* volatile*>( | 182 return reinterpret_cast<T*>(acquireLoad(reinterpret_cast<void* volatile*>( |
171 const_cast<typename std::remove_const<T>::type**>(&m_raw)))); | 183 const_cast<typename std::remove_const<T>::type**>(&m_raw)))); |
172 } | 184 } |
173 | 185 |
174 private: | 186 private: |
175 NO_SANITIZE_ADDRESS | 187 NO_SANITIZE_ADDRESS |
176 void assign(T* ptr) { | 188 void assign(T* ptr) { |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 if (m_persistentNode) { | 585 if (m_persistentNode) { |
574 ASSERT(ThreadState::current()); | 586 ASSERT(ThreadState::current()); |
575 ThreadState::current()->registerStaticPersistentNode( | 587 ThreadState::current()->registerStaticPersistentNode( |
576 m_persistentNode, | 588 m_persistentNode, |
577 &PersistentHeapCollectionBase<Collection>::clearPersistentNode); | 589 &PersistentHeapCollectionBase<Collection>::clearPersistentNode); |
578 LEAK_SANITIZER_IGNORE_OBJECT(this); | 590 LEAK_SANITIZER_IGNORE_OBJECT(this); |
579 } | 591 } |
580 return this; | 592 return this; |
581 } | 593 } |
582 | 594 |
| 595 #if DCHECK_IS_ON() |
| 596 static void enterNoScriptWrappableScope() { |
| 597 DCHECK(ThreadState::current()); |
| 598 ThreadState::current()->enterNoScriptWrappableScope(); |
| 599 } |
| 600 |
| 601 static void leaveNoScriptWrappableScope() { |
| 602 DCHECK(ThreadState::current()); |
| 603 ThreadState::current()->leaveNoScriptWrappableScope(); |
| 604 } |
| 605 #endif |
| 606 |
583 private: | 607 private: |
584 template <typename VisitorDispatcher> | 608 template <typename VisitorDispatcher> |
585 void tracePersistent(VisitorDispatcher visitor) { | 609 void tracePersistent(VisitorDispatcher visitor) { |
586 static_assert(sizeof(Collection), "Collection must be fully defined"); | 610 static_assert(sizeof(Collection), "Collection must be fully defined"); |
587 visitor->trace(*static_cast<Collection*>(this)); | 611 visitor->trace(*static_cast<Collection*>(this)); |
588 } | 612 } |
589 | 613 |
590 // Used when the registered PersistentNode of this object is | 614 // Used when the registered PersistentNode of this object is |
591 // released during ThreadState shutdown, clearing the association. | 615 // released during ThreadState shutdown, clearing the association. |
592 static void clearPersistentNode(void* self) { | 616 static void clearPersistentNode(void* self) { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 static blink::CrossThreadPersistent<T> Unwrap( | 833 static blink::CrossThreadPersistent<T> Unwrap( |
810 const blink::CrossThreadWeakPersistent<T>& wrapped) { | 834 const blink::CrossThreadWeakPersistent<T>& wrapped) { |
811 blink::CrossThreadPersistentRegion::LockScope persistentLock( | 835 blink::CrossThreadPersistentRegion::LockScope persistentLock( |
812 blink::ProcessHeap::crossThreadPersistentRegion()); | 836 blink::ProcessHeap::crossThreadPersistentRegion()); |
813 return blink::CrossThreadPersistent<T>(wrapped.get()); | 837 return blink::CrossThreadPersistent<T>(wrapped.get()); |
814 } | 838 } |
815 }; | 839 }; |
816 } | 840 } |
817 | 841 |
818 #endif // Persistent_h | 842 #endif // Persistent_h |
OLD | NEW |