[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

weinig at apple.com weinig at apple.com
Wed Dec 22 13:23:41 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 12a27a2e0d09bbae4226509d32fd171973ad4177
Author: weinig at apple.com <weinig at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Sep 14 02:48:48 2010 +0000

    Threaded mode should work in WebKit2 MiniBrowser
    https://bugs.webkit.org/show_bug.cgi?id=45727
    
    Reviewed by Jon Honeycutt.
    
    - Make starting the web thread more like starting a new
      process (encapsulate it in a thread launcher class).
    - Make the call to didFinishLaunching asynchronous so that
      WebProcess is fully constructed before it is called.
    
    * Platform/WorkItem.h:
    (MemberFunctionWorkItem1::MemberFunctionWorkItem1):
    (MemberFunctionWorkItem1::~MemberFunctionWorkItem1):
    (MemberFunctionWorkItem1::execute):
    (WorkItem::create):
    * UIProcess/Launcher/ProcessLauncher.h:
    * UIProcess/Launcher/ThreadLauncher.cpp: Added.
    (WebKit::ThreadLauncher::ThreadLauncher):
    (WebKit::ThreadLauncher::launchThread):
    (WebKit::ThreadLauncher::didFinishLaunchingThread):
    (WebKit::ThreadLauncher::invalidate):
    * UIProcess/Launcher/ThreadLauncher.h: Added.
    (WebKit::ThreadLauncher::Client::~Client):
    (WebKit::ThreadLauncher::create):
    (WebKit::ThreadLauncher::isLaunching):
    * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
    (WebKit::ProcessLauncher::terminateProcess):
    * UIProcess/Launcher/mac/ThreadLauncherMac.mm: Added.
    (WebKit::webThreadBody):
    (WebKit::ThreadLauncher::createWebThread):
    * UIProcess/Launcher/qt/ProcessLauncherQt.cpp:
    * UIProcess/Launcher/qt/ThreadLauncherQt.cpp: Added.
    (WebKit::webThreadBody):
    (WebKit::ProcessLauncher::createWebThread):
    * UIProcess/Launcher/win/ProcessLauncherWin.cpp:
    * UIProcess/Launcher/win/ThreadLauncherWin.cpp: Added.
    (WebKit::webThreadBody):
    (WebKit::ProcessLauncher::createWebThread):
    * UIProcess/WebProcessProxy.cpp:
    (WebKit::WebProcessProxy::~WebProcessProxy):
    (WebKit::WebProcessProxy::connect):
    (WebKit::WebProcessProxy::isLaunching):
    (WebKit::WebProcessProxy::didFinishLaunching):
    * UIProcess/WebProcessProxy.h:
    * WebKit2.pro:
    * WebKit2.xcodeproj/project.pbxproj:
    * win/WebKit2.vcproj:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67433 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 6a2ffcd..c84e956 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,5 +1,55 @@
 2010-09-13  Sam Weinig  <sam at webkit.org>
 
+        Reviewed by Jon Honeycutt.
+
+        Threaded mode should work in WebKit2 MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=45727
+
+        - Make starting the web thread more like starting a new
+          process (encapsulate it in a thread launcher class).
+        - Make the call to didFinishLaunching asynchronous so that
+          WebProcess is fully constructed before it is called.
+
+        * Platform/WorkItem.h:
+        (MemberFunctionWorkItem1::MemberFunctionWorkItem1):
+        (MemberFunctionWorkItem1::~MemberFunctionWorkItem1):
+        (MemberFunctionWorkItem1::execute):
+        (WorkItem::create):
+        * UIProcess/Launcher/ProcessLauncher.h:
+        * UIProcess/Launcher/ThreadLauncher.cpp: Added.
+        (WebKit::ThreadLauncher::ThreadLauncher):
+        (WebKit::ThreadLauncher::launchThread):
+        (WebKit::ThreadLauncher::didFinishLaunchingThread):
+        (WebKit::ThreadLauncher::invalidate):
+        * UIProcess/Launcher/ThreadLauncher.h: Added.
+        (WebKit::ThreadLauncher::Client::~Client):
+        (WebKit::ThreadLauncher::create):
+        (WebKit::ThreadLauncher::isLaunching):
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::ProcessLauncher::terminateProcess):
+        * UIProcess/Launcher/mac/ThreadLauncherMac.mm: Added.
+        (WebKit::webThreadBody):
+        (WebKit::ThreadLauncher::createWebThread):
+        * UIProcess/Launcher/qt/ProcessLauncherQt.cpp:
+        * UIProcess/Launcher/qt/ThreadLauncherQt.cpp: Added.
+        (WebKit::webThreadBody):
+        (WebKit::ProcessLauncher::createWebThread):
+        * UIProcess/Launcher/win/ProcessLauncherWin.cpp:
+        * UIProcess/Launcher/win/ThreadLauncherWin.cpp: Added.
+        (WebKit::webThreadBody):
+        (WebKit::ProcessLauncher::createWebThread):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::~WebProcessProxy):
+        (WebKit::WebProcessProxy::connect):
+        (WebKit::WebProcessProxy::isLaunching):
+        (WebKit::WebProcessProxy::didFinishLaunching):
+        * UIProcess/WebProcessProxy.h:
+        * WebKit2.pro:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * win/WebKit2.vcproj:
+
+2010-09-13  Sam Weinig  <sam at webkit.org>
+
         Reviewed by Anders Carlsson.
 
         didFinishDocumentLoadForFrame() is not being sent by WebKit2
