OLD | NEW |
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 WeakIdentifierMap_h | 5 #ifndef WeakIdentifierMap_h |
6 #define WeakIdentifierMap_h | 6 #define WeakIdentifierMap_h |
7 | 7 |
8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
10 #include "wtf/HashMap.h" | 10 #include "wtf/HashMap.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 WeakIdentifierMap<T, ##__VA_ARGS__>& \ | 95 WeakIdentifierMap<T, ##__VA_ARGS__>& \ |
96 WeakIdentifierMap<T, ##__VA_ARGS__>::instance(); \ | 96 WeakIdentifierMap<T, ##__VA_ARGS__>::instance(); \ |
97 extern template class WeakIdentifierMap<T, ##__VA_ARGS__>; | 97 extern template class WeakIdentifierMap<T, ##__VA_ARGS__>; |
98 | 98 |
99 #define DEFINE_WEAK_IDENTIFIER_MAP(T, ...) \ | 99 #define DEFINE_WEAK_IDENTIFIER_MAP(T, ...) \ |
100 template class WeakIdentifierMap<T, ##__VA_ARGS__>; \ | 100 template class WeakIdentifierMap<T, ##__VA_ARGS__>; \ |
101 template <> \ | 101 template <> \ |
102 WeakIdentifierMap<T, ##__VA_ARGS__>& \ | 102 WeakIdentifierMap<T, ##__VA_ARGS__>& \ |
103 WeakIdentifierMap<T, ##__VA_ARGS__>::instance() { \ | 103 WeakIdentifierMap<T, ##__VA_ARGS__>::instance() { \ |
104 using RefType = WeakIdentifierMap<T, ##__VA_ARGS__>; \ | 104 using RefType = WeakIdentifierMap<T, ##__VA_ARGS__>; \ |
| 105 ALLOW_UNSAFE_SINGLETON() \ |
105 DEFINE_STATIC_LOCAL(RefType, mapInstance, \ | 106 DEFINE_STATIC_LOCAL(RefType, mapInstance, \ |
106 (new WeakIdentifierMap<T, ##__VA_ARGS__>())); \ | 107 (new WeakIdentifierMap<T, ##__VA_ARGS__>())); \ |
107 return mapInstance; \ | 108 return mapInstance; \ |
108 } | 109 } |
109 | 110 |
110 } // namespace blink | 111 } // namespace blink |
111 | 112 |
112 #endif // WeakIdentifierMap_h | 113 #endif // WeakIdentifierMap_h |
OLD | NEW |