Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/WebKit/Source/platform/heap/Persistent.h

Issue 2660463003: CrossThreadPersistent should acquire a lock before assigning (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 NO_SANITIZE_ADDRESS 168 NO_SANITIZE_ADDRESS
169 T* atomicGet() { 169 T* atomicGet() {
170 return reinterpret_cast<T*>(acquireLoad(reinterpret_cast<void* volatile*>( 170 return reinterpret_cast<T*>(acquireLoad(reinterpret_cast<void* volatile*>(
171 const_cast<typename std::remove_const<T>::type**>(&m_raw)))); 171 const_cast<typename std::remove_const<T>::type**>(&m_raw))));
172 } 172 }
173 173
174 private: 174 private:
175 NO_SANITIZE_ADDRESS 175 NO_SANITIZE_ADDRESS
176 void assign(T* ptr) { 176 void assign(T* ptr) {
177 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) { 177 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) {
178 CrossThreadPersistentRegion::LockScope persistentLock(
179 ProcessHeap::crossThreadPersistentRegion());
178 releaseStore( 180 releaseStore(
sof 2017/02/09 06:36:24 With the lock held, this could be a 'normal' store
179 reinterpret_cast<void* volatile*>( 181 reinterpret_cast<void* volatile*>(
180 const_cast<typename std::remove_const<T>::type**>(&m_raw)), 182 const_cast<typename std::remove_const<T>::type**>(&m_raw)),
181 const_cast<typename std::remove_const<T>::type*>(ptr)); 183 const_cast<typename std::remove_const<T>::type*>(ptr));
182 } else { 184 } else {
183 m_raw = ptr; 185 m_raw = ptr;
184 } 186 }
185 checkPointer(); 187 checkPointer();
186 if (m_raw) { 188 if (m_raw) {
187 if (!m_persistentNode) 189 if (!m_persistentNode)
188 initialize(); 190 initialize();
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 static blink::CrossThreadPersistent<T> Unwrap( 820 static blink::CrossThreadPersistent<T> Unwrap(
819 const blink::CrossThreadWeakPersistent<T>& wrapped) { 821 const blink::CrossThreadWeakPersistent<T>& wrapped) {
820 blink::CrossThreadPersistentRegion::LockScope persistentLock( 822 blink::CrossThreadPersistentRegion::LockScope persistentLock(
821 blink::ProcessHeap::crossThreadPersistentRegion()); 823 blink::ProcessHeap::crossThreadPersistentRegion());
822 return blink::CrossThreadPersistent<T>(wrapped.get()); 824 return blink::CrossThreadPersistent<T>(wrapped.get());
823 } 825 }
824 }; 826 };
825 } 827 }
826 828
827 #endif // Persistent_h 829 #endif // Persistent_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698