OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 17 matching lines...) Expand all Loading... |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef Handle_h | 31 #ifndef Handle_h |
32 #define Handle_h | 32 #define Handle_h |
33 | 33 |
34 #include "heap/Heap.h" | 34 #include "heap/Heap.h" |
35 #include "heap/ThreadState.h" | 35 #include "heap/ThreadState.h" |
36 #include "heap/Visitor.h" | 36 #include "heap/Visitor.h" |
37 | 37 |
| 38 #include "wtf/HashFunctions.h" |
38 #include "wtf/Locker.h" | 39 #include "wtf/Locker.h" |
39 #include "wtf/RawPtr.h" | 40 #include "wtf/RawPtr.h" |
40 #include "wtf/RefCounted.h" | 41 #include "wtf/RefCounted.h" |
41 #include "wtf/TypeTraits.h" | 42 #include "wtf/TypeTraits.h" |
42 | 43 |
43 namespace WebCore { | 44 namespace WebCore { |
44 | 45 |
45 template<typename T> class HeapTerminatedArray; | 46 template<typename T> class HeapTerminatedArray; |
46 | 47 |
47 #define COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage)
\ | 48 #define COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage)
\ |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); } | 878 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); } |
878 static bool equal(T* a, const WebCore::Member<T>& b) { return a == b; } | 879 static bool equal(T* a, const WebCore::Member<T>& b) { return a == b; } |
879 static bool equal(const WebCore::Member<T>& a, T* b) { return a == b; } | 880 static bool equal(const WebCore::Member<T>& a, T* b) { return a == b; } |
880 template<typename U, typename V> | 881 template<typename U, typename V> |
881 static bool equal(const U& a, const V& b) { return a == b; } | 882 static bool equal(const U& a, const V& b) { return a == b; } |
882 }; | 883 }; |
883 | 884 |
884 template<typename T> struct PtrHash<WebCore::WeakMember<T> > : PtrHash<WebCore::
Member<T> > { | 885 template<typename T> struct PtrHash<WebCore::WeakMember<T> > : PtrHash<WebCore::
Member<T> > { |
885 }; | 886 }; |
886 | 887 |
| 888 template<typename P> struct PtrHash<WebCore::Persistent<P> > : PtrHash<P*> { |
| 889 using PtrHash<P*>::hash; |
| 890 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); } |
| 891 using PtrHash<P*>::equal; |
| 892 static bool equal(const RefPtr<P>& a, const RefPtr<P>& b) { return a == b; } |
| 893 static bool equal(P* a, const RefPtr<P>& b) { return a == b; } |
| 894 static bool equal(const RefPtr<P>& a, P* b) { return a == b; } |
| 895 }; |
| 896 |
887 // PtrHash is the default hash for hash tables with members. | 897 // PtrHash is the default hash for hash tables with members. |
888 template<typename T> struct DefaultHash<WebCore::Member<T> > { | 898 template<typename T> struct DefaultHash<WebCore::Member<T> > { |
889 typedef PtrHash<WebCore::Member<T> > Hash; | 899 typedef PtrHash<WebCore::Member<T> > Hash; |
890 }; | 900 }; |
891 | 901 |
892 template<typename T> struct DefaultHash<WebCore::WeakMember<T> > { | 902 template<typename T> struct DefaultHash<WebCore::WeakMember<T> > { |
893 typedef PtrHash<WebCore::WeakMember<T> > Hash; | 903 typedef PtrHash<WebCore::WeakMember<T> > Hash; |
894 }; | 904 }; |
895 | 905 |
| 906 template<typename T> struct DefaultHash<WebCore::Persistent<T> > { |
| 907 typedef PtrHash<WebCore::Persistent<T> > Hash; |
| 908 }; |
| 909 |
896 template<typename T> | 910 template<typename T> |
897 struct NeedsTracing<WebCore::Member<T> > { | 911 struct NeedsTracing<WebCore::Member<T> > { |
898 static const bool value = true; | 912 static const bool value = true; |
899 }; | 913 }; |
900 | 914 |
901 template<typename T> | 915 template<typename T> |
902 struct IsWeak<WebCore::WeakMember<T> > { | 916 struct IsWeak<WebCore::WeakMember<T> > { |
903 static const bool value = true; | 917 static const bool value = true; |
904 }; | 918 }; |
905 | 919 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 }; | 955 }; |
942 | 956 |
943 template<typename T, typename U> | 957 template<typename T, typename U> |
944 struct NeedsTracing<HashMap<T, U> > { | 958 struct NeedsTracing<HashMap<T, U> > { |
945 static const bool value = false; | 959 static const bool value = false; |
946 }; | 960 }; |
947 | 961 |
948 } // namespace WTF | 962 } // namespace WTF |
949 | 963 |
950 #endif | 964 #endif |
OLD | NEW |