diff --git a/WebKit2/Platform/WorkItem.h b/WebKit2/Platform/WorkItem.h
index 2792dff..e3c7700 100644
--- a/WebKit2/Platform/WorkItem.h
+++ b/WebKit2/Platform/WorkItem.h
@@ -33,6 +33,9 @@ public:
     template<typename C> 
     static PassOwnPtr<WorkItem> create(C*, void (C::*)());
 
+    template<typename C, typename T0>
+    static PassOwnPtr<WorkItem> create(C*, void (C::*)(T0), T0);
+
     template<typename C, typename T0, typename T1>
     static PassOwnPtr<WorkItem> create(C*, void (C::*)(T0, T1), T0, T1);
 
@@ -75,6 +78,36 @@ class MemberFunctionWorkItem0 : private WorkItem {
     FunctionType m_function;
 };
 
+template<typename C, typename T0>
+class MemberFunctionWorkItem1 : private WorkItem {
+    // We only allow WorkItem to create this.
+    friend class WorkItem;
+    
+    typedef void (C::*FunctionType)(T0);
+    
+    MemberFunctionWorkItem1(C* ptr, FunctionType function, T0 t0)
+        : m_ptr(ptr)
+        , m_function(function)
+        , m_t0(t0)
+    {
+        m_ptr->ref();
+    }
+    
+    ~MemberFunctionWorkItem1()
+    {
+        m_ptr->deref();
+    }
+
+    void execute()
+    {
+        (m_ptr->*m_function)(m_t0);
+    }
+    
+    C* m_ptr;
+    FunctionType m_function;
+    T0 m_t0;
+};
+
 template<typename C, typename T0, typename T1>
 class MemberFunctionWorkItem2 : private WorkItem {
     // We only allow WorkItem to create this.
@@ -113,6 +146,12 @@ PassOwnPtr<WorkItem> WorkItem::create(C* ptr, void (C::*function)())
     return adoptPtr(static_cast<WorkItem*>(new MemberFunctionWorkItem0<C>(ptr, function)));
 }
 
