Unreviewed, rolling out r103619.
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Dec 2011 19:26:09 +0000 (19:26 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Dec 2011 19:26:09 +0000 (19:26 +0000)
http://trac.webkit.org/changeset/103619
https://bugs.webkit.org/show_bug.cgi?id=66509

Broke chromium clang build

Source/WebKit/chromium:

* WebKit.gyp:
* public/WebCommonWorkerClient.h:
(WebKit::WebCommonWorkerClient::postConsoleMessageToWorkerObject):
(WebKit::WebCommonWorkerClient::allowFileSystem):
(WebKit::WebCommonWorkerClient::openFileSystem):
(WebKit::WebCommonWorkerClient::dispatchDevToolsMessage):
(WebKit::WebCommonWorkerClient::saveDevToolsAgentState):
(WebKit::WebCommonWorkerClient::~WebCommonWorkerClient):
* public/WebSharedWorker.h:
* public/WebSharedWorkerClient.h: Removed.
* public/WebWorkerClient.h:
(WebKit::WebWorkerClient::~WebWorkerClient):
* src/DatabaseObserver.cpp:
(WebKit::AllowDatabaseMainThreadBridge::create):
(WebKit::AllowDatabaseMainThreadBridge::AllowDatabaseMainThreadBridge):
(WebKit::AllowDatabaseMainThreadBridge::allowDatabaseTask):
(WebKit::allowDatabaseForWorker):
(WebCore::DatabaseObserver::canEstablishDatabase):
* src/IDBFactoryBackendProxy.cpp:
(WebKit::IDBFactoryBackendProxy::openFromWorker):
* src/LocalFileSystemChromium.cpp:
(WebCore::openFileSystemHelper):
* src/WebSharedWorkerImpl.cpp:
(WebKit::WebSharedWorkerImpl::WebSharedWorkerImpl):
(WebKit::WebSharedWorkerImpl::~WebSharedWorkerImpl):
(WebKit::WebSharedWorkerImpl::client):
(WebKit::WebSharedWorker::create):
* src/WebSharedWorkerImpl.h:
(WebKit::WebSharedWorkerImpl::commonClient):
(WebKit::WebSharedWorkerImpl::newCommonClient):
* src/WebWorkerBase.cpp:
(WebKit::initializeWebKitStaticValues):
(WebKit::WebWorkerBase::WebWorkerBase):
(WebKit::WebWorkerBase::~WebWorkerBase):
(WebKit::WebWorkerBase::stopWorkerThread):
(WebKit::WebWorkerBase::initializeLoader):
(WebKit::WebWorkerBase::dispatchTaskToMainThread):
(WebKit::WebWorkerBase::invokeTaskMethod):
(WebKit::WebWorkerBase::didCreateDataSource):
(WebKit::WebWorkerBase::createApplicationCacheHost):
(WebKit::WebWorkerBase::postMessageToWorkerObject):
(WebKit::WebWorkerBase::postMessageTask):
(WebKit::WebWorkerBase::postExceptionToWorkerObject):
(WebKit::WebWorkerBase::postExceptionTask):
(WebKit::WebWorkerBase::postConsoleMessageToWorkerObject):
(WebKit::WebWorkerBase::postConsoleMessageTask):
(WebKit::WebWorkerBase::postMessageToPageInspector):
(WebKit::WebWorkerBase::postMessageToPageInspectorTask):
(WebKit::WebWorkerBase::updateInspectorStateCookie):
(WebKit::WebWorkerBase::updateInspectorStateCookieTask):
(WebKit::WebWorkerBase::confirmMessageFromWorkerObject):
(WebKit::WebWorkerBase::confirmMessageTask):
(WebKit::WebWorkerBase::reportPendingActivity):
(WebKit::WebWorkerBase::reportPendingActivityTask):
(WebKit::WebWorkerBase::workerContextClosed):
(WebKit::WebWorkerBase::workerContextClosedTask):
(WebKit::WebWorkerBase::workerContextDestroyed):
(WebKit::WebWorkerBase::workerContextDestroyedTask):
(WebKit::WebWorkerBase::postTaskToLoader):
(WebKit::WebWorkerBase::postTaskForModeToWorkerContext):
* src/WebWorkerBase.h:
(WebKit::WebWorkerBase::view):
(WebKit::WebWorkerBase::setWorkerThread):
(WebKit::WebWorkerBase::workerThread):
* src/WebWorkerClientImpl.cpp:
* src/WebWorkerClientImpl.h:
(WebKit::WebWorkerClientImpl::newCommonClient):
* src/WebWorkerImpl.cpp: Added.
(WebKit::WebWorker::create):
(WebKit::WebWorkerImpl::WebWorkerImpl):
(WebKit::WebWorkerImpl::~WebWorkerImpl):
(WebKit::WebWorkerImpl::newCommonClient):
(WebKit::WebWorkerImpl::commonClient):
(WebKit::WebWorkerImpl::postMessageToWorkerContextTask):
(WebKit::WebWorkerImpl::startWorkerContext):
(WebKit::WebWorkerImpl::terminateWorkerContext):
(WebKit::WebWorkerImpl::postMessageToWorkerContext):
(WebKit::WebWorkerImpl::workerObjectDestroyed):
(WebKit::WebWorkerImpl::clientDestroyed):
* src/WebWorkerImpl.h: Copied from Source/WebKit/chromium/src/WebWorkerBase.cpp.
(WebKit::WebWorkerImpl::client):
* src/WorkerFileSystemCallbacksBridge.cpp:
(WebKit::WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread):
(WebKit::WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread):
* src/WorkerFileSystemCallbacksBridge.h:

Tools:

* DumpRenderTree/chromium/TestWebWorker.h:
(TestWebWorker::createWorker):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::createWorker):
* DumpRenderTree/chromium/WebViewHost.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@103658 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp
Source/WebKit/chromium/public/WebCommonWorkerClient.h
Source/WebKit/chromium/public/WebSharedWorker.h
Source/WebKit/chromium/public/WebSharedWorkerClient.h [deleted file]
Source/WebKit/chromium/public/WebWorkerClient.h
Source/WebKit/chromium/src/DatabaseObserver.cpp
Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp
Source/WebKit/chromium/src/LocalFileSystemChromium.cpp
Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp
Source/WebKit/chromium/src/WebSharedWorkerImpl.h
Source/WebKit/chromium/src/WebWorkerBase.cpp
Source/WebKit/chromium/src/WebWorkerBase.h
Source/WebKit/chromium/src/WebWorkerClientImpl.cpp
Source/WebKit/chromium/src/WebWorkerClientImpl.h
Source/WebKit/chromium/src/WebWorkerImpl.cpp [new file with mode: 0644]
Source/WebKit/chromium/src/WebWorkerImpl.h [new file with mode: 0644]
Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp
Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h
Tools/ChangeLog
Tools/DumpRenderTree/chromium/TestWebWorker.h
Tools/DumpRenderTree/chromium/WebViewHost.cpp
Tools/DumpRenderTree/chromium/WebViewHost.h

index 83b96286d1cc55200ef3dbac6d9a290db276fc8f..c64efb4988ca8063cae462ad8e30bd947d4ab0d6 100644 (file)
@@ -1,3 +1,97 @@
+2011-12-24  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Unreviewed, rolling out r103619.
+        http://trac.webkit.org/changeset/103619
+        https://bugs.webkit.org/show_bug.cgi?id=66509
+
+        Broke chromium clang build
+
+        * WebKit.gyp:
+        * public/WebCommonWorkerClient.h:
+        (WebKit::WebCommonWorkerClient::postConsoleMessageToWorkerObject):
+        (WebKit::WebCommonWorkerClient::allowFileSystem):
+        (WebKit::WebCommonWorkerClient::openFileSystem):
+        (WebKit::WebCommonWorkerClient::dispatchDevToolsMessage):
+        (WebKit::WebCommonWorkerClient::saveDevToolsAgentState):
+        (WebKit::WebCommonWorkerClient::~WebCommonWorkerClient):
+        * public/WebSharedWorker.h:
+        * public/WebSharedWorkerClient.h: Removed.
+        * public/WebWorkerClient.h:
+        (WebKit::WebWorkerClient::~WebWorkerClient):
+        * src/DatabaseObserver.cpp:
+        (WebKit::AllowDatabaseMainThreadBridge::create):
+        (WebKit::AllowDatabaseMainThreadBridge::AllowDatabaseMainThreadBridge):
+        (WebKit::AllowDatabaseMainThreadBridge::allowDatabaseTask):
+        (WebKit::allowDatabaseForWorker):
+        (WebCore::DatabaseObserver::canEstablishDatabase):
+        * src/IDBFactoryBackendProxy.cpp:
+        (WebKit::IDBFactoryBackendProxy::openFromWorker):
+        * src/LocalFileSystemChromium.cpp:
+        (WebCore::openFileSystemHelper):
+        * src/WebSharedWorkerImpl.cpp:
+        (WebKit::WebSharedWorkerImpl::WebSharedWorkerImpl):
+        (WebKit::WebSharedWorkerImpl::~WebSharedWorkerImpl):
+        (WebKit::WebSharedWorkerImpl::client):
+        (WebKit::WebSharedWorker::create):
+        * src/WebSharedWorkerImpl.h:
+        (WebKit::WebSharedWorkerImpl::commonClient):
+        (WebKit::WebSharedWorkerImpl::newCommonClient):
+        * src/WebWorkerBase.cpp:
+        (WebKit::initializeWebKitStaticValues):
+        (WebKit::WebWorkerBase::WebWorkerBase):
+        (WebKit::WebWorkerBase::~WebWorkerBase):
+        (WebKit::WebWorkerBase::stopWorkerThread):
+        (WebKit::WebWorkerBase::initializeLoader):
+        (WebKit::WebWorkerBase::dispatchTaskToMainThread):
+        (WebKit::WebWorkerBase::invokeTaskMethod):
+        (WebKit::WebWorkerBase::didCreateDataSource):
+        (WebKit::WebWorkerBase::createApplicationCacheHost):
+        (WebKit::WebWorkerBase::postMessageToWorkerObject):
+        (WebKit::WebWorkerBase::postMessageTask):
+        (WebKit::WebWorkerBase::postExceptionToWorkerObject):
+        (WebKit::WebWorkerBase::postExceptionTask):
+        (WebKit::WebWorkerBase::postConsoleMessageToWorkerObject):
+        (WebKit::WebWorkerBase::postConsoleMessageTask):
+        (WebKit::WebWorkerBase::postMessageToPageInspector):
+        (WebKit::WebWorkerBase::postMessageToPageInspectorTask):
+        (WebKit::WebWorkerBase::updateInspectorStateCookie):
+        (WebKit::WebWorkerBase::updateInspectorStateCookieTask):
+        (WebKit::WebWorkerBase::confirmMessageFromWorkerObject):
+        (WebKit::WebWorkerBase::confirmMessageTask):
+        (WebKit::WebWorkerBase::reportPendingActivity):
+        (WebKit::WebWorkerBase::reportPendingActivityTask):
+        (WebKit::WebWorkerBase::workerContextClosed):
+        (WebKit::WebWorkerBase::workerContextClosedTask):
+        (WebKit::WebWorkerBase::workerContextDestroyed):
+        (WebKit::WebWorkerBase::workerContextDestroyedTask):
+        (WebKit::WebWorkerBase::postTaskToLoader):
+        (WebKit::WebWorkerBase::postTaskForModeToWorkerContext):
+        * src/WebWorkerBase.h:
+        (WebKit::WebWorkerBase::view):
+        (WebKit::WebWorkerBase::setWorkerThread):
+        (WebKit::WebWorkerBase::workerThread):
+        * src/WebWorkerClientImpl.cpp:
+        * src/WebWorkerClientImpl.h:
+        (WebKit::WebWorkerClientImpl::newCommonClient):
+        * src/WebWorkerImpl.cpp: Added.
+        (WebKit::WebWorker::create):
+        (WebKit::WebWorkerImpl::WebWorkerImpl):
+        (WebKit::WebWorkerImpl::~WebWorkerImpl):
+        (WebKit::WebWorkerImpl::newCommonClient):
+        (WebKit::WebWorkerImpl::commonClient):
+        (WebKit::WebWorkerImpl::postMessageToWorkerContextTask):
+        (WebKit::WebWorkerImpl::startWorkerContext):
+        (WebKit::WebWorkerImpl::terminateWorkerContext):
+        (WebKit::WebWorkerImpl::postMessageToWorkerContext):
+        (WebKit::WebWorkerImpl::workerObjectDestroyed):
+        (WebKit::WebWorkerImpl::clientDestroyed):
+        * src/WebWorkerImpl.h: Copied from Source/WebKit/chromium/src/WebWorkerBase.cpp.
+        (WebKit::WebWorkerImpl::client):
+        * src/WorkerFileSystemCallbacksBridge.cpp:
+        (WebKit::WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread):
+        (WebKit::WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread):
+        * src/WorkerFileSystemCallbacksBridge.h:
+
 2011-12-23  Sam Weinig  <sam@webkit.org>
 
         Start extracting platform specific bits out of PlatformEvents
index 57e8ab8755f1983222b0b25194e070f0c2f7cb5c..7476b267c4be7e35f4711e0e3738c097c0ce9e11 100644 (file)
                 'public/WebSecurityPolicy.h',
                 'public/WebSelectElement.h',
                 'public/WebSettings.h',
-                'public/WebSharedWorkerClient.h',
                 'public/WebSharedWorker.h',
                 'public/WebSharedWorkerRepository.h',
                 'public/WebSocket.h',
                 'src/WebWorkerBase.h',
                 'src/WebWorkerClientImpl.cpp',
                 'src/WebWorkerClientImpl.h',
+                'src/WebWorkerImpl.cpp',
+                'src/WebWorkerImpl.h',
                 'src/WebWorkerRunLoop.cpp',
                 'src/WorkerAsyncFileSystemChromium.cpp',
                 'src/WorkerAsyncFileSystemChromium.h',
index 2ffb54d57a3f37b0cc2ef7c8ff68fbab8e8b430c..a794539e9138fa5a29c4233dcd087911dece1a3d 100644 (file)
@@ -44,7 +44,7 @@ class WebString;
 class WebWorker;
 class WebWorkerClient;
 
-class WebCommonWorkerClient {
+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;
@@ -56,6 +56,66 @@ public:
     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 : public NewWebCommonWorkerClient {
+public:
+    virtual void postExceptionToWorkerObject(
+        const WebString& errorString, int lineNumber,
+        const WebString& sourceURL) = 0;
+
+    // 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 sourceIdentifier, int messageType, int messageLevel,
+                                                  const WebString& message, int lineNumber, const WebString& sourceURL) = 0;
+
+    virtual void postConsoleMessageToWorkerObject(int sourceIdentifier, int messageType, int messageLevel,
+                                                  const WebString& message, int lineNumber, const WebString& sourceURL)
+    {
+        postConsoleMessageToWorkerObject(0, sourceIdentifier, messageType, messageLevel,
+                                         message, lineNumber, sourceURL);
+    }
+
+    virtual void workerContextClosed() = 0;
+    virtual void workerContextDestroyed() = 0;
+
+    // Returns the notification presenter for this worker context.  Pointer
+    // is owned by the object implementing WebCommonWorkerClient.
+    virtual WebNotificationPresenter* notificationPresenter() = 0;
+
+    // This can be called on any thread to create a nested WebWorker.
+    // WebSharedWorkers are not instantiated via this API - instead
+    // they are created via the WebSharedWorkerRepository.
+    virtual WebWorker* createWorker(WebWorkerClient* client) = 0;
+
+    // Called on the main webkit thread in the worker process during initialization.
+    virtual WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostClient*) = 0;
+
+    // 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()
+    {
+        return true;
+    }
+
+    // Called on the main webkit thread before opening a file system.
+    virtual void openFileSystem(WebFileSystem::Type, long long size, bool create, WebFileSystemCallbacks*)
+    {
+        WEBKIT_ASSERT_NOT_REACHED();
+    }
+
+    virtual void dispatchDevToolsMessage(const WebString&) { }
+    virtual void saveDevToolsAgentState(const WebString&) { }
+
+protected:
+    ~WebCommonWorkerClient() { }
+};
 
 } // namespace WebKit
 
index 447f7f4867113e9bae008dfc13f960c73efb9697..7d5d0035a38b5057e9cfb8a496ebad22ed62ba77 100644 (file)
@@ -41,7 +41,7 @@ namespace WebKit {
 
 class WebString;
 class WebMessagePortChannel;
-class WebSharedWorkerClient;
+class WebCommonWorkerClient;
 class WebURL;
 
 // This is the interface to a SharedWorker thread.
@@ -49,7 +49,7 @@ class WebURL;
 class WebSharedWorker {
 public:
     // Invoked from the worker thread to instantiate a WebSharedWorker that interacts with the WebKit worker components.
-    WEBKIT_EXPORT static WebSharedWorker* create(WebSharedWorkerClient*);
+    WEBKIT_EXPORT static WebSharedWorker* create(WebCommonWorkerClient*);
 
     virtual ~WebSharedWorker() {};
 
diff --git a/Source/WebKit/chromium/public/WebSharedWorkerClient.h b/Source/WebKit/chromium/public/WebSharedWorkerClient.h
deleted file mode 100644 (file)
index 01700c6..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WebSharedWorkerClient_h
-#define WebSharedWorkerClient_h
-
-#include "WebCommonWorkerClient.h"
-#include "WebMessagePortChannel.h"
-
-namespace WebKit {
-
-class WebNotificationPresenter;
-class WebString;
-class WebWorker;
-
-// Provides an interface back to the in-page script object for a worker.
-// All functions are expected to be called back on the thread that created
-// the Worker object, unless noted.
-class WebSharedWorkerClient : public WebCommonWorkerClient {
-public:
-    virtual void postMessageToWorkerObject(
-        const WebString&,
-        const WebMessagePortChannelArray&) = 0;
-
-    virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0;
-    virtual void reportPendingActivity(bool hasPendingActivity) = 0;
-
-    virtual void postExceptionToWorkerObject(
-        const WebString& errorString, int lineNumber,
-        const WebString& sourceURL) = 0;
-
-    // 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 sourceIdentifier, int messageType, int messageLevel,
-                                                  const WebString& message, int lineNumber, const WebString& sourceURL) = 0;
-
-    virtual void postConsoleMessageToWorkerObject(int sourceIdentifier, int messageType, int messageLevel,
-                                                  const WebString& message, int lineNumber, const WebString& sourceURL)
-    {
-        postConsoleMessageToWorkerObject(0, sourceIdentifier, messageType, messageLevel,
-                                         message, lineNumber, sourceURL);
-    }
-
-    virtual void workerContextClosed() = 0;
-    virtual void workerContextDestroyed() = 0;
-
-    // Returns the notification presenter for this worker context. Pointer
-    // is owned by the object implementing WebCommonWorkerClient.
-    virtual WebNotificationPresenter* notificationPresenter() = 0;
-
-    // This can be called on any thread to create a nested WebWorker.
-    // WebSharedWorkers are not instantiated via this API - instead
-    // they are created via the WebSharedWorkerRepository.
-    virtual WebWorker* createWorker(WebSharedWorkerClient*) = 0;
-
-    // Called on the main webkit thread in the worker process during initialization.
-    virtual WebApplicationCacheHost* createApplicationCacheHost(WebApplicationCacheHostClient*) = 0;
-
-    // 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()
-    {
-        return true;
-    }
-
-    // Called on the main webkit thread before opening a file system.
-    virtual void openFileSystem(WebFileSystem::Type, long long size, bool create, WebFileSystemCallbacks*)
-    {
-        WEBKIT_ASSERT_NOT_REACHED();
-    }
-
-    virtual void dispatchDevToolsMessage(const WebString&) { }
-    virtual void saveDevToolsAgentState(const WebString&) { }
-
-protected:
-    ~WebSharedWorkerClient() { }
-};
-
-} // namespace WebKit
-
-#endif
index 596999ddc3939319445c8d5b91f3e37824bf1f6e..eb2e63e5ce933f331bf00a2ca56b8f3368d54412 100644 (file)
 #ifndef WebWorkerClient_h
 #define WebWorkerClient_h
 
-#include "WebSharedWorkerClient.h"
+#include "WebCommonWorkerClient.h"
+#include "WebMessagePortChannel.h"
 
-#define WebWorkerClient WebSharedWorkerClient
+namespace WebKit {
+
+class WebNotificationPresenter;
+class WebString;
+class WebWorker;
+
+// Provides an interface back to the in-page script object for a worker.
+// All functions are expected to be called back on the thread that created
+// the Worker object, unless noted.
+class WebWorkerClient : public WebCommonWorkerClient {
+public:
+    virtual void postMessageToWorkerObject(
+        const WebString&,
+        const WebMessagePortChannelArray&) = 0;
+
+    virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0;
+    virtual void reportPendingActivity(bool hasPendingActivity) = 0;
+
+protected:
+    ~WebWorkerClient() { }
+};
+
+} // namespace WebKit
 
 #endif
index 40b50480341528bc3d0d72415f69d99768f9b111..187b55e82610e919ec93c5fb82d618e6cc598737 100644 (file)
@@ -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 String& mode, WebCommonWorkerClient* commonClient, WebFrame* frame, const String& name, const String& displayName, unsigned long estimatedSize)
+    static PassRefPtr<AllowDatabaseMainThreadBridge> create(WebCore::WorkerLoaderProxy* workerLoaderProxy, const String& mode, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const String& name, const String& displayName, unsigned long estimatedSize)
     {
         return adoptRef(new AllowDatabaseMainThreadBridge(workerLoaderProxy, mode, commonClient, frame, name, displayName, estimatedSize));
     }
@@ -91,7 +91,7 @@ public:
     }
 
 private:
-    AllowDatabaseMainThreadBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, const String& mode, WebCommonWorkerClient* commonClient, WebFrame* frame, const String& name, const String& displayName, unsigned long estimatedSize)
+    AllowDatabaseMainThreadBridge(WebCore::WorkerLoaderProxy* workerLoaderProxy, const String& mode, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const String& name, const String& displayName, unsigned long estimatedSize)
         : m_workerLoaderProxy(workerLoaderProxy)
     {
         WebWorkerBase::dispatchTaskToMainThread(
@@ -101,7 +101,7 @@ private:
                                this));
     }
 
-    static void allowDatabaseTask(WebCore::ScriptExecutionContext* context, const String mode, WebCommonWorkerClient* commonClient, WebFrame* frame, const String name, const String displayName, unsigned long estimatedSize, PassRefPtr<AllowDatabaseMainThreadBridge> bridge)
+    static void allowDatabaseTask(WebCore::ScriptExecutionContext* context, const String mode, NewWebCommonWorkerClient* commonClient, WebFrame* frame, const String name, const String displayName, unsigned long estimatedSize, PassRefPtr<AllowDatabaseMainThreadBridge> bridge)
     {
         bool allowDatabase = commonClient ? commonClient->allowDatabase(frame, name, displayName, estimatedSize) : false;
         bridge->signalCompleted(mode, allowDatabase);
@@ -117,7 +117,7 @@ private:
     WebCore::WorkerLoaderProxy* m_workerLoaderProxy;
 };
 
-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();
@@ -164,8 +164,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->view()->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
index c22309b2a0201fab30f3f048c64b8d4c7fb404b8..7ae6e612150bcead7b05fcabd2f1198bcd46c654 100755 (executable)
@@ -99,7 +99,7 @@ void IDBFactoryBackendProxy::openFromWorker(const String& name, IDBCallbacks* ca
         return;
     }
     WorkerLoaderProxy* workerLoaderProxy = &context->thread()->workerLoaderProxy();
-    WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
+    NewWebWorkerBase* webWorker = static_cast<NewWebWorkerBase*>(workerLoaderProxy);
     WebFrame* webFrame = webWorker->view()->mainFrame();
     m_webIDBFactory->open(name, new WebIDBCallbacksImpl(callbacks), origin, webFrame, dataDir);
 #endif
index 9e0e73026ae382526c9b351638b80e816f581d01..757ef8253e2f9fad2f43589210bb98cdc4a4333e 100644 (file)
@@ -79,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));
     }
@@ -106,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)
     {
@@ -115,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());
@@ -134,7 +134,7 @@ private:
     WTF::String m_mode;
 };
 
