WorkerMessagingProxy.h [plain text]
#ifndef WorkerMessagingProxy_h
#define WorkerMessagingProxy_h
#if ENABLE(WORKERS)
#include "ScriptExecutionContext.h"
#include "WorkerContextProxy.h"
#include "WorkerLoaderProxy.h"
#include "WorkerObjectProxy.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class DedicatedWorkerThread;
class ScriptExecutionContext;
class Worker;
class WorkerMessagingProxy : public WorkerContextProxy, public WorkerObjectProxy, public WorkerLoaderProxy {
WTF_MAKE_NONCOPYABLE(WorkerMessagingProxy); WTF_MAKE_FAST_ALLOCATED;
public:
WorkerMessagingProxy(Worker*);
virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode);
virtual void terminateWorkerContext();
virtual void postMessageToWorkerContext(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>);
virtual bool hasPendingActivity() const;
virtual void workerObjectDestroyed();
#if ENABLE(INSPECTOR)
virtual void connectToInspector(WorkerContextProxy::PageInspector*);
virtual void disconnectFromInspector();
virtual void sendMessageToInspector(const String&);
#endif
virtual void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>);
virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL);
virtual void postConsoleMessageToWorkerObject(MessageSource, MessageType, MessageLevel, const String& message, int lineNumber, const String& sourceURL);
#if ENABLE(INSPECTOR)
virtual void postMessageToPageInspector(const String&);
virtual void updateInspectorStateCookie(const String&);
#endif
virtual void confirmMessageFromWorkerObject(bool hasPendingActivity);
virtual void reportPendingActivity(bool hasPendingActivity);
virtual void workerContextClosed();
virtual void workerContextDestroyed();
virtual void postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task>);
virtual bool postTaskForModeToWorkerContext(PassOwnPtr<ScriptExecutionContext::Task>, const String& mode);
void workerThreadCreated(PassRefPtr<DedicatedWorkerThread>);
bool askedToTerminate() const { return m_askedToTerminate; }
private:
friend class MessageWorkerTask;
friend class PostMessageToPageInspectorTask;
friend class WorkerContextDestroyedTask;
friend class WorkerExceptionTask;
friend class WorkerThreadActivityReportTask;
virtual ~WorkerMessagingProxy();
void workerContextDestroyedInternal();
void reportPendingActivityInternal(bool confirmingMessage, bool hasPendingActivity);
Worker* workerObject() const { return m_workerObject; }
RefPtr<ScriptExecutionContext> m_scriptExecutionContext;
Worker* m_workerObject;
RefPtr<DedicatedWorkerThread> m_workerThread;
unsigned m_unconfirmedMessageCount; bool m_workerThreadHadPendingActivity;
bool m_askedToTerminate;
Vector<OwnPtr<ScriptExecutionContext::Task> > m_queuedEarlyTasks; #if ENABLE(INSPECTOR)
WorkerContextProxy::PageInspector* m_pageInspector;
#endif
};
}
#endif // ENABLE(WORKERS)
#endif // WorkerMessagingProxy_h