+template<typename C, typename T0>
+PassOwnPtr<WorkItem> WorkItem::create(C* ptr, void (C::*function)(T0), T0 t0)
+{
+    return adoptPtr(static_cast<WorkItem*>(new MemberFunctionWorkItem1<C, T0>(ptr, function, t0)));
+}
+
 template<typename C, typename T0, typename T1>
 PassOwnPtr<WorkItem> WorkItem::create(C* ptr, void (C::*function)(T0, T1), T0 t0, T1 t1)
 {
diff --git a/WebKit2/UIProcess/Launcher/ProcessLauncher.h b/WebKit2/UIProcess/Launcher/ProcessLauncher.h
index dff212e..6398f7c 100644
--- a/WebKit2/UIProcess/Launcher/ProcessLauncher.h
+++ b/WebKit2/UIProcess/Launcher/ProcessLauncher.h
@@ -43,7 +43,7 @@ public:
     public:
         virtual ~Client() { }
         
-        virtual void didFinishLaunching(ProcessLauncher*, const CoreIPC::Connection::Identifier&) = 0;
+        virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier) = 0;
     };
     
     static PassRefPtr<ProcessLauncher> create(Client* client)
@@ -57,8 +57,6 @@ public:
     void terminateProcess();
     void invalidate();
 
-    static CoreIPC::Connection::Identifier createWebThread();
-
 #if PLATFORM(QT)
     friend class ProcessLauncherHelper;
     static QLocalSocket* takePendingConnection();
diff --git a/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp b/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp
new file mode 100644
index 0000000..69e4893
--- /dev/null
+++ b/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "ThreadLauncher.h"
+
+#include "RunLoop.h"
+
+namespace WebKit {
+
+ThreadLauncher::ThreadLauncher(Client* client)
+    : m_client(client)
+{
+    launchThread();
+}
+
+void ThreadLauncher::launchThread()
+{
+    m_isLaunching = true;
+
+    CoreIPC::Connection::Identifier connectionIdentifier = createWebThread();
+
+    // We've finished launching the thread, message back to the main run loop.
+    RunLoop::main()->scheduleWork(WorkItem::create(this, &ThreadLauncher::didFinishLaunchingThread, connectionIdentifier));
+}
+
+void ThreadLauncher::didFinishLaunchingThread(CoreIPC::Connection::Identifier identifier)
+{
+    m_isLaunching = false;
+    
+    if (!m_client) {
+        // FIXME: Dispose of the connection identifier.
+        return;
+    }
+
+    m_client->didFinishLaunching(this, identifier);
+}
+
+void ThreadLauncher::invalidate()
+{
+    m_client = 0;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/Launcher/ThreadLauncher.h b/WebKit2/UIProcess/Launcher/ThreadLauncher.h
new file mode 100644
index 0000000..9c90fbd
--- /dev/null
+++ b/WebKit2/UIProcess/Launcher/ThreadLauncher.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 ThreadLauncher_h
+#define ThreadLauncher_h
+
+#include "Connection.h"
+#include "PlatformProcessIdentifier.h"
+#include <wtf/RefPtr.h>
+#include <wtf/Threading.h>
+
+#if PLATFORM(QT)
+class QLocalSocket;
+#endif
+
+namespace WebKit {
+
+class ThreadLauncher : public ThreadSafeShared<ThreadLauncher> {
+public:
+    class Client {
+    public:
+        virtual ~Client() { }
+        virtual void didFinishLaunching(ThreadLauncher*, CoreIPC::Connection::Identifier) = 0;
+    };
+    
+    static PassRefPtr<ThreadLauncher> create(Client* client)
+    {
+        return adoptRef(new ThreadLauncher(client));
+    }
+
+    bool isLaunching() const { return m_isLaunching; }
+
+    void invalidate();
+
+private:
+    explicit ThreadLauncher(Client*);
+
+    void launchThread();
+    void didFinishLaunchingThread(CoreIPC::Connection::Identifier);
+
+    static CoreIPC::Connection::Identifier createWebThread();
+
+    bool m_isLaunching;
+    Client* m_client;
+};
+
+} // namespace WebKit
+
+#endif // ThreadLauncher_h
diff --git a/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
index b0f61c4..4326543 100644
--- a/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
+++ b/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
@@ -125,41 +125,5 @@ void ProcessLauncher::terminateProcess()
     
     kill(m_processIdentifier, SIGKILL);
 }
-
-static void* webThreadBody(void* context)
-{
-    mach_port_t serverPort = static_cast<mach_port_t>(reinterpret_cast<uintptr_t>(context));
-
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    InitWebCoreSystemInterface();
-    JSC::initializeThreading();
-    WTF::initializeMainThread();
-
-    WebProcess::shared().initialize(serverPort, RunLoop::current());
-
-    [pool drain];
-
-    RunLoop::current()->run();
-
-    return 0;
-}
-
-CoreIPC::Connection::Identifier ProcessLauncher::createWebThread()
-{
-    // Create the service port.
-     mach_port_t listeningPort;
-     mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
-     
-     // Insert a send right so we can send to it.
-     mach_port_insert_right(mach_task_self(), listeningPort, listeningPort, MACH_MSG_TYPE_MAKE_SEND);
-
-    if (!createThread(webThreadBody, reinterpret_cast<void*>(listeningPort), "WebKit2: WebThread")) {
-        mach_port_destroy(mach_task_self(), listeningPort);
-        return MACH_PORT_NULL;
-    }
-
-    return listeningPort;
-}
     
 } // namespace WebKit
