Commit 7442ffad authored by dslomov@google.com's avatar dslomov@google.com

https://bugs.webkit.org/show_bug.cgi?id=61016

[WebWorkers][Chromium] Use v8 Isolates for in-process implementation of WebWorkers.
This adds an implementation of in-process dedicated workers to chromium port.
The crux of the matter is the reimplementation of WebWorkerClientImpl. WebWorkerClientImpl now
implements all three of Worker{Loader,Context,Object}Proxies and delegates the implementation to
WebKit's standard WorkerMessagingProxy.
For now, we have 3 implementations of workers in chromium WebKit:
  - In-process dedicated workers (this checkin)
  - Inter-process shared workers
  - Inter-process dedicated workers (defunct after this checkin)
This patch extracts some new common interfaces (NewWebWorkerBase and NewWebWorkerClient) for these
three implementations.
Removing the remainings of inter-process dedicated workers -related classes is left for a separate patch
(it will require coordinated changes on chromuium side).

Reviewed by David Levin.

* public/WebCommonWorkerClient.h:
* src/DatabaseObserver.cpp:
(WebKit::AllowDatabaseMainThreadBridge::create):
(WebKit::AllowDatabaseMainThreadBridge::AllowDatabaseMainThreadBridge):
(WebKit::AllowDatabaseMainThreadBridge::allowDatabaseTask):
(WebKit::allowDatabaseForWorker):
(WebCore::DatabaseObserver::canEstablishDatabase):
* src/LocalFileSystemChromium.cpp:
(WebCore::openFileSystemHelper):
* src/WebSharedWorkerImpl.h:
(WebKit::WebSharedWorkerImpl::newCommonClient):
* src/WebWorkerBase.h:
(WebKit::WebWorkerBase::view):
* src/WebWorkerClientImpl.cpp:
(WebKit::WebWorkerClientImpl::createWorkerContextProxy):
(WebKit::WebWorkerClientImpl::startWorkerContext):
(WebKit::WebWorkerClientImpl::terminateWorkerContext):
(WebKit::WebWorkerClientImpl::postMessageToWorkerContext):
(WebKit::WebWorkerClientImpl::hasPendingActivity):
(WebKit::WebWorkerClientImpl::workerObjectDestroyed):
(WebKit::WebWorkerClientImpl::connectToInspector):
(WebKit::WebWorkerClientImpl::disconnectFromInspector):
(WebKit::WebWorkerClientImpl::sendMessageToInspector):
(WebKit::WebWorkerClientImpl::postMessageToPageInspector):
(WebKit::WebWorkerClientImpl::postTaskToLoader):
(WebKit::WebWorkerClientImpl::postTaskForModeToWorkerContext):
(WebKit::WebWorkerClientImpl::postMessageToWorkerObject):
(WebKit::WebWorkerClientImpl::confirmMessageFromWorkerObject):
(WebKit::WebWorkerClientImpl::reportPendingActivity):
(WebKit::WebWorkerClientImpl::workerContextClosed):
(WebKit::WebWorkerClientImpl::postExceptionToWorkerObject):
(WebKit::WebWorkerClientImpl::postConsoleMessageToWorkerObject):
(WebKit::WebWorkerClientImpl::workerContextDestroyed):
(WebKit::WebWorkerClientImpl::allowFileSystem):
(WebKit::WebWorkerClientImpl::openFileSystem):
(WebKit::WebWorkerClientImpl::allowDatabase):
(WebKit::WebWorkerClientImpl::dispatchDevToolsMessage):
(WebKit::WebWorkerClientImpl::view):
(WebKit::WebWorkerClientImpl::WebWorkerClientImpl):
(WebKit::WebWorkerClientImpl::~WebWorkerClientImpl):
* src/WebWorkerClientImpl.h:
(WebKit::WebWorkerClientImpl::newCommonClient):
* src/WebWorkerImpl.cpp:
(WebKit::WebWorkerImpl::newCommonClient):
* src/WebWorkerImpl.h:
* src/WorkerFileSystemCallbacksBridge.cpp:
(WebKit::WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread):
(WebKit::WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread):
* src/WorkerFileSystemCallbacksBridge.h:

