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

Side by Side Diff: third_party/WebKit/public/platform/WebPrivatePtr.h

Issue 1919643002: Remove RefCountedGarbageCollected<>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sof-data-pers
Patch Set: rebased Created 4 years, 8 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 | « third_party/WebKit/Source/platform/heap/HeapTest.cpp ('k') | 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 /* 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // way of WebPrivatePtr<>. 59 // way of WebPrivatePtr<>.
60 enum class WebPrivatePtrStrength { 60 enum class WebPrivatePtrStrength {
61 Normal, 61 Normal,
62 Weak, 62 Weak,
63 }; 63 };
64 64
65 #if INSIDE_BLINK 65 #if INSIDE_BLINK
66 enum LifetimeManagementType { 66 enum LifetimeManagementType {
67 RefCountedLifetime, 67 RefCountedLifetime,
68 GarbageCollectedLifetime, 68 GarbageCollectedLifetime,
69 RefCountedGarbageCollectedLifetime
70 }; 69 };
71 70
72 template<typename T> 71 template<typename T>
73 struct LifetimeOf { 72 struct LifetimeOf {
74 private: 73 private:
75 static const bool isGarbageCollected = WTF::IsSubclassOfTemplate<T, GarbageC ollected>::value || IsGarbageCollectedMixin<T>::value; 74 static const bool isGarbageCollected = WTF::IsSubclassOfTemplate<T, GarbageC ollected>::value || IsGarbageCollectedMixin<T>::value;
76 static const bool isRefCountedGarbageCollected = WTF::IsSubclassOfTemplate<T , RefCountedGarbageCollected>::value;
77 public: 75 public:
78 static const LifetimeManagementType value = 76 static const LifetimeManagementType value = !isGarbageCollected ? RefCounted Lifetime : GarbageCollectedLifetime;
79 !isGarbageCollected ? RefCountedLifetime :
80 isRefCountedGarbageCollected ? RefCountedGarbageCollectedLifetime : Garb ageCollectedLifetime;
81 }; 77 };
82 78
83 template<typename T, WebPrivatePtrDestruction crossThreadDestruction, WebPrivate PtrStrength strongOrWeak, LifetimeManagementType lifetime> 79 template<typename T, WebPrivatePtrDestruction crossThreadDestruction, WebPrivate PtrStrength strongOrWeak, LifetimeManagementType lifetime>
84 class PtrStorageImpl; 80 class PtrStorageImpl;
85 81
86 template<typename T, WebPrivatePtrDestruction crossThreadDestruction, WebPrivate PtrStrength strongOrWeak> 82 template<typename T, WebPrivatePtrDestruction crossThreadDestruction, WebPrivate PtrStrength strongOrWeak>
87 class PtrStorageImpl<T, crossThreadDestruction, strongOrWeak, RefCountedLifetime > { 83 class PtrStorageImpl<T, crossThreadDestruction, strongOrWeak, RefCountedLifetime > {
88 public: 84 public:
89 typedef PassRefPtr<T> BlinkPtrType; 85 typedef PassRefPtr<T> BlinkPtrType;
90 86
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 { 162 {
167 delete m_handle; 163 delete m_handle;
168 m_handle = 0; 164 m_handle = 0;
169 } 165 }
170 166
171 private: 167 private:
172 typename WebPrivatePtrPersistentStorageType<T, crossThreadDestruction, stron gOrWeak>::Type* m_handle; 168 typename WebPrivatePtrPersistentStorageType<T, crossThreadDestruction, stron gOrWeak>::Type* m_handle;
173 }; 169 };
174 170
175 template<typename T, WebPrivatePtrDestruction crossThreadDestruction, WebPrivate PtrStrength strongOrWeak> 171 template<typename T, WebPrivatePtrDestruction crossThreadDestruction, WebPrivate PtrStrength strongOrWeak>
176 class PtrStorageImpl<T, crossThreadDestruction, strongOrWeak, RefCountedGarbageC ollectedLifetime> : public PtrStorageImpl<T, crossThreadDestruction, strongOrWea k, GarbageCollectedLifetime> {
177 public:
178 void assign(T* val) { PtrStorageImpl<T, crossThreadDestruction, strongOrWeak , GarbageCollectedLifetime>::assign(val); }
179
180 void assign(const PtrStorageImpl& other) { PtrStorageImpl<T, crossThreadDest ruction, strongOrWeak, GarbageCollectedLifetime>::assign(other.get()); }
181 };
182
183 template<typename T, WebPrivatePtrDestruction crossThreadDestruction, WebPrivate PtrStrength strongOrWeak>
184 class PtrStorage : public PtrStorageImpl<T, crossThreadDestruction, strongOrWeak , LifetimeOf<T>::value> { 172 class PtrStorage : public PtrStorageImpl<T, crossThreadDestruction, strongOrWeak , LifetimeOf<T>::value> {
185 public: 173 public:
186 static PtrStorage& fromSlot(void** slot) 174 static PtrStorage& fromSlot(void** slot)
187 { 175 {
188 static_assert(sizeof(PtrStorage) == sizeof(void*), "PtrStorage must be t he size of a pointer"); 176 static_assert(sizeof(PtrStorage) == sizeof(void*), "PtrStorage must be t he size of a pointer");
189 return *reinterpret_cast<PtrStorage*>(slot); 177 return *reinterpret_cast<PtrStorage*>(slot);
190 } 178 }
191 179
192 static const PtrStorage& fromSlot(void* const* slot) 180 static const PtrStorage& fromSlot(void* const* slot)
193 { 181 {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // Disable the copy constructor; classes that contain a WebPrivatePtr 295 // Disable the copy constructor; classes that contain a WebPrivatePtr
308 // should implement their copy constructor using assign(). 296 // should implement their copy constructor using assign().
309 WebPrivatePtr(const WebPrivatePtr&); 297 WebPrivatePtr(const WebPrivatePtr&);
310 298
311 void* m_storage; 299 void* m_storage;
312 }; 300 };
313 301
314 } // namespace blink 302 } // namespace blink
315 303
316 #endif // WebPrivatePtr_h 304 #endif // WebPrivatePtr_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698