diff --git a/WebKit2/UIProcess/Launcher/mac/ThreadLauncherMac.mm b/WebKit2/UIProcess/Launcher/mac/ThreadLauncherMac.mm
new file mode 100644
index 0000000..8aac275
--- /dev/null
+++ b/WebKit2/UIProcess/Launcher/mac/ThreadLauncherMac.mm
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "ThreadLauncher.h"
+
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include "WebSystemInterface.h"
+#include <runtime/InitializeThreading.h>
+#include <wtf/Threading.h>
+
+namespace WebKit {
+
+static void* webThreadBody(void* context)
+{
+    mach_port_t serverPort = static_cast<mach_port_t>(reinterpret_cast<uintptr_t>(context));
+
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+    InitWebCoreSystemInterface();
+    JSC::initializeThreading();
+    WTF::initializeMainThread();
+
+    WebProcess::shared().initialize(serverPort, RunLoop::current());
+
+    [pool drain];
+
+    RunLoop::current()->run();
+
+    return 0;
+}
+
+CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
+{
+    // Create the service port.
+     mach_port_t listeningPort;
+     mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+     
+     // Insert a send right so we can send to it.
+     mach_port_insert_right(mach_task_self(), listeningPort, listeningPort, MACH_MSG_TYPE_MAKE_SEND);
+
+    if (!createThread(webThreadBody, reinterpret_cast<void*>(listeningPort), "WebKit2: WebThread")) {
+        mach_port_destroy(mach_task_self(), listeningPort);
+        return MACH_PORT_NULL;
+    }
+
+    return listeningPort;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
index 465f810..e1ba682 100644
--- a/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
+++ b/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
@@ -141,34 +141,6 @@ QLocalSocket* ProcessLauncher::takePendingConnection()
     return ProcessLauncherHelper::instance()->takePendingConnection();
 }
 
-static void* webThreadBody(void* /* context */)
-{
-    // Initialization
-    JSC::initializeThreading();
-    WTF::initializeMainThread();
-
-    // FIXME: We do not support threaded mode for now.
-
-    WebProcess::shared().initialize("foo", RunLoop::current());
-    RunLoop::run();
-
-    return 0;
-}
-
-CoreIPC::Connection::Identifier ProcessLauncher::createWebThread()
-{
-    srandom(time(0));
-    int connectionIdentifier = random();
-
-    if (!createThread(webThreadBody, reinterpret_cast<void*>(connectionIdentifier), "WebKit2: WebThread")) {
-        qWarning() << "failed starting thread";
-        return 0;
-    }
-
-    QString serverIdentifier = QString::number(connectionIdentifier);
-    return serverIdentifier;
-}
-
 } // namespace WebKit
 
 #include "ProcessLauncherQt.moc"
