WorkerMessagingProxy.h [plain text]
#pragma once
#include "WorkerGlobalScopeProxy.h"
#include "WorkerDebuggerProxy.h"
#include "WorkerLoaderProxy.h"
#include "WorkerObjectProxy.h"
#include <wtf/MonotonicTime.h>
#include <wtf/ThreadSafeRefCounted.h>
namespace WebCore {
class DedicatedWorkerThread;
class WorkerInspectorProxy;
class WorkerMessagingProxy final : public ThreadSafeRefCounted<WorkerMessagingProxy>, public WorkerGlobalScopeProxy, public WorkerObjectProxy, public WorkerLoaderProxy, public WorkerDebuggerProxy {
WTF_MAKE_FAST_ALLOCATED;
public:
explicit WorkerMessagingProxy(Worker&);
virtual ~WorkerMessagingProxy();
private:
void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) final;
void terminateWorkerGlobalScope() final;
void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final;
bool hasPendingActivity() const final;
void workerObjectDestroyed() final;
void notifyNetworkStateChange(bool isOnline) final;
void postMessageToWorkerObject(MessageWithMessagePorts&&) final;
void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) final;
void confirmMessageFromWorkerObject(bool hasPendingActivity) final;
void reportPendingActivity(bool hasPendingActivity) final;
void workerGlobalScopeClosed() final;
void workerGlobalScopeDestroyed() final;
void postMessageToDebugger(const String&) final;
void setResourceCachingDisabled(bool) final;
void postTaskToLoader(ScriptExecutionContext::Task&&) final;
bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&&, const String& mode) final;
Ref<CacheStorageConnection> createCacheStorageConnection() final;
void workerThreadCreated(DedicatedWorkerThread&);
bool askedToTerminate() const { return m_askedToTerminate; }
void workerGlobalScopeDestroyedInternal();
void reportPendingActivityInternal(bool confirmingMessage, bool hasPendingActivity);
Worker* workerObject() const { return m_workerObject; }
RefPtr<ScriptExecutionContext> m_scriptExecutionContext;
std::unique_ptr<WorkerInspectorProxy> m_inspectorProxy;
Worker* m_workerObject;
bool m_mayBeDestroyed { false };
RefPtr<DedicatedWorkerThread> m_workerThread;
unsigned m_unconfirmedMessageCount { 0 }; bool m_workerThreadHadPendingActivity { false };
bool m_askedToTerminate { false };
Vector<std::unique_ptr<ScriptExecutionContext::Task>> m_queuedEarlyTasks; };
}