WorkerContextExecutionProxy.h [plain text]
#ifndef WorkerContextExecutionProxy_h
#define WorkerContextExecutionProxy_h
#if ENABLE(WORKERS)
#include <v8.h>
#include "V8EventListenerList.h"
#include "V8Index.h"
#include <wtf/OwnPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class Event;
class EventTarget;
class V8EventListener;
class V8WorkerContextEventListener;
class WorkerContext;
class WorkerContextExecutionProxy {
public:
WorkerContextExecutionProxy(WorkerContext*);
~WorkerContextExecutionProxy();
v8::Local<v8::Context> GetContext() { return v8::Local<v8::Context>::New(m_context); }
v8::Local<v8::Function> GetConstructor(V8ClassIndex::V8WrapperType);
void RemoveEventListener(V8EventListener*);
static v8::Handle<v8::Value> ToV8Object(V8ClassIndex::V8WrapperType type, void* impl);
static v8::Handle<v8::Value> EventToV8Object(Event* event);
static v8::Handle<v8::Value> EventTargetToV8Object(EventTarget* target);
static v8::Handle<v8::Value> WorkerContextToV8Object(WorkerContext* wc);
PassRefPtr<V8EventListener> findOrCreateEventListener(v8::Local<v8::Value> listener, bool isInline, bool findOnly);
PassRefPtr<V8EventListener> findOrCreateObjectEventListener(v8::Local<v8::Value> object, bool isInline, bool findOnly);
void trackEvent(Event*);
v8::Local<v8::Value> evaluate(const String& script, const String& fileName, int baseLine);
WorkerContext* workerContext() { return m_workerContext; }
static WorkerContextExecutionProxy* retrieve();
static bool isWebWorkersEnabled();
static void setIsWebWorkersEnabled(bool);
private:
void initV8IfNeeded();
void initContextIfNeeded();
void dispose();
PassRefPtr<V8EventListener> findOrCreateEventListenerHelper(v8::Local<v8::Value> object, bool isInline, bool findOnly, bool createObjectEventListener);
v8::Local<v8::Value> runScript(v8::Handle<v8::Script>);
static v8::Local<v8::Object> toV8(V8ClassIndex::V8WrapperType descType, V8ClassIndex::V8WrapperType cptrType, void* impl);
static bool forgetV8EventObject(Event*);
WorkerContext* m_workerContext;
v8::Persistent<v8::Context> m_context;
int m_recursion;
OwnPtr<V8EventListenerList> m_listeners;
Vector<Event*> m_events;
};
}
#endif // ENABLE(WORKERS)
#endif // WorkerContextExecutionProxy_h