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

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

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 PersistentNode_h 5 #ifndef PersistentNode_h
6 #define PersistentNode_h 6 #define PersistentNode_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/heap/ThreadState.h" 9 #include "platform/heap/ThreadState.h"
10 #include "wtf/Allocator.h" 10 #include "wtf/Allocator.h"
11 #include "wtf/Assertions.h" 11 #include "wtf/Assertions.h"
12 #include "wtf/PtrUtil.h"
13 #include "wtf/ThreadingPrimitives.h" 12 #include "wtf/ThreadingPrimitives.h"
14 #include <memory>
15 13
16 namespace blink { 14 namespace blink {
17 15
18 class CrossThreadPersistentRegion; 16 class CrossThreadPersistentRegion;
19 17
20 class PersistentNode final { 18 class PersistentNode final {
21 DISALLOW_NEW(); 19 DISALLOW_NEW();
22 public: 20 public:
23 PersistentNode() 21 PersistentNode()
24 : m_self(nullptr) 22 : m_self(nullptr)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 PersistentNode* m_freeListHead; 165 PersistentNode* m_freeListHead;
168 PersistentNodeSlots* m_slots; 166 PersistentNodeSlots* m_slots;
169 #if ENABLE(ASSERT) 167 #if ENABLE(ASSERT)
170 int m_persistentCount; 168 int m_persistentCount;
171 #endif 169 #endif
172 }; 170 };
173 171
174 class CrossThreadPersistentRegion final { 172 class CrossThreadPersistentRegion final {
175 USING_FAST_MALLOC(CrossThreadPersistentRegion); 173 USING_FAST_MALLOC(CrossThreadPersistentRegion);
176 public: 174 public:
177 CrossThreadPersistentRegion() : m_persistentRegion(wrapUnique(new Persistent Region)) { } 175 CrossThreadPersistentRegion() : m_persistentRegion(adoptPtr(new PersistentRe gion)) { }
178 176
179 void allocatePersistentNode(PersistentNode*& persistentNode, void* self, Tra ceCallback trace) 177 void allocatePersistentNode(PersistentNode*& persistentNode, void* self, Tra ceCallback trace)
180 { 178 {
181 MutexLocker lock(m_mutex); 179 MutexLocker lock(m_mutex);
182 PersistentNode* node = m_persistentRegion->allocatePersistentNode(self, trace); 180 PersistentNode* node = m_persistentRegion->allocatePersistentNode(self, trace);
183 releaseStore(reinterpret_cast<void* volatile*>(&persistentNode), node); 181 releaseStore(reinterpret_cast<void* volatile*>(&persistentNode), node);
184 } 182 }
185 183
186 void freePersistentNode(PersistentNode*& persistentNode) 184 void freePersistentNode(PersistentNode*& persistentNode)
187 { 185 {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 235 }
238 236
239 void unlock() 237 void unlock()
240 { 238 {
241 m_mutex.unlock(); 239 m_mutex.unlock();
242 } 240 }
243 241
244 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion 242 // We don't make CrossThreadPersistentRegion inherit from PersistentRegion
245 // because we don't want to virtualize performance-sensitive methods 243 // because we don't want to virtualize performance-sensitive methods
246 // such as PersistentRegion::allocate/freePersistentNode. 244 // such as PersistentRegion::allocate/freePersistentNode.
247 std::unique_ptr<PersistentRegion> m_persistentRegion; 245 OwnPtr<PersistentRegion> m_persistentRegion;
248 246
249 // Recursive as prepareForThreadStateTermination() clears a PersistentNode's 247 // Recursive as prepareForThreadStateTermination() clears a PersistentNode's
250 // associated Persistent<> -- it in turn freeing the PersistentNode. And bot h 248 // associated Persistent<> -- it in turn freeing the PersistentNode. And bot h
251 // CrossThreadPersistentRegion operations need a lock on the region before 249 // CrossThreadPersistentRegion operations need a lock on the region before
252 // mutating. 250 // mutating.
253 RecursiveMutex m_mutex; 251 RecursiveMutex m_mutex;
254 }; 252 };
255 253
256 } // namespace blink 254 } // namespace blink
257 255
258 #endif 256 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapTest.cpp ('k') | third_party/WebKit/Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698