git-svn-id: svn://svn.chromium.org/blink/trunk@93330 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent a280e074
2011-08-15 Dmitry Lomov <dslomov@google.com>
https://bugs.webkit.org/show_bug.cgi?id=61016
[WebWorkers][Chromium] Use v8 Isolates for in-process implementation of WebWorkers.
This adds an implementation of in-process dedicated workers to chromium port.
The crux of the matter is the reimplementation of WebWorkerClientImpl. WebWorkerClientImpl now
implements all three of Worker{Loader,Context,Object}Proxies and delegates the implementation to
WebKit's standard WorkerMessagingProxy.
For now, we have 3 implementations of workers in chromium WebKit:
- In-process dedicated workers (this checkin)
- Inter-process shared workers
- Inter-process dedicated workers (defunct after this checkin)
This patch extracts some new common interfaces (NewWebWorkerBase and NewWebWorkerClient) for these
three implementations.
Removing the remainings of inter-process dedicated workers -related classes is left for a separate patch
(it will require coordinated changes on chromuium side).
Reviewed by David Levin.
* public/WebCommonWorkerClient.h:
* src/DatabaseObserver.cpp:
(WebKit::AllowDatabaseMainThreadBridge::create):
(WebKit::AllowDatabaseMainThreadBridge::AllowDatabaseMainThreadBridge):
(WebKit::AllowDatabaseMainThreadBridge::allowDatabaseTask):
(WebKit::allowDatabaseForWorker):
(WebCore::DatabaseObserver::canEstablishDatabase):
* src/LocalFileSystemChromium.cpp:
(WebCore::openFileSystemHelper):
* src/WebSharedWorkerImpl.h:
(WebKit::WebSharedWorkerImpl::newCommonClient):
* src/WebWorkerBase.h:
(WebKit::WebWorkerBase::view):
* src/WebWorkerClientImpl.cpp:
(WebKit::WebWorkerClientImpl::createWorkerContextProxy):
(WebKit::WebWorkerClientImpl::startWorkerContext):
(WebKit::WebWorkerClientImpl::terminateWorkerContext):
(WebKit::WebWorkerClientImpl::postMessageToWorkerContext):
(WebKit::WebWorkerClientImpl::hasPendingActivity):
(WebKit::WebWorkerClientImpl::workerObjectDestroyed):
(WebKit::WebWorkerClientImpl::connectToInspector):
(WebKit::WebWorkerClientImpl::disconnectFromInspector):
(WebKit::WebWorkerClientImpl::sendMessageToInspector):
(WebKit::WebWorkerClientImpl::postMessageToPageInspector):
(WebKit::WebWorkerClientImpl::postTaskToLoader):
(WebKit::WebWorkerClientImpl::postTaskForModeToWorkerContext):
(WebKit::WebWorkerClientImpl::postMessageToWorkerObject):
(WebKit::WebWorkerClientImpl::confirmMessageFromWorkerObject):
(WebKit::WebWorkerClientImpl::reportPendingActivity):
(WebKit::WebWorkerClientImpl::workerContextClosed):
(WebKit::WebWorkerClientImpl::postExceptionToWorkerObject):
(WebKit::WebWorkerClientImpl::postConsoleMessageToWorkerObject):
(WebKit::WebWorkerClientImpl::workerContextDestroyed):
(WebKit::WebWorkerClientImpl::allowFileSystem):
(WebKit::WebWorkerClientImpl::openFileSystem):
(WebKit::WebWorkerClientImpl::allowDatabase):
(WebKit::WebWorkerClientImpl::dispatchDevToolsMessage):
(WebKit::WebWorkerClientImpl::view):
(WebKit::WebWorkerClientImpl::WebWorkerClientImpl):
(WebKit::WebWorkerClientImpl::~WebWorkerClientImpl):
* src/WebWorkerClientImpl.h:
(WebKit::WebWorkerClientImpl::newCommonClient):
* src/WebWorkerImpl.cpp:
(WebKit::WebWorkerImpl::newCommonClient):
* src/WebWorkerImpl.h:
* src/WorkerFileSystemCallbacksBridge.cpp:
(WebKit::WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread):
(WebKit::WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread):
* src/WorkerFileSystemCallbacksBridge.h:
2011-08-18 James Robinson <jamesr@chromium.org>
[chromium] Draw the root/"non-composited content" in compositor side
......
......@@ -44,12 +44,24 @@ class WebString;
class WebWorker;
class WebWorkerClient;
class NewWebCommonWorkerClient {
public:
// Called on the main webkit thread before opening a web database.
virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize) = 0;
// Called on the main webkit thread before opening a file system.
virtual bool allowFileSystem() = 0;
// Called on the main webkit thread before opening a file system.
virtual void openFileSystem(WebFileSystem::Type, long long size, bool create, WebFileSystemCallbacks*) = 0;
};
// Provides an interface back to the in-page script object for a worker.
// This interface contains common APIs used by both shared and dedicated
// workers.
// All functions are expected to be called back on the thread that created
// the Worker object, unless noted.
class WebCommonWorkerClient {
class WebCommonWorkerClient : public NewWebCommonWorkerClient {
public:
virtual void postExceptionToWorkerObject(
const WebString& errorString, int lineNumber,
......
......@@ -46,7 +46,7 @@
#include "WebPermissionClient.h"
#include "WebSecurityOrigin.h"
#include "WebViewImpl.h"
#include "WebWorkerImpl.h"
#include "WebWorkerBase.h"
#include "WorkerContext.h"
#include "WorkerLoaderProxy.h"
#include "WorkerScriptController.h"
......@@ -64,7 +64,7 @@ static const char allowDatabaseMode[] = "allowDatabaseMode";
// call back to the worker context.
class AllowDatabaseMainThreadBridge : public ThreadSafeRefCounted<AllowDatabaseMainThreadBridge> {
public:
static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebCore::WorkerLoaderProxy* workerLoaderProxy, const WTF::String& mode, WebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String& name, const WTF::String& displayName, unsigned long estimatedSize)
static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebCore::WorkerLoaderProxy* workerLoaderProxy, const WTF::String& mode, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String& name, const WTF::String& displayName, unsigned long estimatedSize)
{
return adoptRef(new AllowDatabaseMainThreadBridge(workerLoaderProxy, mode, commonClient, frame, name, displayName, estimatedSize));
}
......@@ -92,7 +92,7 @@ public:
}
private:
AllowDatabaseMainThreadBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, const WTF::String& mode, WebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String& name, const WTF::String& displayName, unsigned long estimatedSize)
AllowDatabaseMainThreadBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, const WTF::String& mode, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String& name, const WTF::String& displayName, unsigned long estimatedSize)
: m_workerLoaderProxy(workerLoaderProxy)
, m_mode(mode)
{
......@@ -103,7 +103,7 @@ private:
WebCore::AllowCrossThreadAccess(this)));
}
static void allowDatabaseTask(WebCore::ScriptExecutionContext* context, WebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String name, const WTF::String displayName, unsigned long estimatedSize, PassRefPtr<AllowDatabaseMainThreadBridge> bridge)
static void allowDatabaseTask(WebCore::ScriptExecutionContext* context, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const WTF::String name, const WTF::String displayName, unsigned long estimatedSize, PassRefPtr<AllowDatabaseMainThreadBridge> bridge)
{
if (commonClient)
bridge->signalCompleted(commonClient->allowDatabase(frame, name, displayName, estimatedSize));
......@@ -122,7 +122,7 @@ private:
WTF::String m_mode;
};
bool allowDatabaseForWorker(WebCommonWorkerClient* commonClient, WebFrame* frame, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
bool allowDatabaseForWorker(NewWebCommonWorkerClient* commonClient, WebFrame* frame, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
{
WebCore::WorkerScriptController* controller = WebCore::WorkerScriptController::controllerForContext();
WebCore::WorkerContext* workerContext = controller->workerContext();
......@@ -165,8 +165,8 @@ bool DatabaseObserver::canEstablishDatabase(ScriptExecutionContext* scriptExecut
#if ENABLE(WORKERS)
WorkerContext* workerContext = static_cast<WorkerContext*>(scriptExecutionContext);
WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
return allowDatabaseForWorker(webWorker->commonClient(), webWorker->webView()->mainFrame(), name, displayName, estimatedSize);
NewWebWorkerBase* webWorker = static_cast<NewWebWorkerBase*>(workerLoaderProxy);
return allowDatabaseForWorker(webWorker->newCommonClient(), webWorker->view()->mainFrame(), name, displayName, estimatedSize);
#else
ASSERT_NOT_REACHED();
#endif
......
......@@ -40,7 +40,6 @@
#include "FileSystemCallback.h"
#include "FileSystemCallbacks.h"
#include "PlatformString.h"
#include "WebCommonWorkerClient.h"
#include "WebFileError.h"
#include "WebFileSystem.h"
#include "WebFileSystemCallbacksImpl.h"
......@@ -48,7 +47,7 @@
#include "WebFrameImpl.h"
#include "WebPermissionClient.h"
#include "WebViewImpl.h"
#include "WebWorkerImpl.h"
#include "WebWorkerBase.h"
#include "WorkerContext.h"
#include "WorkerFileSystemCallbacksBridge.h"
#include "WorkerThread.h"
......@@ -80,7 +79,7 @@ static const char openFileSystemMode[] = "openFileSystemMode";
// call back to the worker context.
class AllowFileSystemMainThreadBridge : public ThreadSafeRefCounted<AllowFileSystemMainThreadBridge> {
public:
static PassRefPtr<AllowFileSystemMainThreadBridge> create(WebCore::WorkerLoaderProxy* workerLoaderProxy, const WTF::String& mode, WebCommonWorkerClient* commonClient)
static PassRefPtr<AllowFileSystemMainThreadBridge> create(WebCore::WorkerLoaderProxy* workerLoaderProxy, const WTF::String& mode, NewWebCommonWorkerClient* commonClient)
{
return adoptRef(new AllowFileSystemMainThreadBridge(workerLoaderProxy, mode, commonClient));
}
......@@ -107,7 +106,7 @@ public:
}
private:
AllowFileSystemMainThreadBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, const WTF::String& mode, WebCommonWorkerClient* commonClient)
AllowFileSystemMainThreadBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, const WTF::String& mode, NewWebCommonWorkerClient* commonClient)
: m_workerLoaderProxy(workerLoaderProxy)
, m_mode(mode)
{
......@@ -116,7 +115,7 @@ private:
AllowCrossThreadAccess(this)));
}
static void allowFileSystemTask(WebCore::ScriptExecutionContext* context, WebCommonWorkerClient* commonClient, PassRefPtr<AllowFileSystemMainThreadBridge> bridge)
static void allowFileSystemTask(WebCore::ScriptExecutionContext* context, NewWebCommonWorkerClient* commonClient, PassRefPtr<AllowFileSystemMainThreadBridge> bridge)
{
if (commonClient)
bridge->signalCompleted(commonClient->allowFileSystem());
......@@ -135,7 +134,7 @@ private:
WTF::String m_mode;
};
bool allowFileSystemForWorker(WebCommonWorkerClient* commonClient)
bool allowFileSystemForWorker(NewWebCommonWorkerClient* commonClient)
{
WorkerScriptController* controller = WorkerScriptController::controllerForContext();
WorkerContext* workerContext = controller->workerContext();
......@@ -158,7 +157,7 @@ bool allowFileSystemForWorker(WebCommonWorkerClient* commonClient)
return bridge->result();
}
void openFileSystemForWorker(WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, WebFileSystemCallbacks* callbacks, bool synchronous)
void openFileSystemForWorker(NewWebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, WebFileSystemCallbacks* callbacks, bool synchronous)
{
WorkerScriptController* controller = WorkerScriptController::controllerForContext();
WorkerContext* workerContext = controller->workerContext();
......@@ -204,11 +203,12 @@ static void openFileSystemHelper(ScriptExecutionContext* context, AsyncFileSyste
#if ENABLE(WORKERS)
WorkerContext* workerContext = static_cast<WorkerContext*>(context);
WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
if (!allowFileSystemForWorker(webWorker->commonClient()))
NewWebWorkerBase* webWorker = static_cast<NewWebWorkerBase*>(workerLoaderProxy);
if (!allowFileSystemForWorker(webWorker->newCommonClient()))
allowed = false;
else
openFileSystemForWorker(webWorker->commonClient(), static_cast<WebFileSystem::Type>(type), size, create == CreateIfNotPresent, new WebFileSystemCallbacksImpl(callbacks, type, context, synchronous), synchronous);
openFileSystemForWorker(webWorker->newCommonClient(), static_cast<WebFileSystem::Type>(type), size, create == CreateIfNotPresent, new WebFileSystemCallbacksImpl(callbacks, type, context, synchronous), synchronous);
#else
ASSERT_NOT_REACHED();
#endif
......
......@@ -64,6 +64,9 @@ public:
WebWorkerClient* client();
WebCommonWorkerClient* commonClient() { return m_client; }
// NewWebWorkerBase methods:
NewWebCommonWorkerClient* newCommonClient() { return m_client; }
private:
virtual ~WebSharedWorkerImpl();
......
......@@ -34,9 +34,11 @@
#if ENABLE(WORKERS)
#include "ScriptExecutionContext.h"
#include "WebCommonWorkerClient.h"
#include "WebFrameClient.h"
#include "WorkerLoaderProxy.h"
#include "WorkerObjectProxy.h"
#include "WorkerThread.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/RefPtr.h>
......@@ -55,17 +57,27 @@ class WebView;
class WebWorker;
class WebWorkerClient;
// Base class for WebSharedWorkerImpl, WebWorkerClientImpl and (defunct) WebWorkerImpl
// containing common interface for shared workers and dedicated in-proc workers implementation.
//
// FIXME: Rename this class into WebWorkerBase, merge existing WebWorkerBase and WebSharedWorker.
class NewWebWorkerBase : public WebCore::WorkerLoaderProxy {
public:
virtual NewWebCommonWorkerClient* newCommonClient() = 0;
virtual WebView* view() const = 0;
};
// Base class for WebSharedWorkerImpl and WebWorkerImpl. It contains common
// code used by both implementation classes, including implementations of the
// WorkerObjectProxy and WorkerLoaderProxy interfaces.
class WebWorkerBase : public WebCore::WorkerObjectProxy
, public WebCore::WorkerLoaderProxy
, public NewWebWorkerBase
, public WebFrameClient {
public:
WebWorkerBase();
virtual ~WebWorkerBase();
// WebCore::WorkerObjectProxy methods:
// WebCommonWorkerBase methods:
virtual void postMessageToWorkerObject(
PassRefPtr<WebCore::SerializedScriptValue>,
PassOwnPtr<WebCore::MessagePortChannelArray>);
......@@ -79,6 +91,7 @@ public:
virtual void reportPendingActivity(bool);
virtual void workerContextClosed();
virtual void workerContextDestroyed();
virtual WebView* view() const { return m_webView; }
// WebCore::WorkerLoaderProxy methods:
virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
......@@ -92,11 +105,8 @@ public:
// Executes the given task on the main thread.
static void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
WebView* webView() const { return m_webView; }
virtual WebCommonWorkerClient* commonClient() = 0;
protected:
virtual WebCommonWorkerClient* commonClient() = 0;
virtual WebWorkerClient* client() = 0;
void setWorkerThread(PassRefPtr<WebCore::WorkerThread> thread) { m_workerThread = thread; }
......
......@@ -33,37 +33,40 @@
#if ENABLE(WORKERS)
#include "ScriptExecutionContext.h"
#include "WorkerContextProxy.h"
#include "WorkerLoaderProxy.h"
#include "WorkerMessagingProxy.h"
#include "WorkerObjectProxy.h"
#include "WebFileSystem.h"
#include "WebWorkerBase.h"
#include "WebWorkerClient.h"
#include "WorkerContextProxy.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class ScriptExecutionContext;
}
namespace WebKit {
class WebWorker;
class WebFrameImpl;
// The purpose of this class is to provide a WorkerContextProxy
// implementation that we can give to WebKit. Internally, it converts the
// data types to Chrome compatible ones so that renderer code can use it over
// IPC.
// This class provides chromium implementation for WorkerContextProxt, WorkerObjectProxy amd WorkerLoaderProxy
// for in-proc dedicated workers. It also acts as a bridge for workers to chromium implementation of file systems,
// databases and other related functionality.
//
// In essence, this class wraps WorkerMessagingProxy.
class WebWorkerClientImpl : public WebCore::WorkerContextProxy
, public WebWorkerClient {
, public WebCore::WorkerObjectProxy
, public NewWebWorkerBase
, public NewWebCommonWorkerClient {
public:
WebWorkerClientImpl(WebCore::Worker*);
// WebCore::WorkerContextProxy Factory.
static WebCore::WorkerContextProxy* createWorkerContextProxy(WebCore::Worker*);
void setWebWorker(WebWorker*);
// WebCore::WorkerContextProxy methods:
// These are called on the thread that created the worker. In the renderer
// process, this will be the main WebKit thread. In the worker process, this
// will be the thread of the executing worker (not the main WebKit thread).
// process, this will be the main WebKit thread.
virtual void startWorkerContext(const WebCore::KURL&,
const WTF::String&,
const WTF::String&);
......@@ -74,103 +77,48 @@ public:
virtual bool hasPendingActivity() const;
virtual void workerObjectDestroyed();
virtual void connectToInspector(WorkerContextProxy::PageInspector*);
#if ENABLE(INSPECTOR)
virtual void connectToInspector(WebCore::WorkerContextProxy::PageInspector*);
virtual void disconnectFromInspector();
virtual void sendMessageToInspector(const String&);
virtual void postMessageToPageInspector(const String&);
#endif
// WebCore::WorkerLoaderProxy methods:
virtual void postTaskToLoader(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
virtual void postTaskForModeToWorkerContext(PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const String& mode);
// WebWorkerClient methods:
// These are called on the main WebKit thread.
virtual void postMessageToWorkerObject(const WebString&, const WebMessagePortChannelArray&);
virtual void postExceptionToWorkerObject(const WebString&, int, const WebString&);
// WebCore::WorkerObjectProxy methods:
virtual void postMessageToWorkerObject(PassRefPtr<WebCore::SerializedScriptValue>, PassOwnPtr<WebCore::MessagePortChannelArray>);
virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL);
// FIXME: the below is for compatibility only and should be
// removed once Chromium is updated to remove message
// destination parameter <http://webkit.org/b/37155>.
virtual void postConsoleMessageToWorkerObject(int, int, int, int, const WebString&, int, const WebString&);
virtual void postConsoleMessageToWorkerObject(int, int, int, const WebString&, int, const WebString&);
virtual void postConsoleMessageToWorkerObject(WebCore::MessageSource, WebCore::MessageType, WebCore::MessageLevel,
const String& message, int lineNumber, const String& sourceURL);
virtual void confirmMessageFromWorkerObject(bool);
virtual void reportPendingActivity(bool);
virtual void workerContextClosed();
virtual void workerContextDestroyed();
virtual WebWorker* createWorker(WebWorkerClient*) { return 0; }
virtual WebNotificationPresenter* notificationPresenter()
{
// FIXME: Notifications not yet supported in workers.
return 0;
}
virtual WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostClient*) { return 0; }
virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize)
{
ASSERT_NOT_REACHED();
return true;
}
virtual bool allowFileSystem()
{
ASSERT_NOT_REACHED();
return true;
}
// WebWorkerClientBase methods:
virtual bool allowDatabase(WebFrame*, const WebString& name, const WebString& displayName, unsigned long estimatedSize);
virtual bool allowFileSystem();
virtual void openFileSystem(WebFileSystem::Type, long long size, bool create,
WebFileSystemCallbacks*);
virtual void dispatchDevToolsMessage(const WebString&);
// WebCommentWorkerBase methods:
virtual NewWebCommonWorkerClient* newCommonClient() { return this; }
virtual WebView* view() const;
private:
WebWorkerClientImpl(WebCore::Worker*, WebFrameImpl*);
virtual ~WebWorkerClientImpl();
// Methods used to support WebWorkerClientImpl being constructed on worker
// threads.
// These tasks are dispatched on the WebKit thread.
static void startWorkerContextTask(WebCore::ScriptExecutionContext* context,
WebWorkerClientImpl* thisPtr,
const WTF::String& scriptURL,
const WTF::String& userAgent,
const WTF::String& sourceCode);
static void terminateWorkerContextTask(WebCore::ScriptExecutionContext* context,
WebWorkerClientImpl* thisPtr);
static void postMessageToWorkerContextTask(WebCore::ScriptExecutionContext* context,
WebWorkerClientImpl* thisPtr,
const WTF::String& message,
PassOwnPtr<WebCore::MessagePortChannelArray> channels);
static void workerObjectDestroyedTask(WebCore::ScriptExecutionContext* context,
WebWorkerClientImpl* thisPtr);
// These tasks are dispatched on the thread that created the worker (i.e.
// main WebKit thread in renderer process, and the worker thread in the
// worker process).
static void postMessageToWorkerObjectTask(WebCore::ScriptExecutionContext* context,
WebWorkerClientImpl* thisPtr,
const WTF::String& message,
PassOwnPtr<WebCore::MessagePortChannelArray> channels);
static void postExceptionToWorkerObjectTask(WebCore::ScriptExecutionContext* context,
WebWorkerClientImpl* thisPtr,
const WTF::String& message,
int lineNumber,
const WTF::String& sourceURL);
static void postConsoleMessageToWorkerObjectTask(WebCore::ScriptExecutionContext* context,
WebWorkerClientImpl* thisPtr,
int sourceId,
int messageType,
int messageLevel,
const WTF::String& message,
int lineNumber,
const WTF::String& sourceURL);
static void confirmMessageFromWorkerObjectTask(WebCore::ScriptExecutionContext* context,
WebWorkerClientImpl* thisPtr,
bool hasPendingActivity);
static void reportPendingActivityTask(WebCore::ScriptExecutionContext* context,
WebWorkerClientImpl* thisPtr,
bool hasPendingActivity);
void startWorkerContextInternal(const WebCore::KURL& scriptURL, const WTF::String& userAgent, const WTF::String& sourceCode);
WebCore::WorkerMessagingProxy* m_proxy;
// Guard against context from being destroyed before a worker exits.
RefPtr<WebCore::ScriptExecutionContext> m_scriptExecutionContext;
WebCore::Worker* m_worker;
WebWorker* m_webWorker;
bool m_askedToTerminate;
unsigned m_unconfirmedMessageCount;
bool m_workerContextHadPendingActivity;
ThreadIdentifier m_workerThreadId;
WorkerContextProxy::PageInspector* m_pageInspector;
WebFrameImpl* m_webFrame;
WebCore::WorkerContextProxy::PageInspector* m_pageInspector;
};
} // namespace WebKit;
......
......@@ -74,6 +74,11 @@ WebWorkerImpl::~WebWorkerImpl()
{
}
NewWebCommonWorkerClient* WebWorkerImpl::newCommonClient()
{
return m_client;
}
WebCommonWorkerClient* WebWorkerImpl::commonClient()
{
return m_client;
......
......@@ -65,6 +65,9 @@ public:
virtual WebWorkerClient* client() { return m_client; }
virtual WebCommonWorkerClient* commonClient();
// NewWebWorkerBase methods:
virtual NewWebCommonWorkerClient* newCommonClient();
private:
virtual ~WebWorkerImpl();
......
......@@ -156,7 +156,7 @@ void WorkerFileSystemCallbacksBridge::stop()
}
}
void WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread(WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, const String& mode)
void WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread(NewWebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, const String& mode)
{
dispatchTaskToMainThread(
createCallbackTask(&openFileSystemOnMainThread,
......@@ -251,7 +251,7 @@ void WorkerFileSystemCallbacksBridge::postReadDirectoryToMainThread(WebFileSyste
AllowCrossThreadAccess(this), mode));
}
void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, NewWebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
{
if (!commonClient)
bridge->didFailOnMainThread(WebFileErrorAbort, mode);
......
......@@ -51,8 +51,8 @@ namespace WebKit {
class AsyncFileSystem;
class MainThreadFileSystemCallbacks;
class NewWebCommonWorkerClient;
class ThreadableCallbacksBridgeWrapper;
class WebCommonWorkerClient;
class WebFileSystemCallbacks;
struct WebFileInfo;
struct WebFileSystemEntry;
......@@ -87,7 +87,7 @@ public:
}
// Methods that create an instance and post an initial request task to the main thread. They must be called on the worker thread.
void postOpenFileSystemToMainThread(WebCommonWorkerClient*, WebFileSystem::Type, long long size, bool create, const String& mode);
void postOpenFileSystemToMainThread(NewWebCommonWorkerClient*, WebFileSystem::Type, long long size, bool create, const String& mode);
void postMoveToMainThread(WebFileSystem*, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, const String& mode);
void postCopyToMainThread(WebFileSystem*, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, const String& mode);
void postRemoveToMainThread(WebFileSystem*, const WebCore::KURL& path, const String& mode);
......@@ -110,7 +110,7 @@ private:
WorkerFileSystemCallbacksBridge(WebCore::WorkerLoaderProxy*, WebCore::ScriptExecutionContext*, WebFileSystemCallbacks*);
// Methods that are to be called on the main thread.
static void openFileSystemOnMainThread(WebCore::ScriptExecutionContext*, WebCommonWorkerClient*, WebFileSystem::Type, long long size, bool create, WorkerFileSystemCallbacksBridge*, const String& mode);
static void openFileSystemOnMainThread(WebCore::ScriptExecutionContext*, NewWebCommonWorkerClient*, WebFileSystem::Type, long long size, bool create, WorkerFileSystemCallbacksBridge*, const String& mode);
static void moveOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, WorkerFileSystemCallbacksBridge*, const String& mode);
static void copyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& srcPath, const WebCore::KURL& destPath, WorkerFileSystemCallbacksBridge*, const String& mode);
static void removeOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const WebCore::KURL& path, WorkerFileSystemCallbacksBridge*, const String& mode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment