Title: [98957] trunk/Source/WebKit2
Revision
98957
Author
caio.olive...@openbossa.org
Date
2011-11-01 06:34:34 -0700 (Tue, 01 Nov 2011)

Log Message

[Qt] Create infrastructure for Qt's builtin bundle in web process.
https://bugs.webkit.org/show_bug.cgi?id=71279

Reviewed by Simon Hausmann.

Create a builtin bundle for Qt port: an InjectedBundle which the code is together
with the Qt's web process instead of being in a different library. This gives us
access to many hooks at web process (using WKBundle* functions of C API) without
adding any maintenance burden to cross-port code.

Since we also use a InjectedBundle in the WebKitTestRunner, we only install our
builtin bundle if there's no other installed. This is fine because WTR won't use
the extra runtime features that we plan to provide with the builtin bundle.

* WebKit2.pro:
* WebProcess/qt/QtBuiltinBundle.cpp: Added.
(WebKit::QtBuiltinBundle::~QtBuiltinBundle):
(WebKit::QtBuiltinBundle::shared):
(WebKit::QtBuiltinBundle::initialize):
(WebKit::QtBuiltinBundle::didCreatePage):
(WebKit::QtBuiltinBundle::willDestroyPage):
(WebKit::QtBuiltinBundle::bundlePageForPageRef):
* WebProcess/qt/QtBuiltinBundle.h: Added.
(WebKit::QtBuiltinBundle::toRef):
Object that holds a WKBundleRef and keeps track of the pages in the current context.

* WebProcess/qt/QtBuiltinBundlePage.cpp: Added.
(WebKit::QtBuiltinBundlePage::QtBuiltinBundlePage):
(WebKit::QtBuiltinBundlePage::~QtBuiltinBundlePage):
* WebProcess/qt/QtBuiltinBundlePage.h: Added.
(WebKit::QtBuiltinBundlePage::page):
Our representation for pages from the bundle perspective. This will be the right
place to registering page related clients.

* WebProcess/qt/WebProcessQt.cpp:
(WebKit::WebProcess::platformInitializeWebProcess):
If there's no bundle to be loaded, initialize Qt builtin bundle, which will register the
bundle client for this context.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (98956 => 98957)


--- trunk/Source/WebKit2/ChangeLog	2011-11-01 13:32:40 UTC (rev 98956)
+++ trunk/Source/WebKit2/ChangeLog	2011-11-01 13:34:34 UTC (rev 98957)
@@ -1,3 +1,44 @@
+2011-11-01  Caio Marcelo de Oliveira Filho  <caio.olive...@openbossa.org>
+
+        [Qt] Create infrastructure for Qt's builtin bundle in web process.
+        https://bugs.webkit.org/show_bug.cgi?id=71279
+
+        Reviewed by Simon Hausmann.
+
+        Create a builtin bundle for Qt port: an InjectedBundle which the code is together
+        with the Qt's web process instead of being in a different library. This gives us
+        access to many hooks at web process (using WKBundle* functions of C API) without
+        adding any maintenance burden to cross-port code.
+
+        Since we also use a InjectedBundle in the WebKitTestRunner, we only install our
+        builtin bundle if there's no other installed. This is fine because WTR won't use
+        the extra runtime features that we plan to provide with the builtin bundle.
+
+        * WebKit2.pro:
+        * WebProcess/qt/QtBuiltinBundle.cpp: Added.
+        (WebKit::QtBuiltinBundle::~QtBuiltinBundle):
+        (WebKit::QtBuiltinBundle::shared):
+        (WebKit::QtBuiltinBundle::initialize):
+        (WebKit::QtBuiltinBundle::didCreatePage):
+        (WebKit::QtBuiltinBundle::willDestroyPage):
+        (WebKit::QtBuiltinBundle::bundlePageForPageRef):
+        * WebProcess/qt/QtBuiltinBundle.h: Added.
+        (WebKit::QtBuiltinBundle::toRef):
+        Object that holds a WKBundleRef and keeps track of the pages in the current context.
+
+        * WebProcess/qt/QtBuiltinBundlePage.cpp: Added.
+        (WebKit::QtBuiltinBundlePage::QtBuiltinBundlePage):
+        (WebKit::QtBuiltinBundlePage::~QtBuiltinBundlePage):
+        * WebProcess/qt/QtBuiltinBundlePage.h: Added.
+        (WebKit::QtBuiltinBundlePage::page):
+        Our representation for pages from the bundle perspective. This will be the right
+        place to registering page related clients.
+
+        * WebProcess/qt/WebProcessQt.cpp:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        If there's no bundle to be loaded, initialize Qt builtin bundle, which will register the
+        bundle client for this context.
+
 2011-11-01  Simon Hausmann  <simon.hausm...@nokia.com>
 
         [WK2] Add WebGestureEvents to the Qt build and enable PlatformGestureEvent::TapType

