OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 #ifndef WTFThreadData_h | 27 #ifndef WTFThreadData_h |
28 #define WTFThreadData_h | 28 #define WTFThreadData_h |
29 | 29 |
30 #include "wtf/HashMap.h" | 30 #include "wtf/HashMap.h" |
31 #include "wtf/HashSet.h" | 31 #include "wtf/HashSet.h" |
32 #include "wtf/Noncopyable.h" | 32 #include "wtf/Noncopyable.h" |
33 #include "wtf/ThreadSpecific.h" | 33 #include "wtf/ThreadSpecific.h" |
34 #include "wtf/Threading.h" | 34 #include "wtf/Threading.h" |
35 #include "wtf/WTFExport.h" | 35 #include "wtf/WTFExport.h" |
| 36 #include "wtf/text/AtomicStringTable.h" |
36 #include "wtf/text/StringHash.h" | 37 #include "wtf/text/StringHash.h" |
37 #include <memory> | 38 #include <memory> |
38 | 39 |
39 namespace blink { | 40 namespace blink { |
40 | 41 |
41 // TODO(hajimehoshi): CompressibleStringTable should be moved from blink to WTF | 42 // TODO(hajimehoshi): CompressibleStringTable should be moved from blink to WTF |
42 // namespace. Fix this forward declaration when we do this. | 43 // namespace. Fix this forward declaration when we do this. |
43 class CompressibleStringTable; | 44 class CompressibleStringTable; |
44 | 45 |
45 typedef void (*CompressibleStringTableDestructor)(CompressibleStringTable*); | 46 typedef void (*CompressibleStringTableDestructor)(CompressibleStringTable*); |
46 | 47 |
47 } | 48 } |
48 | 49 |
49 namespace WTF { | 50 namespace WTF { |
50 | 51 |
51 class AtomicStringTable; | |
52 struct ICUConverterWrapper; | 52 struct ICUConverterWrapper; |
53 | 53 |
54 typedef void (*AtomicStringTableDestructor)(AtomicStringTable*); | |
55 | |
56 class WTF_EXPORT WTFThreadData { | 54 class WTF_EXPORT WTFThreadData { |
57 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 55 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
58 WTF_MAKE_NONCOPYABLE(WTFThreadData); | 56 WTF_MAKE_NONCOPYABLE(WTFThreadData); |
59 public: | 57 public: |
60 WTFThreadData(); | 58 WTFThreadData(); |
61 ~WTFThreadData(); | 59 ~WTFThreadData(); |
62 | 60 |
63 AtomicStringTable* getAtomicStringTable() | 61 AtomicStringTable& getAtomicStringTable() |
64 { | 62 { |
65 return m_atomicStringTable; | 63 return *m_atomicStringTable; |
66 } | 64 } |
67 | 65 |
68 blink::CompressibleStringTable* compressibleStringTable() | 66 blink::CompressibleStringTable* compressibleStringTable() |
69 { | 67 { |
70 return m_compressibleStringTable; | 68 return m_compressibleStringTable; |
71 } | 69 } |
72 | 70 |
73 ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; } | 71 ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; } |
74 | 72 |
75 private: | 73 private: |
76 AtomicStringTable* m_atomicStringTable; | 74 std::unique_ptr<AtomicStringTable> m_atomicStringTable; |
77 AtomicStringTableDestructor m_atomicStringTableDestructor; | |
78 blink::CompressibleStringTable* m_compressibleStringTable; | 75 blink::CompressibleStringTable* m_compressibleStringTable; |
79 blink::CompressibleStringTableDestructor m_compressibleStringTableDestructor
; | 76 blink::CompressibleStringTableDestructor m_compressibleStringTableDestructor
; |
80 std::unique_ptr<ICUConverterWrapper> m_cachedConverterICU; | 77 std::unique_ptr<ICUConverterWrapper> m_cachedConverterICU; |
81 | 78 |
82 static ThreadSpecific<WTFThreadData>* staticData; | 79 static ThreadSpecific<WTFThreadData>* staticData; |
83 friend WTFThreadData& wtfThreadData(); | 80 friend WTFThreadData& wtfThreadData(); |
84 friend class AtomicStringTable; | |
85 friend class blink::CompressibleStringTable; | 81 friend class blink::CompressibleStringTable; |
86 }; | 82 }; |
87 | 83 |
88 inline WTFThreadData& wtfThreadData() | 84 inline WTFThreadData& wtfThreadData() |
89 { | 85 { |
90 // WTFThreadData is used on main thread before it could possibly be used | 86 // WTFThreadData is used on main thread before it could possibly be used |
91 // on secondary ones, so there is no need for synchronization here. | 87 // on secondary ones, so there is no need for synchronization here. |
92 if (!WTFThreadData::staticData) | 88 if (!WTFThreadData::staticData) |
93 WTFThreadData::staticData = new ThreadSpecific<WTFThreadData>; | 89 WTFThreadData::staticData = new ThreadSpecific<WTFThreadData>; |
94 return **WTFThreadData::staticData; | 90 return **WTFThreadData::staticData; |
95 } | 91 } |
96 | 92 |
97 } // namespace WTF | 93 } // namespace WTF |
98 | 94 |
99 using WTF::WTFThreadData; | 95 using WTF::WTFThreadData; |
100 using WTF::wtfThreadData; | 96 using WTF::wtfThreadData; |
101 | 97 |
102 #endif // WTFThreadData_h | 98 #endif // WTFThreadData_h |
OLD | NEW |