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 17 matching lines...) Expand all Loading... |
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/StringHash.h" | 36 #include "wtf/text/StringHash.h" |
37 | 37 |
| 38 namespace blink { |
| 39 |
| 40 // TODO(hajimehoshi): CompressibleStringTable should be moved from blink to WTF |
| 41 // namespace. Fix this forward declaration when we do this. |
| 42 class CompressibleStringTable; |
| 43 |
| 44 typedef void (*CompressibleStringTableDestructor)(CompressibleStringTable*); |
| 45 |
| 46 } |
| 47 |
38 namespace WTF { | 48 namespace WTF { |
39 | 49 |
40 class AtomicStringTable; | 50 class AtomicStringTable; |
41 struct ICUConverterWrapper; | 51 struct ICUConverterWrapper; |
42 | 52 |
43 typedef void (*AtomicStringTableDestructor)(AtomicStringTable*); | 53 typedef void (*AtomicStringTableDestructor)(AtomicStringTable*); |
44 | 54 |
45 class WTF_EXPORT WTFThreadData { | 55 class WTF_EXPORT WTFThreadData { |
46 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 56 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
47 WTF_MAKE_NONCOPYABLE(WTFThreadData); | 57 WTF_MAKE_NONCOPYABLE(WTFThreadData); |
48 public: | 58 public: |
49 WTFThreadData(); | 59 WTFThreadData(); |
50 ~WTFThreadData(); | 60 ~WTFThreadData(); |
51 | 61 |
52 AtomicStringTable* atomicStringTable() | 62 AtomicStringTable* atomicStringTable() |
53 { | 63 { |
54 return m_atomicStringTable; | 64 return m_atomicStringTable; |
55 } | 65 } |
56 | 66 |
| 67 blink::CompressibleStringTable* compressibleStringTable() |
| 68 { |
| 69 return m_compressibleStringTable; |
| 70 } |
| 71 |
57 ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; } | 72 ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; } |
58 | 73 |
59 private: | 74 private: |
60 AtomicStringTable* m_atomicStringTable; | 75 AtomicStringTable* m_atomicStringTable; |
61 AtomicStringTableDestructor m_atomicStringTableDestructor; | 76 AtomicStringTableDestructor m_atomicStringTableDestructor; |
| 77 blink::CompressibleStringTable* m_compressibleStringTable; |
| 78 blink::CompressibleStringTableDestructor m_compressibleStringTableDestructor
; |
62 OwnPtr<ICUConverterWrapper> m_cachedConverterICU; | 79 OwnPtr<ICUConverterWrapper> m_cachedConverterICU; |
63 | 80 |
64 static ThreadSpecific<WTFThreadData>* staticData; | 81 static ThreadSpecific<WTFThreadData>* staticData; |
65 friend WTFThreadData& wtfThreadData(); | 82 friend WTFThreadData& wtfThreadData(); |
66 friend class AtomicStringTable; | 83 friend class AtomicStringTable; |
| 84 friend class blink::CompressibleStringTable; |
67 }; | 85 }; |
68 | 86 |
69 inline WTFThreadData& wtfThreadData() | 87 inline WTFThreadData& wtfThreadData() |
70 { | 88 { |
71 // WRT WebCore: | 89 // WRT WebCore: |
72 // WTFThreadData is used on main thread before it could possibly be used | 90 // WTFThreadData is used on main thread before it could possibly be used |
73 // on secondary ones, so there is no need for synchronization here. | 91 // on secondary ones, so there is no need for synchronization here. |
74 // WRT JavaScriptCore: | 92 // WRT JavaScriptCore: |
75 // wtfThreadData() is initially called from initializeThreading(), ensuri
ng | 93 // wtfThreadData() is initially called from initializeThreading(), ensuri
ng |
76 // this is initially called in a pthread_once locked context. | 94 // this is initially called in a pthread_once locked context. |
77 if (!WTFThreadData::staticData) | 95 if (!WTFThreadData::staticData) |
78 WTFThreadData::staticData = new ThreadSpecific<WTFThreadData>; | 96 WTFThreadData::staticData = new ThreadSpecific<WTFThreadData>; |
79 return **WTFThreadData::staticData; | 97 return **WTFThreadData::staticData; |
80 } | 98 } |
81 | 99 |
82 } // namespace WTF | 100 } // namespace WTF |
83 | 101 |
84 using WTF::WTFThreadData; | 102 using WTF::WTFThreadData; |
85 using WTF::wtfThreadData; | 103 using WTF::wtfThreadData; |
86 | 104 |
87 #endif // WTFThreadData_h | 105 #endif // WTFThreadData_h |
OLD | NEW |