Modified: trunk/Source/WebKit2/WebKit2.pro (98956 => 98957)


--- trunk/Source/WebKit2/WebKit2.pro	2011-11-01 13:32:40 UTC (rev 98956)
+++ trunk/Source/WebKit2/WebKit2.pro	2011-11-01 13:34:34 UTC (rev 98957)
@@ -340,6 +340,8 @@
     WebProcess/WebPage/WebPage.h \
     WebProcess/WebPage/WebPageGroupProxy.h \
     WebProcess/WebProcess.h \
+    WebProcess/qt/QtBuiltinBundle.h \
+    WebProcess/qt/QtBuiltinBundlePage.h \
     $$WEBKIT2_GENERATED_HEADERS \
     $$WEBKIT1_HEADERS_SHARED_WITH_WEBKIT2
 
@@ -607,6 +609,8 @@
     WebProcess/WebPage/qt/LayerTreeHostQt.cpp \
     WebProcess/WebPage/qt/WebPageQt.cpp \
     WebProcess/WebProcess.cpp \
+    WebProcess/qt/QtBuiltinBundle.cpp \
+    WebProcess/qt/QtBuiltinBundlePage.cpp \
     WebProcess/qt/WebProcessMainQt.cpp \
     WebProcess/qt/WebProcessQt.cpp \
     $$WEBKIT2_GENERATED_SOURCES \

Added: trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp (0 => 98957)


--- trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.cpp	2011-11-01 13:34:34 UTC (rev 98957)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 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 "config.h"
+#include "QtBuiltinBundle.h"
+
+#include "QtBuiltinBundlePage.h"
+#include "WKBundlePage.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+QtBuiltinBundle::~QtBuiltinBundle()
+{
+    // For OwnPtr's sake.
+}
+
+QtBuiltinBundle& QtBuiltinBundle::shared()
+{
+    static QtBuiltinBundle& shared = *new QtBuiltinBundle;
+    return shared;
+}
+
+void QtBuiltinBundle::initialize(WKBundleRef bundle)
+{
+    m_bundle = bundle;
+    WKBundleClient client = {
+        kWKBundleClientCurrentVersion,
+        this,
+        didCreatePage,
+        willDestroyPage,
+        0, // didInitializePageGroup
+        0, // didReceiveMessage
+    };
+    WKBundleSetClient(m_bundle, &client);
+}
+
+void QtBuiltinBundle::didCreatePage(WKBundleRef, WKBundlePageRef page, const void* clientInfo)
+{
+    static_cast<QtBuiltinBundle*>(const_cast<void*>(clientInfo))->didCreatePage(page);
+}
+
+void QtBuiltinBundle::willDestroyPage(WKBundleRef, WKBundlePageRef page, const void* clientInfo)
+{
+    static_cast<QtBuiltinBundle*>(const_cast<void*>(clientInfo))->willDestroyPage(page);
+}
+
+void QtBuiltinBundle::didCreatePage(WKBundlePageRef page)
+{
+    m_pages.append(adoptPtr(new QtBuiltinBundlePage(this, page)));
+}
+
+void QtBuiltinBundle::willDestroyPage(WKBundlePageRef page)
+{
+    for (size_t i = 0; i < m_pages.size(); ++i) {
+        if (m_pages[i]->page() == page) {
+            m_pages.remove(i);
+            break;
+        }
+    }
+}
+
+QtBuiltinBundlePage* QtBuiltinBundle::bundlePageForPageRef(const WKBundlePageRef page) const
+{
+    for (size_t i = 0; i < m_pages.size(); ++i) {
+        if (m_pages[i]->page() == page)
+            return m_pages[i].get();
+    }
+    return 0;
+}
+
+} // namespace WebKit

