#ifndef Worker_h
#define Worker_h
#include "AbstractWorker.h"
#include "ActiveDOMObject.h"
#include "ContentSecurityPolicyResponseHeaders.h"
#include "EventListener.h"
#include "EventTarget.h"
#include "MessagePort.h"
#include "WorkerScriptLoaderClient.h"
#include <wtf/Forward.h>
#include <wtf/Optional.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, public ActiveDOMObject, private WorkerScriptLoaderClient {
public:
static RefPtr<Worker> create(ScriptExecutionContext&, const String& url, ExceptionCode&);
virtual ~Worker();
EventTargetInterface eventTargetInterface() const override { return WorkerEventTargetInterfaceType; }
void postMessage(RefPtr<SerializedScriptValue>&& message, const MessagePortArray*, ExceptionCode&);
void postMessage(RefPtr<SerializedScriptValue>&& message, MessagePort*, ExceptionCode&);
void terminate();
ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
bool hasPendingActivity() const override;
private:
explicit Worker(ScriptExecutionContext&);
void notifyNetworkStateChange(bool isOnline);
void didReceiveResponse(unsigned long identifier, const ResourceResponse&) override;
void notifyFinished() override;
bool canSuspendForDocumentSuspension() const override;
void stop() override;
const char* activeDOMObjectName() const override;
friend void networkStateChanged(bool isOnLine);
RefPtr<WorkerScriptLoader> m_scriptLoader;
WorkerGlobalScopeProxy* m_contextProxy; Optional<ContentSecurityPolicyResponseHeaders> m_contentSecurityPolicyResponseHeaders;
bool m_shouldBypassMainWorldContentSecurityPolicy { false };
};
}
#endif // Worker_h