#ifndef WebSharedWorkerImpl_h
#define WebSharedWorkerImpl_h
#include "WebSharedWorker.h"
#include "WebContentSecurityPolicy.h"
#include "WebFrameClient.h"
#include "WebSharedWorkerClient.h"
#include "core/dom/ExecutionContext.h"
#include "core/workers/WorkerLoaderProxy.h"
#include "core/workers/WorkerReportingProxy.h"
#include "core/workers/WorkerScriptLoaderClient.h"
#include "core/workers/WorkerThread.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefPtr.h"
#include "wtf/WeakPtr.h"
namespace WebCore {
class ResourceResponse;
}
namespace blink {
class WebApplicationCacheHost;
class WebApplicationCacheHostClient;
class WebWorkerClient;
class WebSecurityOrigin;
class WebString;
class WebURL;
class WebView;
class WebWorker;
class WebSharedWorkerClient;
class WebSharedWorkerImpl FINAL
: public WebCore::WorkerReportingProxy
, public WebCore::WorkerLoaderProxy
, public WebFrameClient
, public WebSharedWorker {
public:
explicit WebSharedWorkerImpl(WebSharedWorkerClient*);
virtual void reportException(
const WTF::String&, int, int, const WTF::String&) OVERRIDE;
virtual void reportConsoleMessage(
WebCore::MessageSource, WebCore::MessageLevel,
const WTF::String&, int, const WTF::String&) OVERRIDE;
virtual void postMessageToPageInspector(const WTF::String&) OVERRIDE;
virtual void updateInspectorStateCookie(const WTF::String&) OVERRIDE;
virtual void workerGlobalScopeStarted(WebCore::WorkerGlobalScope*) OVERRIDE;
virtual void workerGlobalScopeClosed() OVERRIDE;
virtual void workerGlobalScopeDestroyed() OVERRIDE;
virtual void postTaskToLoader(PassOwnPtr<WebCore::ExecutionContextTask>) OVERRIDE;
virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<WebCore::ExecutionContextTask>) OVERRIDE;
virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*, WebApplicationCacheHostClient*) OVERRIDE;
virtual void didFinishDocumentLoad(WebLocalFrame*) OVERRIDE;
virtual void startWorkerContext(const WebURL&, const WebString& name, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType) OVERRIDE;
virtual void connect(WebMessagePortChannel*) OVERRIDE;
virtual void terminateWorkerContext() OVERRIDE;
virtual void clientDestroyed() OVERRIDE;
virtual void pauseWorkerContextOnStart() OVERRIDE;
virtual void resumeWorkerContext() OVERRIDE;
virtual void attachDevTools() OVERRIDE;
virtual void reattachDevTools(const WebString& savedState) OVERRIDE;
virtual void detachDevTools() OVERRIDE;
virtual void dispatchDevToolsMessage(const WebString&) OVERRIDE;
private:
class Loader;
virtual ~WebSharedWorkerImpl();
WebSharedWorkerClient* client() { return m_client->get(); }
void setWorkerThread(PassRefPtr<WebCore::WorkerThread> thread) { m_workerThread = thread; }
WebCore::WorkerThread* workerThread() { return m_workerThread.get(); }
void stopWorkerThread();
void initializeLoader(const WebURL&);
void didReceiveScriptLoaderResponse();
void onScriptLoaderFinished();
static void connectTask(WebCore::ExecutionContext*, PassOwnPtr<WebMessagePortChannel>);
void workerGlobalScopeClosedOnMainThread();
void workerGlobalScopeDestroyedOnMainThread();
RefPtr<WebCore::ExecutionContext> m_loadingDocument;
WebView* m_webView;
WebFrame* m_mainFrame;
bool m_askedToTerminate;
RefPtr<WebCore::WorkerThread> m_workerThread;
RefPtr<WeakReference<WebSharedWorkerClient> > m_client;
WeakPtr<WebSharedWorkerClient> m_clientWeakPtr;
bool m_pauseWorkerContextOnStart;
bool m_attachDevToolsOnStart;
OwnPtr<Loader> m_mainScriptLoader;
WebURL m_url;
WebString m_name;
WebString m_contentSecurityPolicy;
WebContentSecurityPolicyType m_policyType;
};
}
#endif