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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); } | 866 static unsigned hash(const U& key) { return PtrHash<T*>::hash(key); } |
866 static bool equal(T* a, const WebCore::Member<T>& b) { return a == b; } | 867 static bool equal(T* a, const WebCore::Member<T>& b) { return a == b; } |
867 static bool equal(const WebCore::Member<T>& a, T* b) { return a == b; } | 868 static bool equal(const WebCore::Member<T>& a, T* b) { return a == b; } |
868 template<typename U, typename V> | 869 template<typename U, typename V> |
869 static bool equal(const U& a, const V& b) { return a == b; } | 870 static bool equal(const U& a, const V& b) { return a == b; } |
870 }; | 871 }; |
871 | 872 |
872 template<typename T> struct PtrHash<WebCore::WeakMember<T> > : PtrHash<WebCore::
Member<T> > { | 873 template<typename T> struct PtrHash<WebCore::WeakMember<T> > : PtrHash<WebCore::
Member<T> > { |
873 }; | 874 }; |
874 | 875 |
| 876 template<typename P> struct PtrHash<WebCore::Persistent<P> > : PtrHash<P*> { |
| 877 using PtrHash<P*>::hash; |
| 878 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); } |
| 879 using PtrHash<P*>::equal; |
| 880 static bool equal(const RefPtr<P>& a, const RefPtr<P>& b) { return a == b; } |
| 881 static bool equal(P* a, const RefPtr<P>& b) { return a == b; } |
| 882 static bool equal(const RefPtr<P>& a, P* b) { return a == b; } |
| 883 }; |
| 884 |
875 // PtrHash is the default hash for hash tables with members. | 885 // PtrHash is the default hash for hash tables with members. |
876 template<typename T> struct DefaultHash<WebCore::Member<T> > { | 886 template<typename T> struct DefaultHash<WebCore::Member<T> > { |
877 typedef PtrHash<WebCore::Member<T> > Hash; | 887 typedef PtrHash<WebCore::Member<T> > Hash; |
878 }; | 888 }; |
879 | 889 |
880 template<typename T> struct DefaultHash<WebCore::WeakMember<T> > { | 890 template<typename T> struct DefaultHash<WebCore::WeakMember<T> > { |
881 typedef PtrHash<WebCore::WeakMember<T> > Hash; | 891 typedef PtrHash<WebCore::WeakMember<T> > Hash; |
882 }; | 892 }; |
883 | 893 |
| 894 template<typename T> struct DefaultHash<WebCore::Persistent<T> > { |
| 895 typedef PtrHash<WebCore::Persistent<T> > Hash; |
| 896 }; |
| 897 |
884 template<typename T> | 898 template<typename T> |
885 struct NeedsTracing<WebCore::Member<T> > { | 899 struct NeedsTracing<WebCore::Member<T> > { |
886 static const bool value = true; | 900 static const bool value = true; |
887 }; | 901 }; |
888 | 902 |
889 template<typename T> | 903 template<typename T> |
890 struct IsWeak<WebCore::WeakMember<T> > { | 904 struct IsWeak<WebCore::WeakMember<T> > { |
891 static const bool value = true; | 905 static const bool value = true; |
892 }; | 906 }; |
893 | 907 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 }; | 943 }; |
930 | 944 |
931 template<typename T, typename U> | 945 template<typename T, typename U> |
932 struct NeedsTracing<HashMap<T, U> > { | 946 struct NeedsTracing<HashMap<T, U> > { |
933 static const bool value = false; | 947 static const bool value = false; |
934 }; | 948 }; |
935 | 949 |
936 } // namespace WTF | 950 } // namespace WTF |
937 | 951 |
938 #endif | 952 #endif |
OLD | NEW |