Added: trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.h (0 => 98957)


--- trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundle.h	2011-11-01 13:34:34 UTC (rev 98957)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef QtBuiltinBundle_h
+#define QtBuiltinBundle_h
+
+#include "WKBundle.h"
+#include "WKBundlePage.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebKit {
+
+class QtBuiltinBundlePage;
+
+class QtBuiltinBundle {
+public:
+    ~QtBuiltinBundle();
+
+    static QtBuiltinBundle& shared();
+    void initialize(WKBundleRef);
+
+    WKBundleRef toRef() const { return m_bundle; }
+
+    // Bundle Client.
+    static void didCreatePage(WKBundleRef, WKBundlePageRef, const void*);
+    static void willDestroyPage(WKBundleRef, WKBundlePageRef, const void*);
+
+    void didCreatePage(WKBundlePageRef);
+    void willDestroyPage(WKBundlePageRef);
+
+private:
+    QtBuiltinBundlePage* bundlePageForPageRef(const WKBundlePageRef) const;
+
+    // FIXME: Can we use HashMap of OwnPtrs? Or something equivalent?
+    Vector<OwnPtr<QtBuiltinBundlePage> > m_pages;
+    WKBundleRef m_bundle;
+};
+
+} // namespace WebKit
+
+#endif // QtBuiltinBundle_h

Added: trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp (0 => 98957)


--- trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.cpp	2011-11-01 13:34:34 UTC (rev 98957)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 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 "config.h"
+#include "QtBuiltinBundlePage.h"
+
+namespace WebKit {
+
+QtBuiltinBundlePage::QtBuiltinBundlePage(QtBuiltinBundle* bundle, WKBundlePageRef page)
+    : m_bundle(bundle)
+    , m_page(page)
+{
+    // Here we can set the bundle's page clients.
+}
+
+QtBuiltinBundlePage::~QtBuiltinBundlePage()
+{
+
+}
+
+} // namespace WebKit

Added: trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.h (0 => 98957)


--- trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/qt/QtBuiltinBundlePage.h	2011-11-01 13:34:34 UTC (rev 98957)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef QtBuiltinBundlePage_h
+#define QtBuiltinBundlePage_h
+
+#include "WKBundlePage.h"
+
+namespace WebKit {
+
+class QtBuiltinBundle;
+
+class QtBuiltinBundlePage {
+public:
+    QtBuiltinBundlePage(QtBuiltinBundle*, WKBundlePageRef);
+    ~QtBuiltinBundlePage();
+
+    WKBundlePageRef page() const { return m_page; }
+
+private:
+    QtBuiltinBundle* m_bundle;
+    WKBundlePageRef m_page;
+};
+
+} // namespace WebKit
+
+#endif // QtBuiltinBundlePage_h

Modified: trunk/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp (98956 => 98957)


--- trunk/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp	2011-11-01 13:32:40 UTC (rev 98956)
+++ trunk/Source/WebKit2/WebProcess/qt/WebProcessQt.cpp	2011-11-01 13:34:34 UTC (rev 98957)
@@ -26,6 +26,9 @@
 #include "config.h"
 #include "WebProcess.h"
 
+#include "InjectedBundle.h"
+#include "QtBuiltinBundle.h"
+#include "WKBundleAPICast.h"
 #include "WebProcessCreationParameters.h"
 
 #include <QCoreApplication>
@@ -83,6 +86,14 @@
 #if ENABLE(SPEECH_INPUT)
     WebCore::RuntimeEnabledFeatures::setSpeechInputEnabled(false);
 #endif
+
+    // We'll only install the Qt builtin bundle if we don't have one given by the UI process.
+    // Currently only WTR provides its own bundle.
+    if (parameters.injectedBundlePath.isEmpty()) {
+        m_injectedBundle = InjectedBundle::create(String());
+        m_injectedBundle->setSandboxExtension(SandboxExtension::create(parameters.injectedBundlePathExtensionHandle));
+        QtBuiltinBundle::shared().initialize(toAPI(m_injectedBundle.get()));
+    }
 }
 
 void WebProcess::platformTerminate()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to