ThreadGlobalData.h [plain text]
#ifndef ThreadGlobalData_h
#define ThreadGlobalData_h
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/text/StringHash.h>
#include <wtf/ThreadSpecific.h>
#include <wtf/Threading.h>
using WTF::ThreadSpecific;
namespace WebCore {
class EventNames;
class ReplayInputTypes;
class ThreadTimers;
struct CachedResourceRequestInitiators;
struct ICUConverterWrapper;
struct TECConverterWrapper;
class ThreadGlobalData {
WTF_MAKE_NONCOPYABLE(ThreadGlobalData);
public:
ThreadGlobalData();
~ThreadGlobalData();
void destroy();
const CachedResourceRequestInitiators& cachedResourceRequestInitiators() { return *m_cachedResourceRequestInitiators; }
EventNames& eventNames() { return *m_eventNames; }
ThreadTimers& threadTimers() { return *m_threadTimers; }
#if ENABLE(WEB_REPLAY)
ReplayInputTypes& inputTypes() { return *m_inputTypes; }
#endif
ICUConverterWrapper& cachedConverterICU() { return *m_cachedConverterICU; }
#if PLATFORM(MAC)
TECConverterWrapper& cachedConverterTEC() { return *m_cachedConverterTEC; }
#endif
#if USE(WEB_THREAD)
void setWebCoreThreadData();
#endif
private:
OwnPtr<CachedResourceRequestInitiators> m_cachedResourceRequestInitiators;
OwnPtr<EventNames> m_eventNames;
OwnPtr<ThreadTimers> m_threadTimers;
#if ENABLE(WEB_REPLAY)
std::unique_ptr<ReplayInputTypes> m_inputTypes;
#endif
#ifndef NDEBUG
bool m_isMainThread;
#endif
OwnPtr<ICUConverterWrapper> m_cachedConverterICU;
#if PLATFORM(MAC)
OwnPtr<TECConverterWrapper> m_cachedConverterTEC;
#endif
static ThreadSpecific<ThreadGlobalData>* staticData;
#if USE(WEB_THREAD)
static ThreadGlobalData* sharedMainThreadStaticData;
#endif
friend ThreadGlobalData& threadGlobalData();
};
#if USE(WEB_THREAD)
ThreadGlobalData& threadGlobalData();
#else
ThreadGlobalData& threadGlobalData() PURE_FUNCTION;
#endif
}
#endif // ThreadGlobalData_h