diff --git a/WebKit2/UIProcess/Launcher/qt/ThreadLauncherQt.cpp b/WebKit2/UIProcess/Launcher/qt/ThreadLauncherQt.cpp
new file mode 100644
index 0000000..471a424
--- /dev/null
+++ b/WebKit2/UIProcess/Launcher/qt/ThreadLauncherQt.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "ThreadLauncher.h"
+
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include <runtime/InitializeThreading.h>
+#include <wtf/Threading.h>
+
+#include <QApplication>
+#include <QDebug>
+#include <QFile>
+#include <QLocalServer>
+#include <QProcess>
+
+#include <QtCore/qglobal.h>
+
+#include <sys/resource.h>
+#include <unistd.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static void* webThreadBody(void* /* context */)
+{
+    // Initialization
+    JSC::initializeThreading();
+    WTF::initializeMainThread();
+
+    // FIXME: We do not support threaded mode for now.
+
+    WebProcess::shared().initialize("foo", RunLoop::current());
+    RunLoop::run();
+
+    return 0;
+}
+
+CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
+{
+    srandom(time(0));
+    int connectionIdentifier = random();
+
+    if (!createThread(webThreadBody, reinterpret_cast<void*>(connectionIdentifier), "WebKit2: WebThread")) {
+        qWarning() << "failed starting thread";
+        return 0;
+    }
+
+    QString serverIdentifier = QString::number(connectionIdentifier);
+    return serverIdentifier;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp b/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp
index db9cad4..63f423d 100644
--- a/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp
+++ b/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp
@@ -27,9 +27,6 @@
 
 #include "Connection.h"
 #include "RunLoop.h"
-#include "WebProcess.h"
-#include <runtime/InitializeThreading.h>
-#include <wtf/Threading.h>
 #include <wtf/text/WTFString.h>
 
 using namespace WebCore;
@@ -94,36 +91,4 @@ void ProcessLauncher::terminateProcess()
     ::TerminateProcess(m_processIdentifier, 0);
 }
 
-static void* webThreadBody(void* context)
-{
-    HANDLE clientIdentifier = reinterpret_cast<HANDLE>(context);
-
-    // Initialization
-    JSC::initializeThreading();
-    WTF::initializeMainThread();
-
-    WebProcess::shared().initialize(clientIdentifier, RunLoop::current());
-    RunLoop::run();
-
-    return 0;
-}
-
-CoreIPC::Connection::Identifier ProcessLauncher::createWebThread()
-{
-    // First, create the server and client identifiers.
-    HANDLE serverIdentifier, clientIdentifier;
-    if (!CoreIPC::Connection::createServerAndClientIdentifiers(serverIdentifier, clientIdentifier)) {
-        // FIXME: What should we do here?
-        ASSERT_NOT_REACHED();
-    }
-
-    if (!createThread(webThreadBody, reinterpret_cast<void*>(clientIdentifier), "WebKit2: WebThread")) {
-        ::CloseHandle(serverIdentifier);
-        ::CloseHandle(clientIdentifier);
-        return 0;
-    }
-
-    return serverIdentifier;
-}
-
 } // namespace WebKit
diff --git a/WebKit2/UIProcess/Launcher/win/ThreadLauncherWin.cpp b/WebKit2/UIProcess/Launcher/win/ThreadLauncherWin.cpp
new file mode 100644
index 0000000..b8b2f64
--- /dev/null
+++ b/WebKit2/UIProcess/Launcher/win/ThreadLauncherWin.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "ThreadLauncher.h"
+
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include <runtime/InitializeThreading.h>
+#include <wtf/Threading.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static void* webThreadBody(void* context)
+{
+    HANDLE clientIdentifier = reinterpret_cast<HANDLE>(context);
+
+    // Initialization
+    JSC::initializeThreading();
+    WTF::initializeMainThread();
+
+    WebProcess::shared().initialize(clientIdentifier, RunLoop::current());
+    RunLoop::run();
+
+    return 0;
+}
+
+CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
+{
+    // First, create the server and client identifiers.
+    HANDLE serverIdentifier, clientIdentifier;
+    if (!CoreIPC::Connection::createServerAndClientIdentifiers(serverIdentifier, clientIdentifier)) {
+        // FIXME: What should we do here?
+        ASSERT_NOT_REACHED();
+    }
+
+    if (!createThread(webThreadBody, reinterpret_cast<void*>(clientIdentifier), "WebKit2: WebThread")) {
+        ::CloseHandle(serverIdentifier);
+        ::CloseHandle(clientIdentifier);
+        return 0;
+    }
+
+    return serverIdentifier;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/UIProcess/WebProcessProxy.cpp b/WebKit2/UIProcess/WebProcessProxy.cpp
index 26d3ad9..d09a062 100644
--- a/WebKit2/UIProcess/WebProcessProxy.cpp
+++ b/WebKit2/UIProcess/WebProcessProxy.cpp
@@ -26,7 +26,6 @@
 #include "WebProcessProxy.h"
 
 #include "PluginInfoStore.h"
-#include "ProcessLauncher.h"
 #include "WebBackForwardListItem.h"
 #include "WebContext.h"
 #include "WebNavigationDataStore.h"
@@ -102,18 +101,22 @@ WebProcessProxy::~WebProcessProxy()
         m_processLauncher->invalidate();
         m_processLauncher = 0;
     }