-bool allowFileSystemForWorker(WebCommonWorkerClient* commonClient)
+bool allowFileSystemForWorker(NewWebCommonWorkerClient* commonClient)
 {
     WorkerScriptController* controller = WorkerScriptController::controllerForContext();
     WorkerContext* workerContext = controller->workerContext();
@@ -157,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();
@@ -203,11 +203,11 @@ 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();
index 231aaac2e50c8d264164597448a058d83ac612ed..1445f8ec9676ec579c741e11a9e790d82a7d5277 100644 (file)
 #include "WebSharedWorkerImpl.h"
 
 #include "CrossThreadTask.h"
-#include "DatabaseTask.h"
-#include "Document.h"
 #include "KURL.h"
 #include "MessageEvent.h"
 #include "MessagePortChannel.h"
 #include "PlatformMessagePortChannel.h"
-#include "SecurityOrigin.h"
 #include "ScriptExecutionContext.h"
 #include "SharedWorkerContext.h"
 #include "SharedWorkerThread.h"
-#include "WebDataSourceImpl.h"
-#include "WebFileError.h"
-#include "WebFrameClient.h"
-#include "WebFrameImpl.h"
-#include "WebMessagePortChannel.h"
-#include "WebRuntimeFeatures.h"
-#include "WebSettings.h"
-#include "WebSharedWorkerClient.h"
-#include "WebView.h"
-#include "WorkerContext.h"
 #include "WorkerDebuggerAgent.h"
 #include "WorkerInspectorController.h"
-#include "WorkerLoaderProxy.h"
-#include "WorkerThread.h"
+
+#include "WebMessagePortChannel.h"
 #include "platform/WebString.h"
 #include "platform/WebURL.h"
-#include <wtf/MainThread.h>
 
 using namespace WebCore;
 
 namespace WebKit {
 
 #if ENABLE(SHARED_WORKERS)
-// This function is called on the main thread to force to initialize some static
-// values used in WebKit before any worker thread is started. This is because in
-// our worker processs, we do not run any WebKit code in main thread and thus
-// when multiple workers try to start at the same time, we might hit crash due
-// to contention for initializing static values.
-static void initializeWebKitStaticValues()
-{
-    static bool initialized = false;
-    if (!initialized) {
-        initialized = true;
-        // Note that we have to pass a URL with valid protocol in order to follow
-        // the path to do static value initializations.
-        RefPtr<SecurityOrigin> origin =
-            SecurityOrigin::create(KURL(ParsedURLString, "http://localhost"));
-        origin.release();
-    }
-}
 
-WebSharedWorkerImpl::WebSharedWorkerImpl(WebSharedWorkerClient* client)
-    : m_webView(0)
-    , m_askedToTerminate(false)
-    , m_client(client)
+WebSharedWorkerImpl::WebSharedWorkerImpl(WebCommonWorkerClient* client)
+    : m_client(client)
     , m_pauseWorkerContextOnStart(false)
 {
-    initializeWebKitStaticValues();
 }
 
 WebSharedWorkerImpl::~WebSharedWorkerImpl()
 {
-    ASSERT(m_webView);
-    WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
-    if (webFrame)
-        webFrame->setClient(0);
-    m_webView->close();
-}
-
-void WebSharedWorkerImpl::stopWorkerThread()
-{
-    if (m_askedToTerminate)
-        return;
-    m_askedToTerminate = true;
-    if (m_workerThread)
-        m_workerThread->stop();
-}
-
-void WebSharedWorkerImpl::initializeLoader(const WebURL& url)
-{
-    // Create 'shadow page'. This page is never displayed, it is used to proxy the
-    // loading requests from the worker context to the rest of WebKit and Chromium
-    // infrastructure.
-    ASSERT(!m_webView);
-    m_webView = WebView::create(0);
-    m_webView->settings()->setOfflineWebApplicationCacheEnabled(WebRuntimeFeatures::isApplicationCacheEnabled());
-    // FIXME: Settings information should be passed to the Worker process from Browser process when the worker
-    // is created (similar to RenderThread::OnCreateNewView).
-    m_webView->settings()->setHixie76WebSocketProtocolEnabled(false);
-    m_webView->initializeMainFrame(this);
-
-    WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
-
-    // Construct substitute data source for the 'shadow page'. We only need it
-    // to have same origin as the worker so the loading checks work correctly.
-    CString content("");
-    int len = static_cast<int>(content.length());
-    RefPtr<SharedBuffer> buf(SharedBuffer::create(content.data(), len));
-    SubstituteData substData(buf, String("text/html"), String("UTF-8"), KURL());
-    webFrame->frame()->loader()->load(ResourceRequest(url), substData, false);
-
-    // This document will be used as 'loading context' for the worker.
-    m_loadingDocument = webFrame->frame()->document();
-}
-
-void WebSharedWorkerImpl::didCreateDataSource(WebFrame*, WebDataSource* ds)
-{
-    // Tell the loader to load the data into the 'shadow page' synchronously,
-    // so we can grab the resulting Document right after load.
-    static_cast<WebDataSourceImpl*>(ds)->setDeferMainResourceDataLoad(false);
-}
-
-WebApplicationCacheHost* WebSharedWorkerImpl::createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient* appcacheHostClient)
-{
-    if (client())
-        return client()->createApplicationCacheHost(appcacheHostClient);
-    return 0;
-}
-
-// WorkerObjectProxy -----------------------------------------------------------
-
-void WebSharedWorkerImpl::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message,
-                                                    PassOwnPtr<MessagePortChannelArray> channels)
-{
-    WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageTask, AllowCrossThreadAccess(this),
-                                                message->toWireString(), channels));
-}
-
-void WebSharedWorkerImpl::postMessageTask(ScriptExecutionContext* context,
-                                          WebSharedWorkerImpl* thisPtr,
-                                          String message,
-                                          PassOwnPtr<MessagePortChannelArray> channels)
-{
-    if (!thisPtr->client())
-        return;
-
-    WebMessagePortChannelArray webChannels(channels ? channels->size() : 0);
-    for (size_t i = 0; i < webChannels.size(); ++i) {
-        webChannels[i] = (*channels)[i]->channel()->webChannelRelease();
-        webChannels[i]->setClient(0);
-    }
-
-    thisPtr->client()->postMessageToWorkerObject(message, webChannels);
-}
-
-void WebSharedWorkerImpl::postExceptionToWorkerObject(const String& errorMessage,
-                                                      int lineNumber,
-                                                      const String& sourceURL)
-{
-    WebWorkerBase::dispatchTaskToMainThread(
-        createCallbackTask(&postExceptionTask, AllowCrossThreadAccess(this),
-                           errorMessage, lineNumber,
-                           sourceURL));
-}
-
-void WebSharedWorkerImpl::postExceptionTask(ScriptExecutionContext* context,
-                                            WebSharedWorkerImpl* thisPtr,
-                                            const String& errorMessage,
-                                            int lineNumber, const String& sourceURL)
-{
-    if (!thisPtr->client())
-        return;
-
-    thisPtr->client()->postExceptionToWorkerObject(errorMessage,
-                                                   lineNumber,
-                                                   sourceURL);
-}
-
-void WebSharedWorkerImpl::postConsoleMessageToWorkerObject(MessageSource source,
-                                                           MessageType type,
-                                                           MessageLevel level,
-                                                           const String& message,
-                                                           int lineNumber,
-                                                           const String& sourceURL)
-{
-    WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postConsoleMessageTask, AllowCrossThreadAccess(this),
-                                            source, type, level,
-                                            message, lineNumber, sourceURL));
-}
-
-void WebSharedWorkerImpl::postConsoleMessageTask(ScriptExecutionContext* context,
-                                                 WebSharedWorkerImpl* thisPtr,
-                                                 int source,
-                                                 int type, int level,
-                                                 const String& message,
-                                                 int lineNumber,
-                                                 const String& sourceURL)
-{
-    if (!thisPtr->client())
-        return;
-    thisPtr->client()->postConsoleMessageToWorkerObject(source,
-                                                              type, level, message,
-                                                              lineNumber, sourceURL);
-}
-
-void WebSharedWorkerImpl::postMessageToPageInspector(const String& message)
-{
-    WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&postMessageToPageInspectorTask, AllowCrossThreadAccess(this), message));
 }
 
-void WebSharedWorkerImpl::postMessageToPageInspectorTask(ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& message)
-{
-    if (!thisPtr->client())
-        return;
-    thisPtr->client()->dispatchDevToolsMessage(message);
-}
-
-void WebSharedWorkerImpl::updateInspectorStateCookie(const WTF::String& cookie)
-{
-    WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&updateInspectorStateCookieTask, AllowCrossThreadAccess(this), cookie));
-}
-
-void WebSharedWorkerImpl::updateInspectorStateCookieTask(ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const String& cookie)
-{
-    if (!thisPtr->client())
-        return;
-    thisPtr->client()->saveDevToolsAgentState(cookie);
-}
-
-void WebSharedWorkerImpl::confirmMessageFromWorkerObject(bool hasPendingActivity)
-{
-    WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&confirmMessageTask, AllowCrossThreadAccess(this),
-                                            hasPendingActivity));
-}
-
-void WebSharedWorkerImpl::confirmMessageTask(ScriptExecutionContext* context,
-                                             WebSharedWorkerImpl* thisPtr,
-                                             bool hasPendingActivity)
-{
-    if (!thisPtr->client())
-        return;
-    thisPtr->client()->confirmMessageFromWorkerObject(hasPendingActivity);
-}
-
-void WebSharedWorkerImpl::reportPendingActivity(bool hasPendingActivity)
-{
-    WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&reportPendingActivityTask,
-                                            AllowCrossThreadAccess(this),
-                                            hasPendingActivity));
-}
-
-void WebSharedWorkerImpl::reportPendingActivityTask(ScriptExecutionContext* context,
-                                                    WebSharedWorkerImpl* thisPtr,
-                                                    bool hasPendingActivity)
-{
-    if (!thisPtr->client())
-        return;
-    thisPtr->client()->reportPendingActivity(hasPendingActivity);
-}
-
-void WebSharedWorkerImpl::workerContextClosed()
-{
-    WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerContextClosedTask,
-                                            AllowCrossThreadAccess(this)));
-}
-
-void WebSharedWorkerImpl::workerContextClosedTask(ScriptExecutionContext* context,
-                                                  WebSharedWorkerImpl* thisPtr)
-{
-    if (thisPtr->client())
-        thisPtr->client()->workerContextClosed();
-
-    thisPtr->stopWorkerThread();
-}
-
-void WebSharedWorkerImpl::workerContextDestroyed()
-{
-    WebWorkerBase::dispatchTaskToMainThread(createCallbackTask(&workerContextDestroyedTask,
-                                                               AllowCrossThreadAccess(this)));
-}
-
-void WebSharedWorkerImpl::workerContextDestroyedTask(ScriptExecutionContext* context,
-                                                     WebSharedWorkerImpl* thisPtr)
-{
-    if (thisPtr->client())
-        thisPtr->client()->workerContextDestroyed();
-    // The lifetime of this proxy is controlled by the worker context.
-    delete thisPtr;
-}
-
-// WorkerLoaderProxy -----------------------------------------------------------
-
-void WebSharedWorkerImpl::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task> task)
-{
-    ASSERT(m_loadingDocument->isDocument());
-    m_loadingDocument->postTask(task);
-}
-
-void WebSharedWorkerImpl::postTaskForModeToWorkerContext(
-    PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
-{
-    m_workerThread->runLoop().postTaskForMode(task, mode);
-}
-
-
-
 bool WebSharedWorkerImpl::isStarted()
 {
     // Should not ever be called from the worker thread (this API is only called on WebSharedWorkerProxy on the renderer thread).
@@ -443,10 +177,19 @@ void WebSharedWorkerImpl::dispatchDevToolsMessage(const WebString& message)
     workerThread()->runLoop().postTaskForMode(createCallbackTask(dispatchOnInspectorBackendTask, String(message)), WorkerDebuggerAgent::debuggerTaskMode);
 }
 
-WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client)
+WebWorkerClient* WebSharedWorkerImpl::client()
+{
+    // We should never be asked for a WebWorkerClient (only dedicated workers have an associated WebWorkerClient).
+    // It should not be possible for SharedWorkerContext to generate an API call outside those supported by WebCommonWorkerClient.
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+WebSharedWorker* WebSharedWorker::create(WebCommonWorkerClient* client)
 {
     return new WebSharedWorkerImpl(client);
 }
+
 #endif // ENABLE(SHARED_WORKERS)
 
 } // namespace WebKit
index 83d361aee2aa0b33186e410c94f3b8a7bb309330..437bb2bc7ffb36dd6eca043c8a73808cadcb7660 100644 (file)
 #include "WebSharedWorker.h"
 
 #if ENABLE(SHARED_WORKERS)
+
 #include "ScriptExecutionContext.h"
-#include "WebCommonWorkerClient.h"
-#include "WebFrameClient.h"
-#include "WebWorkerBase.h"
-#include "WebWorkerClient.h"
-#include "WorkerLoaderProxy.h"
-#include "WorkerObjectProxy.h"
-#include "WorkerThread.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefPtr.h>
 
+#include "WebWorkerBase.h"
 
 namespace WebKit {
-class WebApplicationCacheHost;
-class WebApplicationCacheHostClient;
-class WebWorkerClient;
-class WebSecurityOrigin;
-class WebString;
-class WebURL;
-class WebView;
-class WebWorker;
-class WebSharedWorkerClient;
+
 // This class is used by the worker process code to talk to the WebCore::SharedWorker implementation.
 // It can't use it directly since it uses WebKit types, so this class converts the data types.
 // When the WebCore::SharedWorker object wants to call WebCore::WorkerReportingProxy, this class will
 // convert to Chrome data types first and then call the supplied WebCommonWorkerClient.
-class WebSharedWorkerImpl : public WebCore::WorkerObjectProxy
-                          , public WebWorkerBase
-                          , public WebFrameClient
-                          , public WebSharedWorker {
+class WebSharedWorkerImpl : public WebWorkerBase, public WebSharedWorker {
 public:
-    explicit WebSharedWorkerImpl(WebSharedWorkerClient*);
-
-    virtual void postMessageToWorkerObject(
-        PassRefPtr<WebCore::SerializedScriptValue>,
-        PassOwnPtr<WebCore::MessagePortChannelArray>);
-    virtual void postExceptionToWorkerObject(
-        const WTF::String&, int, const WTF::String&);
-    virtual void postConsoleMessageToWorkerObject(
-        WebCore::MessageSource, WebCore::MessageType,
-        WebCore::MessageLevel, const WTF::String&, int, const WTF::String&);
-    virtual void postMessageToPageInspector(const WTF::String&);
-    virtual void updateInspectorStateCookie(const WTF::String&);
-    virtual void confirmMessageFromWorkerObject(bool);
-    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>);
-    virtual void postTaskForModeToWorkerContext(
-        PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const WTF::String& mode);
-
-    // WebFrameClient methods to support resource loading thru the 'shadow page'.
-    virtual void didCreateDataSource(WebFrame*, WebDataSource*);
-    virtual WebApplicationCacheHost* createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient*);
-
+    explicit WebSharedWorkerImpl(WebCommonWorkerClient* client);
 
     // WebSharedWorker methods:
     virtual bool isStarted();
@@ -107,72 +63,19 @@ public:
     virtual void detachDevTools();
     virtual void dispatchDevToolsMessage(const WebString&);
 
+    // WebWorkerBase methods:
+    WebWorkerClient* client();
+    WebCommonWorkerClient* commonClient() { return m_client; }
 
     // NewWebWorkerBase methods:
-    WebCommonWorkerClient* commonClient() { return m_client; }
+    NewWebCommonWorkerClient* newCommonClient() { return m_client; }
 
 private:
     virtual ~WebSharedWorkerImpl();
 
-    WebSharedWorkerClient* client() { return m_client; }
-
-    void setWorkerThread(PassRefPtr<WebCore::WorkerThread> thread) { m_workerThread = thread; }
-    WebCore::WorkerThread* workerThread() { return m_workerThread.get(); }
-
-    // Shuts down the worker thread.
-    void stopWorkerThread();
-
-    // Creates the shadow loader used for worker network requests.
-    void initializeLoader(const WebURL&);
-
-
     static void connectTask(WebCore::ScriptExecutionContext*, PassOwnPtr<WebCore::MessagePortChannel>);
-    // Tasks that are run on the main thread.
-    static void postMessageTask(
-        WebCore::ScriptExecutionContext*,
-        WebSharedWorkerImpl* thisPtr,
-        WTF::String message,
-        PassOwnPtr<WebCore::MessagePortChannelArray> channels);
-    static void postExceptionTask(
-        WebCore::ScriptExecutionContext*,
-        WebSharedWorkerImpl* thisPtr,
-        const WTF::String& message,
-        int lineNumber,
-        const WTF::String& sourceURL);
-    static void postConsoleMessageTask(
-        WebCore::ScriptExecutionContext*,
-        WebSharedWorkerImpl* thisPtr,
-        int source,
-        int type,
-        int level,
-        const WTF::String& message,
-        int lineNumber,
-        const WTF::String& sourceURL);
-    static void postMessageToPageInspectorTask(WebCore::ScriptExecutionContext*, WebSharedWorkerImpl*, const WTF::String&);
-    static void updateInspectorStateCookieTask(WebCore::ScriptExecutionContext*, WebSharedWorkerImpl* thisPtr, const WTF::String& cookie);
-    static void confirmMessageTask(
-        WebCore::ScriptExecutionContext*,
-        WebSharedWorkerImpl* thisPtr,
-        bool hasPendingActivity);
-    static void reportPendingActivityTask(
-        WebCore::ScriptExecutionContext*,
-        WebSharedWorkerImpl* thisPtr,
-        bool hasPendingActivity);
-    static void workerContextClosedTask(
-        WebCore::ScriptExecutionContext*,
-        WebSharedWorkerImpl* thisPtr);
-    static void workerContextDestroyedTask(
-        WebCore::ScriptExecutionContext*,
-        WebSharedWorkerImpl* thisPtr);
-
-    // 'shadow page' - created to proxy loading requests from the worker.
-    RefPtr<WebCore::ScriptExecutionContext> m_loadingDocument;
-    WebView* m_webView;
-    bool m_askedToTerminate;
-
-    RefPtr<WebCore::WorkerThread> m_workerThread;
-
-    WebSharedWorkerClient* m_client;
+
+    WebCommonWorkerClient* m_client;
     bool m_pauseWorkerContextOnStart;
 };
 
index b12db7d8343870c6ded3a7746724e95ce36bf4ce..93f840c8347bb307b076776cf617905289520856 100644 (file)
 #include "WebWorkerBase.h"
 
 #include "CrossThreadTask.h"
+#include "DatabaseTask.h"
+#include "Document.h"
+#include "MessagePortChannel.h"
+#include "PlatformMessagePortChannel.h"
+#include "SecurityOrigin.h"
 
+#include "WebDataSourceImpl.h"
+#include "WebFileError.h"
+#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
+#include "WebMessagePortChannel.h"
+#include "WebRuntimeFeatures.h"
+#include "WebSettings.h"
+#include "WebView.h"
 #include "WebWorkerClient.h"
 
 #include "WorkerContext.h"
@@ -46,7 +59,82 @@ namespace WebKit {
 
 #if ENABLE(WORKERS)
 
-static void invokeTaskMethod(void* param)
+// This function is called on the main thread to force to initialize some static
+// values used in WebKit before any worker thread is started. This is because in
+// our worker processs, we do not run any WebKit code in main thread and thus
+// when multiple workers try to start at the same time, we might hit crash due
+// to contention for initializing static values.
+static void initializeWebKitStaticValues()
+{
+    static bool initialized = false;
+    if (!initialized) {
+        initialized = true;
+        // Note that we have to pass a URL with valid protocol in order to follow
+        // the path to do static value initializations.
+        RefPtr<SecurityOrigin> origin =
+            SecurityOrigin::create(KURL(ParsedURLString, "http://localhost"));
+        origin.release();
+    }
+}
+
+WebWorkerBase::WebWorkerBase()
+    : m_webView(0)
+    , m_askedToTerminate(false)
+{
+    initializeWebKitStaticValues();
+}
+
+WebWorkerBase::~WebWorkerBase()
+{
+    ASSERT(m_webView);
+    WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
+    if (webFrame)
+        webFrame->setClient(0);
+    m_webView->close();
+}
+
+void WebWorkerBase::stopWorkerThread()
+{
+    if (m_askedToTerminate)
+        return;
+    m_askedToTerminate = true;
+    if (m_workerThread)
+        m_workerThread->stop();
+}
+
+void WebWorkerBase::initializeLoader(const WebURL& url)
+{
+    // Create 'shadow page'. This page is never displayed, it is used to proxy the
+    // loading requests from the worker context to the rest of WebKit and Chromium
+    // infrastructure.
+    ASSERT(!m_webView);
+    m_webView = WebView::create(0);
+    m_webView->settings()->setOfflineWebApplicationCacheEnabled(WebRuntimeFeatures::isApplicationCacheEnabled());
+    // FIXME: Settings information should be passed to the Worker process from Browser process when the worker
+    // is created (similar to RenderThread::OnCreateNewView).
+    m_webView->settings()->setHixie76WebSocketProtocolEnabled(false);
+    m_webView->initializeMainFrame(this);
+
+    WebFrameImpl* webFrame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
+
+    // Construct substitute data source for the 'shadow page'. We only need it
+    // to have same origin as the worker so the loading checks work correctly.
+    CString content("");
+    int len = static_cast<int>(content.length());
+    RefPtr<SharedBuffer> buf(SharedBuffer::create(content.data(), len));
+    SubstituteData substData(buf, String("text/html"), String("UTF-8"), KURL());
+    webFrame->frame()->loader()->load(ResourceRequest(url), substData, false);
+
+    // This document will be used as 'loading context' for the worker.
+    m_loadingDocument = webFrame->frame()->document();
+}
+
+void WebWorkerBase::dispatchTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task> task)
+{
+    callOnMainThread(invokeTaskMethod, task.leakPtr());
+}
+
+void WebWorkerBase::invokeTaskMethod(void* param)
 {
     ScriptExecutionContext::Task* task =
         static_cast<ScriptExecutionContext::Task*>(param);
@@ -54,10 +142,193 @@ static void invokeTaskMethod(void* param)
     delete task;
 }
 
+void WebWorkerBase::didCreateDataSource(WebFrame*, WebDataSource* ds)
+{
+    // Tell the loader to load the data into the 'shadow page' synchronously,
+    // so we can grab the resulting Document right after load.
+    static_cast<WebDataSourceImpl*>(ds)->setDeferMainResourceDataLoad(false);
+}
 
-void WebWorkerBase::dispatchTaskToMainThread(PassOwnPtr<ScriptExecutionContext::Task> task)
+WebApplicationCacheHost* WebWorkerBase::createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient* appcacheHostClient)
 {
-    callOnMainThread(invokeTaskMethod, task.leakPtr());
+    if (commonClient())
+        return commonClient()->createApplicationCacheHost(appcacheHostClient);
+    return 0;
+}
+
+// WorkerObjectProxy -----------------------------------------------------------
+
+void WebWorkerBase::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message,
+                                              PassOwnPtr<MessagePortChannelArray> channels)
+{
+    dispatchTaskToMainThread(createCallbackTask(&postMessageTask, AllowCrossThreadAccess(this),
+                                                message->toWireString(), channels));
+}
+
+void WebWorkerBase::postMessageTask(ScriptExecutionContext* context,
+                                    WebWorkerBase* thisPtr,
+                                    String message,
+                                    PassOwnPtr<MessagePortChannelArray> channels)
+{
+    if (!thisPtr->client())
+        return;
+
+    WebMessagePortChannelArray webChannels(channels ? channels->size() : 0);
+    for (size_t i = 0; i < webChannels.size(); ++i) {
+        webChannels[i] = (*channels)[i]->channel()->webChannelRelease();
+        webChannels[i]->setClient(0);
+    }
+
+    thisPtr->client()->postMessageToWorkerObject(message, webChannels);
+}
+
+void WebWorkerBase::postExceptionToWorkerObject(const String& errorMessage,
+                                                int lineNumber,
+                                                const String& sourceURL)
+{
+    dispatchTaskToMainThread(
+        createCallbackTask(&postExceptionTask, AllowCrossThreadAccess(this),
+                           errorMessage, lineNumber,
+                           sourceURL));
+}
+
+void WebWorkerBase::postExceptionTask(ScriptExecutionContext* context,
+                                      WebWorkerBase* thisPtr,
+                                      const String& errorMessage,
+                                      int lineNumber, const String& sourceURL)
+{
+    if (!thisPtr->commonClient())
+        return;
+
+    thisPtr->commonClient()->postExceptionToWorkerObject(errorMessage,
+                                                         lineNumber,
+                                                         sourceURL);
+}
+
+void WebWorkerBase::postConsoleMessageToWorkerObject(MessageSource source,
+                                                     MessageType type,
+                                                     MessageLevel level,
+                                                     const String& message,
+                                                     int lineNumber,
+                                                     const String& sourceURL)
+{
+    dispatchTaskToMainThread(createCallbackTask(&postConsoleMessageTask, AllowCrossThreadAccess(this),
+                                                source, type, level,
+                                                message, lineNumber, sourceURL));
+}
+
+void WebWorkerBase::postConsoleMessageTask(ScriptExecutionContext* context,
+                                           WebWorkerBase* thisPtr,
+                                           int source,
+                                           int type, int level,
+                                           const String& message,
+                                           int lineNumber,
+                                           const String& sourceURL)
+{
+    if (!thisPtr->commonClient())
+        return;
+    thisPtr->commonClient()->postConsoleMessageToWorkerObject(source,
+                                                              type, level, message,
+                                                              lineNumber, sourceURL);
+}
+
+void WebWorkerBase::postMessageToPageInspector(const String& message)
+{
+    dispatchTaskToMainThread(createCallbackTask(&postMessageToPageInspectorTask, AllowCrossThreadAccess(this), message));
+}
+
+void WebWorkerBase::postMessageToPageInspectorTask(ScriptExecutionContext*, WebWorkerBase* thisPtr, const String& message)
+{
+    if (!thisPtr->commonClient())
+        return;
+    thisPtr->commonClient()->dispatchDevToolsMessage(message);
+}
+
+void WebWorkerBase::updateInspectorStateCookie(const WTF::String& cookie)
+{
+    dispatchTaskToMainThread(createCallbackTask(&updateInspectorStateCookieTask, AllowCrossThreadAccess(this), cookie));
+}
+
+void WebWorkerBase::updateInspectorStateCookieTask(ScriptExecutionContext*, WebWorkerBase* thisPtr, const String& cookie)
+{
+    if (!thisPtr->commonClient())
+        return;
+    thisPtr->commonClient()->saveDevToolsAgentState(cookie);
+}
+
+void WebWorkerBase::confirmMessageFromWorkerObject(bool hasPendingActivity)
+{
+    dispatchTaskToMainThread(createCallbackTask(&confirmMessageTask, AllowCrossThreadAccess(this),
+                                                hasPendingActivity));
+}
+
+void WebWorkerBase::confirmMessageTask(ScriptExecutionContext* context,
+                                       WebWorkerBase* thisPtr,
+                                       bool hasPendingActivity)
+{
+    if (!thisPtr->client())
+        return;
+    thisPtr->client()->confirmMessageFromWorkerObject(hasPendingActivity);
+}
+
+void WebWorkerBase::reportPendingActivity(bool hasPendingActivity)
+{
+    dispatchTaskToMainThread(createCallbackTask(&reportPendingActivityTask,
+                                                AllowCrossThreadAccess(this),
+                                                hasPendingActivity));
+}
+
+void WebWorkerBase::reportPendingActivityTask(ScriptExecutionContext* context,
+                                              WebWorkerBase* thisPtr,
+                                              bool hasPendingActivity)
+{
+    if (!thisPtr->client())
+        return;
+    thisPtr->client()->reportPendingActivity(hasPendingActivity);
+}
+
+void WebWorkerBase::workerContextClosed()
+{
+    dispatchTaskToMainThread(createCallbackTask(&workerContextClosedTask,
+                                                AllowCrossThreadAccess(this)));
+}
+
+void WebWorkerBase::workerContextClosedTask(ScriptExecutionContext* context,
+                                            WebWorkerBase* thisPtr)
+{
+    if (thisPtr->commonClient())
+        thisPtr->commonClient()->workerContextClosed();
+
+    thisPtr->stopWorkerThread();
+}
+
+void WebWorkerBase::workerContextDestroyed()
+{
+    dispatchTaskToMainThread(createCallbackTask(&workerContextDestroyedTask,
+                                                AllowCrossThreadAccess(this)));
+}
+
+void WebWorkerBase::workerContextDestroyedTask(ScriptExecutionContext* context,
+                                               WebWorkerBase* thisPtr)
+{
+    if (thisPtr->commonClient())
+        thisPtr->commonClient()->workerContextDestroyed();
+    // The lifetime of this proxy is controlled by the worker context.
+    delete thisPtr;
+}
+
+// WorkerLoaderProxy -----------------------------------------------------------
+
+void WebWorkerBase::postTaskToLoader(PassOwnPtr<ScriptExecutionContext::Task> task)
+{
+    ASSERT(m_loadingDocument->isDocument());
+    m_loadingDocument->postTask(task);
+}
+
+void WebWorkerBase::postTaskForModeToWorkerContext(
+    PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
+{
+    m_workerThread->runLoop().postTaskForMode(task, mode);
 }
 
 #endif // ENABLE(WORKERS)
index c43c63931b041850647a5e522cde4ce019135cbb..93599f4fde2c6384ccf19bb43730f4d2babbb776 100644 (file)
 
 #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>
 
+namespace WebCore {
+class WorkerThread;
+}
 
 namespace WebKit {
+class WebApplicationCacheHost;
+class WebApplicationCacheHostClient;
+class WebCommonWorkerClient;
+class WebSecurityOrigin;
+class WebString;
+class WebURL;
 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 WebWorkerBase : public WebCore::WorkerLoaderProxy {
+class NewWebWorkerBase : public WebCore::WorkerLoaderProxy {
 public:
-    virtual WebCommonWorkerClient* commonClient() = 0;
+    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 NewWebWorkerBase
+                    , public WebFrameClient {
+public:
+    WebWorkerBase();
+    virtual ~WebWorkerBase();
+
+    // WebCommonWorkerBase methods:
+    virtual void postMessageToWorkerObject(
+        PassRefPtr<WebCore::SerializedScriptValue>,
+        PassOwnPtr<WebCore::MessagePortChannelArray>);
+    virtual void postExceptionToWorkerObject(
+        const WTF::String&, int, const WTF::String&);
+    virtual void postConsoleMessageToWorkerObject(
+        WebCore::MessageSource, WebCore::MessageType,
+        WebCore::MessageLevel, const WTF::String&, int, const WTF::String&);
+    virtual void postMessageToPageInspector(const WTF::String&);
+    virtual void updateInspectorStateCookie(const WTF::String&);
+    virtual void confirmMessageFromWorkerObject(bool);
+    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>);
+    virtual void postTaskForModeToWorkerContext(
+        PassOwnPtr<WebCore::ScriptExecutionContext::Task>, const WTF::String& mode);
+
+    // WebFrameClient methods to support resource loading thru the 'shadow page'.
+    virtual void didCreateDataSource(WebFrame*, WebDataSource*);
+    virtual WebApplicationCacheHost* createApplicationCacheHost(WebFrame*, WebApplicationCacheHostClient*);
 
     // Executes the given task on the main thread.
     static void dispatchTaskToMainThread(PassOwnPtr<WebCore::ScriptExecutionContext::Task>);
+
+protected:
+    virtual WebCommonWorkerClient* commonClient() = 0;
+    virtual WebWorkerClient* client() = 0;
+
+    void setWorkerThread(PassRefPtr<WebCore::WorkerThread> thread) { m_workerThread = thread; }
+    WebCore::WorkerThread* workerThread() { return m_workerThread.get(); }
+
+    // Shuts down the worker thread.
+    void stopWorkerThread();
+
+    // Creates the shadow loader used for worker network requests.
+    void initializeLoader(const WebURL&);
+
+private:
+    // Function used to invoke tasks on the main thread.
+    static void invokeTaskMethod(void*);
+
+    // Tasks that are run on the main thread.
+    static void postMessageTask(
+        WebCore::ScriptExecutionContext* context,
+        WebWorkerBase* thisPtr,
+        WTF::String message,
+        PassOwnPtr<WebCore::MessagePortChannelArray> channels);
+    static void postExceptionTask(
+        WebCore::ScriptExecutionContext* context,
+        WebWorkerBase* thisPtr,
+        const WTF::String& message,
+        int lineNumber,
+        const WTF::String& sourceURL);
+    static void postConsoleMessageTask(
+        WebCore::ScriptExecutionContext* context,
+        WebWorkerBase* thisPtr,
+        int source,
+        int type,
+        int level,
+        const WTF::String& message,
+        int lineNumber,
+        const WTF::String& sourceURL);
+    static void postMessageToPageInspectorTask(WebCore::ScriptExecutionContext*, WebWorkerBase*, const WTF::String&);
+    static void updateInspectorStateCookieTask(WebCore::ScriptExecutionContext*, WebWorkerBase* thisPtr, const WTF::String& cookie);
+    static void confirmMessageTask(
+        WebCore::ScriptExecutionContext* context,
+        WebWorkerBase* thisPtr,
+        bool hasPendingActivity);
+    static void reportPendingActivityTask(
+        WebCore::ScriptExecutionContext* context,
+        WebWorkerBase* thisPtr,
+        bool hasPendingActivity);
+    static void workerContextClosedTask(
+        WebCore::ScriptExecutionContext* context,
+        WebWorkerBase* thisPtr);
+    static void workerContextDestroyedTask(
+        WebCore::ScriptExecutionContext* context,
+        WebWorkerBase* thisPtr);
+
+    // 'shadow page' - created to proxy loading requests from the worker.
+    RefPtr<WebCore::ScriptExecutionContext> m_loadingDocument;
+    WebView* m_webView;
+    bool m_askedToTerminate;
+
+    RefPtr<WebCore::WorkerThread> m_workerThread;
 };
 
 } // namespace WebKit
index 5090affbc515766bca0077eecce2e4ff0e48e301..5b9f32047dde5739ac9cc36b9a5b1bb2d067a133 100644 (file)
@@ -63,6 +63,7 @@
 #include "platform/WebURL.h"
 #include "WebViewImpl.h"
 #include "WebWorker.h"
+#include "WebWorkerImpl.h"
 
 using namespace WebCore;
 
index 5189ad14a64544bdbf7b6493b30b869f3dfb72a7..7006a94cf7d96a643c839b9599a57d9d4b0e66b3 100644 (file)
@@ -58,8 +58,8 @@ class WebFrameImpl;
 // In essence, this class wraps WorkerMessagingProxy.
 class WebWorkerClientImpl : public WebCore::WorkerContextProxy
                           , public WebCore::WorkerObjectProxy
-                          , public WebWorkerBase
-                          , public WebCommonWorkerClient {
+                          , public NewWebWorkerBase
+                          , public NewWebCommonWorkerClient {
 public:
     // WebCore::WorkerContextProxy Factory.
     static WebCore::WorkerContextProxy* createWorkerContextProxy(WebCore::Worker*);
@@ -107,7 +107,7 @@ public:
                                 WebFileSystemCallbacks*);
 
     // WebCommentWorkerBase methods:
-    virtual WebCommonWorkerClient* commonClient() { return this; }
+    virtual NewWebCommonWorkerClient* newCommonClient() { return this; }
     virtual WebView* view() const;
 
 private:
diff --git a/Source/WebKit/chromium/src/WebWorkerImpl.cpp b/Source/WebKit/chromium/src/WebWorkerImpl.cpp
new file mode 100644 (file)
index 0000000..dcbfeee
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebWorkerImpl.h"
+
+#include "CrossThreadTask.h"
+#include "DedicatedWorkerContext.h"
+#include "DedicatedWorkerThread.h"
+#include "KURL.h"
+#include "MessageEvent.h"
+#include "MessagePort.h"
+#include "MessagePortChannel.h"
+#include "ScriptExecutionContext.h"
+#include "SecurityOrigin.h"
+#include "SerializedScriptValue.h"
+#include "SubstituteData.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/Threading.h>
+
+#include "PlatformMessagePortChannel.h"
+#include "WebMessagePortChannel.h"
+#include "platform/WebString.h"
+#include "platform/WebURL.h"
+#include "WebWorkerClient.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#if ENABLE(WORKERS)
+
+WebWorker* WebWorker::create(WebWorkerClient* client)
+{
+    return new WebWorkerImpl(client);
+}
+
+
+WebWorkerImpl::WebWorkerImpl(WebWorkerClient* client)
+    : m_client(client)
+{
+}
+
+WebWorkerImpl::~WebWorkerImpl()
+{
+}
+
+NewWebCommonWorkerClient* WebWorkerImpl::newCommonClient()
+{
+    return m_client;
+}
+
+WebCommonWorkerClient* WebWorkerImpl::commonClient()
+{
+    return m_client;
+}
+
+void WebWorkerImpl::postMessageToWorkerContextTask(WebCore::ScriptExecutionContext* context,
+                                                   WebWorkerImpl* thisPtr,
+                                                   const String& message,
+                                                   PassOwnPtr<MessagePortChannelArray> channels)
+{
+    ASSERT(context->isWorkerContext());
+    DedicatedWorkerContext* workerContext =
+        static_cast<DedicatedWorkerContext*>(context);
+
+    OwnPtr<MessagePortArray> ports =
+        MessagePort::entanglePorts(*context, channels);
+    RefPtr<SerializedScriptValue> serializedMessage =
+        SerializedScriptValue::createFromWire(message);
+    workerContext->dispatchEvent(MessageEvent::create(
+        ports.release(), serializedMessage.release()));
+    thisPtr->confirmMessageFromWorkerObject(workerContext->hasPendingActivity());
+}
+
+// WebWorker -------------------------------------------------------------------
+
+void WebWorkerImpl::startWorkerContext(const WebURL& scriptUrl,
+                                       const WebString& userAgent,
+                                       const WebString& sourceCode)
+{
+    initializeLoader(scriptUrl);
+    setWorkerThread(DedicatedWorkerThread::create(scriptUrl, userAgent, sourceCode, *this, *this, DontPauseWorkerContextOnStart));
+    // Worker initialization means a pending activity.
+    reportPendingActivity(true);
+    workerThread()->start();
+}
+
+void WebWorkerImpl::terminateWorkerContext()
+{
+    stopWorkerThread();
+}
+
+void WebWorkerImpl::postMessageToWorkerContext(const WebString& message,
+                                               const WebMessagePortChannelArray& webChannels)
+{
+    OwnPtr<MessagePortChannelArray> channels;
+    if (webChannels.size()) {
+        channels = adoptPtr(new MessagePortChannelArray(webChannels.size()));
+        for (size_t i = 0; i < webChannels.size(); ++i) {
+            RefPtr<PlatformMessagePortChannel> platform_channel =
+                PlatformMessagePortChannel::create(webChannels[i]);
+            webChannels[i]->setClient(platform_channel.get());
+            (*channels)[i] = MessagePortChannel::create(platform_channel);
+        }
+    }
+
+    workerThread()->runLoop().postTask(
+        createCallbackTask(&postMessageToWorkerContextTask,
+                           AllowCrossThreadAccess(this), String(message), channels.release()));
+}
+
+void WebWorkerImpl::workerObjectDestroyed()
+{
+    // Worker object in the renderer was destroyed, perhaps a result of GC.
+    // For us, it's a signal to start terminating the WorkerContext too.
+    // FIXME: when 'kill a worker' html5 spec algorithm is implemented, it
+    // should be used here instead of 'terminate a worker'.
+    terminateWorkerContext();
+}
+
+void WebWorkerImpl::clientDestroyed()
+{
+    m_client = 0;
+}
+
+#else
+
+WebWorker* WebWorker::create(WebWorkerClient* client)
+{
+    return 0;
+}
+
+#endif // ENABLE(WORKERS)
+
+} // namespace WebKit
diff --git a/Source/WebKit/chromium/src/WebWorkerImpl.h b/Source/WebKit/chromium/src/WebWorkerImpl.h
new file mode 100644 (file)
index 0000000..4f052a7
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebWorkerImpl_h
+#define WebWorkerImpl_h
+
+#include "WebWorker.h"
+
+#if ENABLE(WORKERS)
+
+#include "ScriptExecutionContext.h"
+
+#include "WebWorkerBase.h"
+
+namespace WebKit {
+
+// This class is used by the worker process code to talk to the WebCore::Worker
+// implementation.  It can't use it directly since it uses WebKit types, so this
+// class converts the data types.  When the WebCore::Worker object wants to call
+// WebCore::WorkerObjectProxy, this class will conver to Chrome data types first
+// and then call the supplied WebWorkerClient.
+class WebWorkerImpl : public WebWorkerBase, public WebWorker {
+public:
+    explicit WebWorkerImpl(WebWorkerClient* client);
+
+    // WebWorker methods:
+    virtual void startWorkerContext(const WebURL&, const WebString&, const WebString&);
+    virtual void terminateWorkerContext();
+    virtual void postMessageToWorkerContext(const WebString&, const WebMessagePortChannelArray&);
+    virtual void workerObjectDestroyed();
+    virtual void clientDestroyed();
+
+    // WebWorkerBase methods:
+    virtual WebWorkerClient* client() { return m_client; }
+    virtual WebCommonWorkerClient* commonClient();
+
+    // NewWebWorkerBase methods:
+    virtual NewWebCommonWorkerClient* newCommonClient();
+
+private:
+    virtual ~WebWorkerImpl();
+
+    // Tasks that are run on the worker thread.
+    static void postMessageToWorkerContextTask(
+        WebCore::ScriptExecutionContext* context,
+        WebWorkerImpl* thisPtr,
+        const WTF::String& message,
+        PassOwnPtr<WebCore::MessagePortChannelArray> channels);
+
+    WebWorkerClient* m_client;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(WORKERS)
+
+#endif
index 8ce5e6976bb09193d3a7409a5a1cf78fc4c05571..523ef75afe2c85ea6d08e78bf48568b162cd2082 100644 (file)
@@ -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);
index 9c44cb1a976e8d652e0604fc61e70a92e3a2ede9..8ae7eb349510f49f0296d5bd49240552774a03e4 100644 (file)
@@ -51,7 +51,7 @@ namespace WebKit {
 
 class AsyncFileSystem;
 class MainThreadFileSystemCallbacks;
-class WebCommonWorkerClient;
+class NewWebCommonWorkerClient;
 class ThreadableCallbacksBridgeWrapper;
 class WebFileSystemCallbacks;
 struct WebFileInfo;
@@ -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);
index 9953a7a61d0acdbc09f073e1cb7467071c963bbe..8d14bb9345ea1a77aa7edcddf7a9dd382102906c 100644 (file)
@@ -1,3 +1,17 @@
+2011-12-24  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Unreviewed, rolling out r103619.
+        http://trac.webkit.org/changeset/103619
+        https://bugs.webkit.org/show_bug.cgi?id=66509
+
+        Broke chromium clang build
+
+        * DumpRenderTree/chromium/TestWebWorker.h:
+        (TestWebWorker::createWorker):
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::createWorker):
+        * DumpRenderTree/chromium/WebViewHost.h:
+
 2011-12-23  Daniel Bates  <dbates@webkit.org>
 
         Provide option to disable Mac OS 10.7 application resume when using
index ad82a87e9ec5cea3fb6fd777ea63679836e2d1d9..71bffce628f7b00b0468d03b377268cb6f5ef93f 100644 (file)
@@ -32,8 +32,8 @@
 #define TestWebWorker_h
 
 #include "WebMessagePortChannel.h"
-#include "WebSharedWorkerClient.h"
 #include "WebWorker.h"
+#include "WebWorkerClient.h"
 #include <wtf/RefCounted.h>
 
 namespace WebKit {
@@ -43,7 +43,7 @@ class WebURL;
 }
 
 class TestWebWorker : public WebKit::WebWorker,
-                      public WebKit::WebSharedWorkerClient,
+                      public WebKit::WebWorkerClient,
                       public WTF::RefCounted<TestWebWorker> {
 public:
     TestWebWorker()
@@ -80,7 +80,7 @@ public:
         // Releases the reference held for worker context object.
         deref();
     }
-    virtual WebKit::WebWorker* createWorker(WebKit::WebSharedWorkerClient*) { return 0; }
+    virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient*) { return 0; }
     virtual WebKit::WebNotificationPresenter* notificationPresenter() { return 0; }
     virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(WebKit::WebApplicationCacheHostClient*) { return 0; }
     virtual bool allowDatabase(WebKit::WebFrame*, const WebKit::WebString&, const WebKit::WebString&, unsigned long) { return true; }
index 1b0687dd06f5d91033fb1f1be6c49e2d40b55acf..de65e905497fb87d2fa58f5e24ef3d010c5ce8a2 100644 (file)
@@ -837,7 +837,7 @@ WebPlugin* WebViewHost::createPlugin(WebFrame* frame, const WebPluginParams& par
     return webkit_support::CreateWebPlugin(frame, params);
 }
 
-WebWorker* WebViewHost::createWorker(WebFrame*, WebSharedWorkerClient*)
+WebWorker* WebViewHost::createWorker(WebFrame*, WebWorkerClient*)
 {
     return new TestWebWorker();
 }
index 0bc4c38e67395ddb2c8d48ddae141bc0becb6633..31ecd796adc7979dd3902bdbb641ec1908604242 100644 (file)
@@ -55,7 +55,6 @@ class WebDeviceOrientationClientMock;
 class WebGeolocationClient;
 class WebGeolocationClientMock;
 class WebGeolocationServiceMock;
-class WebSharedWorkerClient;
 class WebSpeechInputController;
 class WebSpeechInputControllerMock;
 class WebSpeechInputListener;
@@ -174,7 +173,7 @@ class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewCl
 
     // WebKit::WebFrameClient
     virtual WebKit::WebPlugin* createPlugin(WebKit::WebFrame*, const WebKit::WebPluginParams&);
-    virtual WebKit::WebWorker* createWorker(WebKit::WebFrame*, WebKit::WebSharedWorkerClient*);
+    virtual WebKit::WebWorker* createWorker(WebKit::WebFrame*, WebKit::WebWorkerClient*);
     virtual WebKit::WebMediaPlayer* createMediaPlayer(WebKit::WebFrame*, WebKit::WebMediaPlayerClient*);
     virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(WebKit::WebFrame*, WebKit::WebApplicationCacheHostClient*);
     virtual void loadURLExternally(WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebNavigationPolicy);