ThreadGlobalData.h [plain text]
#ifndef ThreadGlobalData_h
#define ThreadGlobalData_h
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/text/StringHash.h>
namespace WebCore {
class QualifiedNameCache;
class ThreadTimers;
struct CachedResourceRequestInitiators;
struct EventNames;
struct ICUConverterWrapper;
#if USE(WEB_THREAD)
class ThreadGlobalData : public ThreadSafeRefCounted<ThreadGlobalData> {
#else
class ThreadGlobalData {
#endif
WTF_MAKE_NONCOPYABLE(ThreadGlobalData);
WTF_MAKE_FAST_ALLOCATED;
public:
WEBCORE_EXPORT ThreadGlobalData();
WEBCORE_EXPORT ~ThreadGlobalData();
void destroy();
const CachedResourceRequestInitiators& cachedResourceRequestInitiators() { return *m_cachedResourceRequestInitiators; }
EventNames& eventNames() { return *m_eventNames; }
ThreadTimers& threadTimers() { return *m_threadTimers; }
QualifiedNameCache& qualifiedNameCache() { return *m_qualifiedNameCache; }
ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; }
#if USE(WEB_THREAD)
void setWebCoreThreadData();
#endif
private:
std::unique_ptr<CachedResourceRequestInitiators> m_cachedResourceRequestInitiators;
std::unique_ptr<EventNames> m_eventNames;
std::unique_ptr<ThreadTimers> m_threadTimers;
std::unique_ptr<QualifiedNameCache> m_qualifiedNameCache;
#ifndef NDEBUG
bool m_isMainThread;
#endif
std::unique_ptr<ICUConverterWrapper> m_cachedConverterICU;
WEBCORE_EXPORT friend ThreadGlobalData& threadGlobalData();
};
#if USE(WEB_THREAD)
WEBCORE_EXPORT ThreadGlobalData& threadGlobalData();
#else
WEBCORE_EXPORT ThreadGlobalData& threadGlobalData() PURE_FUNCTION;
#endif
}
#endif // ThreadGlobalData_h