+
+    if (m_threadLauncher) {
+        m_threadLauncher->invalidate();
+        m_threadLauncher = 0;
+    }
 }
 
 void WebProcessProxy::connect()
 {
     if (m_context->processModel() == ProcessModelSharedSecondaryThread) {
-        CoreIPC::Connection::Identifier connectionIdentifier = ProcessLauncher::createWebThread();
-        didFinishLaunching(0, connectionIdentifier);
-        return;
+        ASSERT(!m_threadLauncher);
+        m_threadLauncher = ThreadLauncher::create(this);
+    } else {
+        ASSERT(!m_processLauncher);
+        m_processLauncher = ProcessLauncher::create(this);
     }
-
-    ASSERT(!m_processLauncher);
-    m_processLauncher = ProcessLauncher::create(this);
 }
 
 bool WebProcessProxy::sendMessage(CoreIPC::MessageID messageID, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments)
@@ -128,6 +131,16 @@ bool WebProcessProxy::sendMessage(CoreIPC::MessageID messageID, PassOwnPtr<CoreI
     return m_connection->sendMessage(messageID, arguments);
 }
 
+bool WebProcessProxy::isLaunching() const
+{
+    if (m_processLauncher)
+        return m_processLauncher->isLaunching();
+    if (m_threadLauncher)
+        return m_threadLauncher->isLaunching();
+
+    return false;
+}
+
 void WebProcessProxy::terminate()
 {
     if (m_processLauncher)
@@ -424,7 +437,17 @@ void WebProcessProxy::didBecomeResponsive(ResponsivenessTimer*)
         pages[i]->processDidBecomeResponsive();
 }
 
