WebCoreJSClientData.h [plain text]
#ifndef WebCoreJSClientData_h
#define WebCoreJSClientData_h
#include "DOMWrapperWorld.h"
#include "DOMObjectHashTableMap.h"
#include <wtf/HashSet.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class WebCoreJSClientData : public JSC::JSGlobalData::ClientData {
WTF_MAKE_NONCOPYABLE(WebCoreJSClientData); WTF_MAKE_FAST_ALLOCATED;
friend class JSGlobalDataWorldIterator;
friend void initNormalWorldClientData(JSC::JSGlobalData*);
public:
WebCoreJSClientData() { }
virtual ~WebCoreJSClientData()
{
ASSERT(m_worldSet.contains(m_normalWorld.get()));
ASSERT(m_worldSet.size() == 1);
ASSERT(m_normalWorld->hasOneRef());
m_normalWorld.clear();
ASSERT(m_worldSet.isEmpty());
}
DOMWrapperWorld* normalWorld() { return m_normalWorld.get(); }
void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds)
{
copyToVector(m_worldSet, worlds);
}
void rememberWorld(DOMWrapperWorld* world)
{
ASSERT(!m_worldSet.contains(world));
m_worldSet.add(world);
}
void forgetWorld(DOMWrapperWorld* world)
{
ASSERT(m_worldSet.contains(world));
m_worldSet.remove(world);
}
DOMObjectHashTableMap hashTableMap;
private:
HashSet<DOMWrapperWorld*> m_worldSet;
RefPtr<DOMWrapperWorld> m_normalWorld;
};
inline void initNormalWorldClientData(JSC::JSGlobalData* globalData)
{
WebCoreJSClientData* webCoreJSClientData = new WebCoreJSClientData;
globalData->clientData = webCoreJSClientData; webCoreJSClientData->m_normalWorld = DOMWrapperWorld::create(globalData, true);
}
}
#endif // WebCoreJSClientData_h