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