-void WebProcessProxy::didFinishLaunching(ProcessLauncher*, const CoreIPC::Connection::Identifier& connectionIdentifier)
+void WebProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier connectionIdentifier)
+{
+    didFinishLaunching(connectionIdentifier);
+}
+
+void WebProcessProxy::didFinishLaunching(ThreadLauncher*, CoreIPC::Connection::Identifier connectionIdentifier)
+{
+    didFinishLaunching(connectionIdentifier);
+}
+
+void WebProcessProxy::didFinishLaunching(CoreIPC::Connection::Identifier connectionIdentifier)
 {
     ASSERT(!m_connection);
     
diff --git a/WebKit2/UIProcess/WebProcessProxy.h b/WebKit2/UIProcess/WebProcessProxy.h
index 5128626..e337a9d 100644
--- a/WebKit2/UIProcess/WebProcessProxy.h
+++ b/WebKit2/UIProcess/WebProcessProxy.h
@@ -32,9 +32,10 @@
 #include "ProcessLauncher.h"
 #include "ProcessModel.h"
 #include "ResponsivenessTimer.h"
+#include "ThreadLauncher.h"
 #include "WebPageProxy.h"
-#include <wtf/Forward.h>
 #include <WebCore/LinkHash.h>
+#include <wtf/Forward.h>
 #include <wtf/HashMap.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -49,7 +50,7 @@ class WebBackForwardListItem;
 class WebContext;
 class WebPageNamespace;
     
-class WebProcessProxy : public RefCounted<WebProcessProxy>, CoreIPC::Connection::Client, ResponsivenessTimer::Client, ProcessLauncher::Client {
+class WebProcessProxy : public RefCounted<WebProcessProxy>, CoreIPC::Connection::Client, ResponsivenessTimer::Client, ProcessLauncher::Client, ThreadLauncher::Client {
 public:
     typedef HashMap<uint64_t, RefPtr<WebPageProxy> > WebPageProxyMap;
     typedef WebPageProxyMap::const_iterator::Values pages_const_iterator;
@@ -85,7 +86,7 @@ public:
     ResponsivenessTimer* responsivenessTimer() { return &m_responsivenessTimer; }
 
     bool isValid() const { return m_connection; }
-    bool isLaunching() const { return m_processLauncher && m_processLauncher->isLaunching(); }
+    bool isLaunching() const;
 
     WebFrameProxy* webFrame(uint64_t) const;
     void frameCreated(uint64_t, WebFrameProxy*);
@@ -120,13 +121,19 @@ private:
     void didBecomeResponsive(ResponsivenessTimer*);
 
     // ProcessLauncher::Client
-    virtual void didFinishLaunching(ProcessLauncher*, const CoreIPC::Connection::Identifier&);
+    virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier);
+
+    // ThreadLauncher::Client
+    virtual void didFinishLaunching(ThreadLauncher*, CoreIPC::Connection::Identifier);
+
+    void didFinishLaunching(CoreIPC::Connection::Identifier);
 
     ResponsivenessTimer m_responsivenessTimer;
     RefPtr<CoreIPC::Connection> m_connection;
 
     Vector<CoreIPC::Connection::OutgoingMessage> m_pendingMessages;
     RefPtr<ProcessLauncher> m_processLauncher;
+    RefPtr<ThreadLauncher> m_threadLauncher;
 
     WebContext* m_context;
 
diff --git a/WebKit2/WebKit2.pro b/WebKit2/WebKit2.pro
index 398a169..2987561 100644
--- a/WebKit2/WebKit2.pro
+++ b/WebKit2/WebKit2.pro
@@ -201,6 +201,7 @@ HEADERS += \
     UIProcess/DrawingAreaProxy.h \
     UIProcess/GenericCallback.h \
     UIProcess/Launcher/ProcessLauncher.h \
+    UIProcess/Launcher/ThreadLauncher.h \
     UIProcess/Plugins/PluginInfoStore.h \
     UIProcess/PageClient.h \
     UIProcess/ProcessModel.h \
@@ -315,7 +316,9 @@ SOURCES += \
     UIProcess/Plugins/PluginInfoStore.cpp \
     UIProcess/Plugins/qt/PluginInfoStoreQt.cpp \
     UIProcess/Launcher/ProcessLauncher.cpp \
+    UIProcess/Launcher/ThreadLauncher.cpp \
     UIProcess/Launcher/qt/ProcessLauncherQt.cpp \
+    UIProcess/Launcher/qt/ThreadLauncherQt.cpp \
     UIProcess/ResponsivenessTimer.cpp \
     UIProcess/VisitedLinkProvider.cpp \
     UIProcess/WebBackForwardList.cpp \
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 676bf8d..080092b 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -333,6 +333,9 @@
 		BCEE98CD1133174C006BCC24 /* WKPageNamespace.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEE98CB1133174C006BCC24 /* WKPageNamespace.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		BCF049E611FE20F600F86A58 /* WKBundleFramePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF049E411FE20F600F86A58 /* WKBundleFramePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		BCF049E711FE20F600F86A58 /* WKBundlePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF049E511FE20F600F86A58 /* WKBundlePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		BCF50121123ED3B3005955AE /* ThreadLauncher.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF5011F123ED3B3005955AE /* ThreadLauncher.h */; };
+		BCF50122123ED3B3005955AE /* ThreadLauncher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF50120123ED3B3005955AE /* ThreadLauncher.cpp */; };
+		BCF501B4123EF602005955AE /* ThreadLauncherMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCF501B3123EF602005955AE /* ThreadLauncherMac.mm */; };
 		BCF69F861176CD6F00471A52 /* WebHistoryClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF69F841176CD6F00471A52 /* WebHistoryClient.cpp */; };
 		BCF69F871176CD6F00471A52 /* WebHistoryClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF69F851176CD6F00471A52 /* WebHistoryClient.h */; };
 		BCF69F9A1176CED600471A52 /* WebNavigationDataStore.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF69F981176CED600471A52 /* WebNavigationDataStore.h */; };
@@ -716,6 +719,9 @@
 		BCF049E511FE20F600F86A58 /* WKBundlePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundlePrivate.h; sourceTree = "<group>"; };
 		BCF04C8C11FF9B7D00F86A58 /* APIObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIObject.h; sourceTree = "<group>"; };
 		BCF04C8E11FF9F6E00F86A58 /* WebString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebString.h; sourceTree = "<group>"; };
+		BCF5011F123ED3B3005955AE /* ThreadLauncher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadLauncher.h; sourceTree = "<group>"; };
+		BCF50120123ED3B3005955AE /* ThreadLauncher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadLauncher.cpp; sourceTree = "<group>"; };
+		BCF501B3123EF602005955AE /* ThreadLauncherMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ThreadLauncherMac.mm; sourceTree = "<group>"; };
 		BCF69F841176CD6F00471A52 /* WebHistoryClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebHistoryClient.cpp; sourceTree = "<group>"; };
 		BCF69F851176CD6F00471A52 /* WebHistoryClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebHistoryClient.h; sourceTree = "<group>"; };
 		BCF69F981176CED600471A52 /* WebNavigationDataStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNavigationDataStore.h; sourceTree = "<group>"; };
@@ -1230,6 +1236,8 @@
 				BC111B19112F5FC500337BAB /* mac */,
 				1AE117F511DBB30900981615 /* ProcessLauncher.cpp */,
 				BC1A7C571136E19C00FB7167 /* ProcessLauncher.h */,
+				BCF50120123ED3B3005955AE /* ThreadLauncher.cpp */,
+				BCF5011F123ED3B3005955AE /* ThreadLauncher.h */,
 			);
 			path = Launcher;
 			sourceTree = "<group>";
@@ -1238,6 +1246,7 @@
 			isa = PBXGroup;
 			children = (
 				BC111B1B112F5FE600337BAB /* ProcessLauncherMac.mm */,
+				BCF501B3123EF602005955AE /* ThreadLauncherMac.mm */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -1630,6 +1639,7 @@
 				BC33DD681238464600360F3F /* WebNumber.h in Headers */,
 				BC33DE8E12385C3300360F3F /* WKNumber.h in Headers */,
 				BC33DF061238677F00360F3F /* WKSerializedScriptValue.h in Headers */,
+				BCF50121123ED3B3005955AE /* ThreadLauncher.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1876,6 +1886,8 @@
 				BCA0EFA012332642007D3CFB /* WebEditCommandProxy.cpp in Sources */,
 				A72D610B1237144F00A88B15 /* WKSerializedScriptValue.cpp in Sources */,
 				BC33DE8F12385C3300360F3F /* WKNumber.cpp in Sources */,
+				BCF50122123ED3B3005955AE /* ThreadLauncher.cpp in Sources */,
+				BCF501B4123EF602005955AE /* ThreadLauncherMac.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index a87fc97..a555c19 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -1599,6 +1599,14 @@
 					RelativePath="..\UIProcess\Launcher\ProcessLauncher.h"
 					>
 				</File>
+				<File
+					RelativePath="..\UIProcess\Launcher\ThreadLauncher.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\UIProcess\Launcher\ThreadLauncher.h"
+					>
+				</File>
 				<Filter
 					Name="win"
 					>
@@ -1606,6 +1614,10 @@
 						RelativePath="..\UIProcess\Launcher\win\ProcessLauncherWin.cpp"
 						>
 					</File>
+					<File
+						RelativePath="..\UIProcess\Launcher\win\ThreadLauncherWin.cpp"
+						>
+					</File>
 				</Filter>
 			</Filter>
 			<Filter

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list