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::VM::ClientData {
WTF_MAKE_NONCOPYABLE(WebCoreJSClientData); WTF_MAKE_FAST_ALLOCATED;
friend class VMWorldIterator;
friend void initNormalWorldClientData(JSC::VM*);
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::VM* vm)
{
WebCoreJSClientData* webCoreJSClientData = new WebCoreJSClientData;
vm->clientData = webCoreJSClientData; webCoreJSClientData->m_normalWorld = DOMWrapperWorld::create(vm, true);
}
}
#endif // WebCoreJSClientData_h