#ifndef Worker_h
#define Worker_h
#include "AbstractWorker.h"
#include "ActiveDOMObject.h"
#include "EventListener.h"
#include "EventNames.h"
#include "EventTarget.h"
#include "MessagePort.h"
#include "WorkerScriptLoaderClient.h"
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/text/AtomicStringHash.h>
namespace WebCore {
class ScriptExecutionContext;
class WorkerGlobalScopeProxy;
class WorkerScriptLoader;
typedef int ExceptionCode;
class Worker final : public AbstractWorker, private WorkerScriptLoaderClient {
public:
static PassRefPtr<Worker> create(ScriptExecutionContext&, const String& url, ExceptionCode&);
virtual ~Worker();
virtual EventTargetInterface eventTargetInterface() const override { return WorkerEventTargetInterfaceType; }
void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionCode&);
void postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort*, ExceptionCode&);
void terminate();
virtual bool canSuspend() const override;
virtual void stop() override;
virtual bool hasPendingActivity() const override;
DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
private:
explicit Worker(ScriptExecutionContext&);
void notifyNetworkStateChange(bool isOnline);
virtual void didReceiveResponse(unsigned long identifier, const ResourceResponse&) override;
virtual void notifyFinished() override;
friend void networkStateChanged(bool isOnLine);
RefPtr<WorkerScriptLoader> m_scriptLoader;
WorkerGlobalScopeProxy* m_contextProxy; };
}
#endif // Worker_h