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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 ProcessHeap::GetCrossThreadPersistentRegion().FreePersistentNode( | 242 ProcessHeap::GetCrossThreadPersistentRegion().FreePersistentNode( |
243 persistent_node_); | 243 persistent_node_); |
244 return; | 244 return; |
245 } | 245 } |
246 | 246 |
247 if (!persistent_node_) | 247 if (!persistent_node_) |
248 return; | 248 return; |
249 ThreadState* state = | 249 ThreadState* state = |
250 ThreadStateFor<ThreadingTrait<T>::kAffinity>::GetState(); | 250 ThreadStateFor<ThreadingTrait<T>::kAffinity>::GetState(); |
251 DCHECK(state->CheckThread()); | 251 DCHECK(state->CheckThread()); |
252 // Persistent handle must be created and destructed in the same thread. | 252 // Persistent handle must be created and destructed in the same thread. |
253 #if DCHECK_IS_ON() | 253 #if DCHECK_IS_ON() |
254 DCHECK_EQ(state_, state); | 254 DCHECK_EQ(state_, state); |
255 #endif | 255 #endif |
256 state->FreePersistentNode(persistent_node_); | 256 state->FreePersistentNode(persistent_node_); |
257 persistent_node_ = nullptr; | 257 persistent_node_ = nullptr; |
258 } | 258 } |
259 | 259 |
260 void CheckPointer() const { | 260 void CheckPointer() const { |
261 #if DCHECK_IS_ON() | 261 #if DCHECK_IS_ON() |
262 if (!raw_ || IsHashTableDeletedValue()) | 262 if (!raw_ || IsHashTableDeletedValue()) |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 #if DCHECK_IS_ON() | 607 #if DCHECK_IS_ON() |
608 state_ = state; | 608 state_ = state; |
609 #endif | 609 #endif |
610 } | 610 } |
611 | 611 |
612 void Uninitialize() { | 612 void Uninitialize() { |
613 if (!persistent_node_) | 613 if (!persistent_node_) |
614 return; | 614 return; |
615 ThreadState* state = ThreadState::Current(); | 615 ThreadState* state = ThreadState::Current(); |
616 DCHECK(state->CheckThread()); | 616 DCHECK(state->CheckThread()); |
617 // Persistent handle must be created and destructed in the same thread. | 617 // Persistent handle must be created and destructed in the same thread. |
618 #if DCHECK_IS_ON() | 618 #if DCHECK_IS_ON() |
619 DCHECK_EQ(state_, state); | 619 DCHECK_EQ(state_, state); |
620 #endif | 620 #endif |
621 state->FreePersistentNode(persistent_node_); | 621 state->FreePersistentNode(persistent_node_); |
622 persistent_node_ = nullptr; | 622 persistent_node_ = nullptr; |
623 } | 623 } |
624 | 624 |
625 PersistentNode* persistent_node_; | 625 PersistentNode* persistent_node_; |
626 #if DCHECK_IS_ON() | 626 #if DCHECK_IS_ON() |
627 ThreadState* state_; | 627 ThreadState* state_; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 | 806 |
807 template <typename T> | 807 template <typename T> |
808 struct BindUnwrapTraits<blink::CrossThreadWeakPersistent<T>> { | 808 struct BindUnwrapTraits<blink::CrossThreadWeakPersistent<T>> { |
809 static blink::CrossThreadPersistent<T> Unwrap( | 809 static blink::CrossThreadPersistent<T> Unwrap( |
810 const blink::CrossThreadWeakPersistent<T>& wrapped) { | 810 const blink::CrossThreadWeakPersistent<T>& wrapped) { |
811 blink::CrossThreadPersistentRegion::LockScope persistentLock( | 811 blink::CrossThreadPersistentRegion::LockScope persistentLock( |
812 blink::ProcessHeap::GetCrossThreadPersistentRegion()); | 812 blink::ProcessHeap::GetCrossThreadPersistentRegion()); |
813 return blink::CrossThreadPersistent<T>(wrapped.Get()); | 813 return blink::CrossThreadPersistent<T>(wrapped.Get()); |
814 } | 814 } |
815 }; | 815 }; |
816 } | 816 } // namespace base |
817 | 817 |
818 #endif // Persistent_h | 818 #endif // Persistent_h |
OLD | NEW |