<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[162928] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/162928">162928</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-01-28 02:22:47 -0800 (Tue, 28 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Add API to allow setting the process model in WebKitWebContext
https://bugs.webkit.org/show_bug.cgi?id=125463

Patch by Adrian Perez de Castro &lt;aperez@igalia.com&gt; on 2014-01-28
Reviewed by Carlos Garcia Campos.

Implements accessors in WebKitWebContext for the process model.
The default behavior is unchanged, and a single web process is
used. Using WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW
as the process model will make use one web process for each
WebKitWebView. This also enables the network process. Setting
the process model must be done as early as possible, before the
very first web process is spawned.

Source/WebKit2:

* UIProcess/API/gtk/WebKitWebContext.cpp:
Add accessors in the API to get/set the process model.
(webkit_web_context_set_process_model):
(webkit_web_context_get_process_model):
* UIProcess/API/gtk/WebKitWebContext.h:
Define the WebKitProcessModel enum.
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
Add new public API bits to the documentation.

Tools:

* MiniBrowser/gtk/main.c:
(main):
Enable multiple process mode if the MINIBROWSER_MULTIPROCESS
environment variable is defined and not empty.
* TestWebKitAPI/GNUmakefile.am:
Add new TestMultiprocess test case.
* TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt:
Add new TestMultiprocess test case.
* TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp: Added.
(loadChanged):
(testMultipleSecondaryProcesses):
(initializeWebExtensions):
(beforeAll):
(afterAll):
* TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
(methodCallCallback):
Implement the GetProcessIdentifier D-Bus method.
(makeBusName):
Choose a different bus name when the web extension is used
from TestMultiprocess.
(webkit_web_extension_initialize_with_user_data):
Use makeBusName() to choose the bus name.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebContextcpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebContexth">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtksectionstxt">trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsMiniBrowsergtkmainc">trunk/Tools/MiniBrowser/gtk/main.c</a></li>
<li><a href="#trunkToolsTestWebKitAPIGNUmakefileam">trunk/Tools/TestWebKitAPI/GNUmakefile.am</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkCMakeListstxt">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkWebExtensionTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestMultiprocesscpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (162927 => 162928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Source/WebKit2/ChangeLog        2014-01-28 10:22:47 UTC (rev 162928)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2014-01-28  Adrian Perez de Castro  &lt;aperez@igalia.com&gt;
+
+        [GTK] Add API to allow setting the process model in WebKitWebContext
+        https://bugs.webkit.org/show_bug.cgi?id=125463
+
+        Reviewed by Carlos Garcia Campos.
+
+        Implements accessors in WebKitWebContext for the process model.
+        The default behavior is unchanged, and a single web process is
+        used. Using WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW
+        as the process model will make use one web process for each
+        WebKitWebView. This also enables the network process. Setting
+        the process model must be done as early as possible, before the
+        very first web process is spawned.
+
+        * UIProcess/API/gtk/WebKitWebContext.cpp:
+        Add accessors in the API to get/set the process model.
+        (webkit_web_context_set_process_model):
+        (webkit_web_context_get_process_model):
+        * UIProcess/API/gtk/WebKitWebContext.h:
+        Define the WebKitProcessModel enum.
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
+        Add new public API bits to the documentation.
+
</ins><span class="cx"> 2014-01-27  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Make webkit_uri_scheme_request_get_web_view() work with CustomProtocols
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (162927 => 162928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp        2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp        2014-01-28 10:22:47 UTC (rev 162928)
</span><span class="lines">@@ -64,8 +64,9 @@
</span><span class="cx">  * The #WebKitWebContext manages all aspects common to all
</span><span class="cx">  * #WebKitWebView&lt;!-- --&gt;s.
</span><span class="cx">  *
</span><del>- * You can define the #WebKitCacheModel with
- * webkit_web_context_set_cache_model(), depending on the needs of
</del><ins>+ * You can define the #WebKitCacheModel and #WebKitProcessModel with
+ * webkit_web_context_set_cache_model() and
+ * webkit_web_context_set_process_model(), depending on the needs of
</ins><span class="cx">  * your application. You can access the #WebKitCookieManager or the
</span><span class="cx">  * #WebKitSecurityManager to specify the behaviour of your application
</span><span class="cx">  * regarding cookies and security, using
</span><span class="lines">@@ -161,6 +162,9 @@
</span><span class="cx"> 
</span><span class="cx"> static guint signals[LAST_SIGNAL] = { 0, };
</span><span class="cx"> 
</span><ins>+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS, ProcessModelSharedSecondaryProcess);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW, ProcessModelMultipleSecondaryProcesses);
+
</ins><span class="cx"> WEBKIT_DEFINE_TYPE(WebKitWebContext, webkit_web_context, G_TYPE_OBJECT)
</span><span class="cx"> 
</span><span class="cx"> static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass)
</span><span class="lines">@@ -228,10 +232,6 @@
</span><span class="cx">     priv-&gt;context = WebContext::create(WebCore::filenameToString(injectedBundleFilename().data()));
</span><span class="cx">     priv-&gt;requestManager = webContext-&gt;priv-&gt;context-&gt;supplement&lt;WebSoupCustomProtocolRequestManager&gt;();
</span><span class="cx">     priv-&gt;context-&gt;setCacheModel(CacheModelPrimaryWebBrowser);
</span><del>-#if ENABLE(NETWORK_PROCESS)
-    // FIXME: Temporary use an env var until we have API to set the process model. See https://bugs.webkit.org/show_bug.cgi?id=125463.
-    priv-&gt;context-&gt;setUsesNetworkProcess(g_getenv(&quot;WEBKIT_USE_NETWORK_PROCESS&quot;));
-#endif
</del><span class="cx">     priv-&gt;tlsErrorsPolicy = WEBKIT_TLS_ERRORS_POLICY_IGNORE;
</span><span class="cx"> 
</span><span class="cx">     attachInjectedBundleClientToContext(webContext.get());
</span><span class="lines">@@ -888,6 +888,56 @@
</span><span class="cx">     context-&gt;priv-&gt;context-&gt;allowSpecificHTTPSCertificateForHost(webCertificateInfo.get(), String::fromUTF8(host));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * webkit_web_context_set_process_model:
+ * @context: the #WebKitWebContext
+ * @process_model: a #WebKitProcessModel
+ *
+ * Specifies a process model for WebViews, which WebKit will use to
+ * determine how auxiliary processes are handled. The default setting
+ * (%WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS) is suitable for most
+ * applications which embed a small amount of WebViews, or are used to
+ * display documents which are considered safe -- like local files.
+ *
+ * Applications which may potentially use a large amount of WebViews --for
+ * example a multi-tabbed web browser-- may want to use
+ * %WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW to use one
+ * process per view. Using this model, when a WebView hangs or crashes,
+ * the rest of the WebViews in the application will still work normally.
+ *
+ * This method &lt;strong&gt;must be called before any other functions&lt;/strong&gt;,
+ * as early as possible in your application. Calling it later will make
+ * your application crash.
+ *
+ * Since: 2.4
+ */
+void webkit_web_context_set_process_model(WebKitWebContext* context, WebKitProcessModel processModel)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+
+    if (processModel != context-&gt;priv-&gt;context-&gt;processModel()) {
+        context-&gt;priv-&gt;context-&gt;setUsesNetworkProcess(processModel == ProcessModelMultipleSecondaryProcesses);
+        context-&gt;priv-&gt;context-&gt;setProcessModel(static_cast&lt;ProcessModel&gt;(processModel));
+    }
+}
+
+/**
+ * webkit_web_context_get_process_model:
+ * @context: the #WebKitWebContext
+ *
+ * Returns the current process model. For more information about this value
+ * see webkit_web_context_set_process_model().
+ *
+ * Returns: the current #WebKitProcessModel
+ *
+ * Since: 2.4
+ */
+WebKitProcessModel webkit_web_context_get_process_model(WebKitWebContext* context)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
+    return static_cast&lt;WebKitProcessModel&gt;(context-&gt;priv-&gt;context-&gt;processModel());
+}
+
</ins><span class="cx"> WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy)
</span><span class="cx"> {
</span><span class="cx">     GRefPtr&lt;WebKitDownload&gt; download = downloadsMap().get(downloadProxy);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h (162927 => 162928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h        2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h        2014-01-28 10:22:47 UTC (rev 162928)
</span><span class="lines">@@ -63,6 +63,30 @@
</span><span class="cx"> } WebKitCacheModel;
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * WebKitProcessModel:
+ * @WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS: Use a single process to
+ *   perform content rendering. The process is shared among all the
+ *   #WebKitWebView instances created by the application: if the process
+ *   hangs or crashes all the web views in the application will be affected.
+ *   This is the default process model, and it should suffice for most cases.
+ * @WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW: Use one process
+ *   for each #WebKitWebView. The main advantage of this process model is that
+ *   the rendering process for a web view can crash while the rest of the
+ *   views keep working normally. This process model is indicated for
+ *   applications which may use a number of web views and the content of
+ *   in each must not interfere with the rest -- for example a full-fledged
+ *   web browser with support for multiple tabs.
+ *
+ * Enum values used for determining the #WebKitWebContext process model.
+ *
+ * Since: 2.4
+ */
+typedef enum {
+    WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS,
+    WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW,
+} WebKitProcessModel;
+
+/**
</ins><span class="cx">  * WebKitTLSErrorsPolicy:
</span><span class="cx">  * @WEBKIT_TLS_ERRORS_POLICY_IGNORE: Ignore TLS errors.
</span><span class="cx">  * @WEBKIT_TLS_ERRORS_POLICY_FAIL: TLS errors will emit
</span><span class="lines">@@ -213,6 +237,13 @@
</span><span class="cx">                                                      WebKitCertificateInfo         *info,
</span><span class="cx">                                                      const gchar                   *host);
</span><span class="cx"> 
</span><ins>+WEBKIT_API void
+webkit_web_context_set_process_model                (WebKitWebContext              *context,
+                                                     WebKitProcessModel             process_model);
+
+WEBKIT_API WebKitProcessModel
+webkit_web_context_get_process_model                (WebKitWebContext              *context);
+
</ins><span class="cx"> G_END_DECLS
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtksectionstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (162927 => 162928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt        2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt        2014-01-28 10:22:47 UTC (rev 162928)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> &lt;TITLE&gt;WebKitWebContext&lt;/TITLE&gt;
</span><span class="cx"> WebKitWebContext
</span><span class="cx"> WebKitCacheModel
</span><ins>+WebKitProcessModel
</ins><span class="cx"> WebKitTLSErrorsPolicy
</span><span class="cx"> webkit_web_context_get_default
</span><span class="cx"> webkit_web_context_get_cache_model
</span><span class="lines">@@ -50,6 +51,8 @@
</span><span class="cx"> webkit_web_context_prefetch_dns
</span><span class="cx"> webkit_web_context_set_disk_cache_directory
</span><span class="cx"> webkit_web_context_allow_tls_certificate_for_host
</span><ins>+webkit_web_context_get_process_model
+webkit_web_context_set_process_model
</ins><span class="cx"> 
</span><span class="cx"> &lt;SUBSECTION URI Scheme&gt;
</span><span class="cx"> WebKitURISchemeRequestCallback
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (162927 => 162928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Tools/ChangeLog        2014-01-28 10:22:47 UTC (rev 162928)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2014-01-28  Adrian Perez de Castro  &lt;aperez@igalia.com&gt;
+
+        [GTK] Add API to allow setting the process model in WebKitWebContext
+        https://bugs.webkit.org/show_bug.cgi?id=125463
+
+        Reviewed by Carlos Garcia Campos.
+
+        Implements accessors in WebKitWebContext for the process model.
+        The default behavior is unchanged, and a single web process is
+        used. Using WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW
+        as the process model will make use one web process for each
+        WebKitWebView. This also enables the network process. Setting
+        the process model must be done as early as possible, before the
+        very first web process is spawned.
+
+        * MiniBrowser/gtk/main.c:
+        (main):
+        Enable multiple process mode if the MINIBROWSER_MULTIPROCESS
+        environment variable is defined and not empty.
+        * TestWebKitAPI/GNUmakefile.am:
+        Add new TestMultiprocess test case.
+        * TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt:
+        Add new TestMultiprocess test case.
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp: Added.
+        (loadChanged):
+        (testMultipleSecondaryProcesses):
+        (initializeWebExtensions):
+        (beforeAll):
+        (afterAll):
+        * TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
+        (methodCallCallback):
+        Implement the GetProcessIdentifier D-Bus method.
+        (makeBusName):
+        Choose a different bus name when the web extension is used
+        from TestMultiprocess.
+        (webkit_web_extension_initialize_with_user_data):
+        Use makeBusName() to choose the bus name.
+
</ins><span class="cx"> 2014-01-28  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [SOUP] Remove soupURIToKURL
</span></span></pre></div>
<a id="trunkToolsMiniBrowsergtkmainc"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/gtk/main.c (162927 => 162928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/gtk/main.c        2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Tools/MiniBrowser/gtk/main.c        2014-01-28 10:22:47 UTC (rev 162928)
</span><span class="lines">@@ -241,6 +241,12 @@
</span><span class="cx"> {
</span><span class="cx">     gtk_init(&amp;argc, &amp;argv);
</span><span class="cx"> 
</span><ins>+    const gchar *multiprocess = g_getenv(&quot;MINIBROWSER_MULTIPROCESS&quot;);
+    if (multiprocess &amp;&amp; *multiprocess) {
+        webkit_web_context_set_process_model(webkit_web_context_get_default(),
+            WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW);
+    }
+
</ins><span class="cx">     GOptionContext *context = g_option_context_new(NULL);
</span><span class="cx">     g_option_context_add_main_entries(context, commandLineOptions, 0);
</span><span class="cx">     g_option_context_add_group(context, gtk_get_option_group(TRUE));
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIGNUmakefileam"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/GNUmakefile.am (162927 => 162928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/GNUmakefile.am        2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Tools/TestWebKitAPI/GNUmakefile.am        2014-01-28 10:22:47 UTC (rev 162928)
</span><span class="lines">@@ -161,6 +161,7 @@
</span><span class="cx">         Programs/TestWebKitAPI/WebKit2Gtk/TestInspector \
</span><span class="cx">         Programs/TestWebKitAPI/WebKit2Gtk/TestInspectorServer \
</span><span class="cx">         Programs/TestWebKitAPI/WebKit2Gtk/TestLoaderClient \
</span><ins>+        Programs/TestWebKitAPI/WebKit2Gtk/TestMultiprocess \
</ins><span class="cx">         Programs/TestWebKitAPI/WebKit2Gtk/TestPrinting \
</span><span class="cx">         Programs/TestWebKitAPI/WebKit2Gtk/TestResources \
</span><span class="cx">         Programs/TestWebKitAPI/WebKit2Gtk/TestSSL \
</span><span class="lines">@@ -769,6 +770,12 @@
</span><span class="cx"> Programs_TestWebKitAPI_WebKit2Gtk_TestLoaderClient_LDADD = $(webkit2gtk_tests_ldadd)
</span><span class="cx"> Programs_TestWebKitAPI_WebKit2Gtk_TestLoaderClient_LDFLAGS = $(webkit2gtk_tests_ldflags)
</span><span class="cx"> 
</span><ins>+Programs_TestWebKitAPI_WebKit2Gtk_TestMultiprocess_SOURCES = \
+        Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestMultiprocess_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestMultiprocess_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestMultiprocess_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
</ins><span class="cx"> Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitSettings_SOURCES = \
</span><span class="cx">         Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp
</span><span class="cx"> Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitSettings_CPPFLAGS = $(webkit2gtk_tests_cppflags)
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt (162927 => 162928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt        2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt        2014-01-28 10:22:47 UTC (rev 162928)
</span><span class="lines">@@ -92,6 +92,7 @@
</span><span class="cx"> ADD_WK2_TEST(TestInspector TestInspector.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestInspectorServer TestInspectorServer.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestLoaderClient TestLoaderClient.cpp)
</span><ins>+ADD_WK2_TEST(TestMultiprocess TestMultiprocess.cpp)
</ins><span class="cx"> ADD_WK2_TEST(TestPrinting TestPrinting.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestSSL TestSSL.cpp)
</span><span class="cx"> ADD_WK2_TEST(TestWebExtensions TestWebExtensions.cpp)
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestMultiprocesscpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp (0 => 162928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp        2014-01-28 10:22:47 UTC (rev 162928)
</span><span class="lines">@@ -0,0 +1,143 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include &quot;config.h&quot;
+
+#include &quot;TestMain.h&quot;
+#include &quot;WebKitTestBus.h&quot;
+#include &lt;webkit2/webkit2.h&gt;
+#include &lt;wtf/Vector.h&gt;
+
+static const unsigned numViews = 2;
+static guint32 nextInitializationId = 1;
+static unsigned initializeWebExtensionsSignalCount;
+static WebKitTestBus* bus;
+
+class MultiprocessTest: public Test {
+public:
+    MAKE_GLIB_TEST_FIXTURE(MultiprocessTest);
+
+    MultiprocessTest()
+        : m_mainLoop(g_main_loop_new(nullptr, TRUE))
+        , m_webViewBusNames(numViews)
+        , m_webViews(numViews) { }
+
+    static void loadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent, MultiprocessTest* test)
+    {
+        if (loadEvent != WEBKIT_LOAD_FINISHED)
+            return;
+        g_signal_handlers_disconnect_by_func(webView, reinterpret_cast&lt;void*&gt;(loadChanged), test);
+        g_main_loop_quit(test-&gt;m_mainLoop);
+    }
+
+    void loadWebViewAndWaitUntilLoaded(unsigned index)
+    {
+        g_assert_cmpuint(index, &lt;, numViews);
+
+        m_webViewBusNames[index] = GUniquePtr&lt;char&gt;(g_strdup_printf(&quot;org.webkit.gtk.WebExtensionTest%u&quot;, nextInitializationId));
+
+        m_webViews[index] = WEBKIT_WEB_VIEW(webkit_web_view_new());
+        assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webViews[index].get()));
+
+        webkit_web_view_load_html(m_webViews[index].get(), &quot;&lt;html&gt;&lt;/html&gt;&quot;, nullptr);
+        g_signal_connect(m_webViews[index].get(), &quot;load-changed&quot;, G_CALLBACK(loadChanged), this);
+        g_main_loop_run(m_mainLoop);
+    }
+
+    unsigned webProcessPid(unsigned index)
+    {
+        g_assert_cmpuint(index, &lt;, numViews);
+
+        GRefPtr&lt;GDBusProxy&gt; proxy = adoptGRef(bus-&gt;createProxy(m_webViewBusNames[index].get(),
+            &quot;/org/webkit/gtk/WebExtensionTest&quot;, &quot;org.webkit.gtk.WebExtensionTest&quot;, m_mainLoop));
+
+        GRefPtr&lt;GVariant&gt; result = adoptGRef(g_dbus_proxy_call_sync(
+            proxy.get(),
+            &quot;GetProcessIdentifier&quot;,
+            nullptr,
+            G_DBUS_CALL_FLAGS_NONE,
+            -1, nullptr, nullptr));
+        g_assert(result);
+
+        guint32 identifier = 0;
+        g_variant_get(result.get(), &quot;(u)&quot;, &amp;identifier);
+        return identifier;
+    }
+
+    GMainLoop* m_mainLoop;
+    Vector&lt;GUniquePtr&lt;char&gt;, numViews&gt; m_webViewBusNames;
+    Vector&lt;GRefPtr&lt;WebKitWebView&gt;, numViews&gt; m_webViews;
+};
+
+static void testProcessPerWebView(MultiprocessTest* test, gconstpointer)
+{
+    // Create two web views. As we are in multiprocess mode, there must be
+    // two web processes, running an instance of the web extension each.
+    // The initialize-web-extensions must have been called twice, and the
+    // identifiers generated for them must be different (and their reported
+    // process identifiers).
+
+    for (unsigned i = 0; i &lt; numViews; i++) {
+        test-&gt;loadWebViewAndWaitUntilLoaded(i);
+        g_assert(WEBKIT_IS_WEB_VIEW(test-&gt;m_webViews[i].get()));
+        g_assert(test-&gt;m_webViewBusNames[i]);
+    }
+
+    g_assert_cmpuint(initializeWebExtensionsSignalCount, ==, numViews);
+    g_assert_cmpstr(test-&gt;m_webViewBusNames[0].get(), !=, test-&gt;m_webViewBusNames[1].get());
+    g_assert_cmpuint(test-&gt;webProcessPid(0), !=, test-&gt;webProcessPid(1));
+}
+
+static void initializeWebExtensions(WebKitWebContext* context, gpointer)
+{
+    initializeWebExtensionsSignalCount++;
+    webkit_web_context_set_web_extensions_directory(context, WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+    webkit_web_context_set_web_extensions_initialization_user_data(context,
+        g_variant_new_uint32(nextInitializationId++));
+}
+
+void beforeAll()
+{
+    g_signal_connect(webkit_web_context_get_default(),
+        &quot;initialize-web-extensions&quot;, G_CALLBACK(initializeWebExtensions), nullptr);
+
+    // Check that default setting is the one stated in the documentation
+    g_assert_cmpuint(webkit_web_context_get_process_model(webkit_web_context_get_default()),
+        ==, WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
+
+    webkit_web_context_set_process_model(webkit_web_context_get_default(),
+        WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW);
+
+    // Check that the getter returns the newly-set value
+    g_assert_cmpuint(webkit_web_context_get_process_model(webkit_web_context_get_default()),
+        ==, WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW);
+
+    bus = new WebKitTestBus();
+    if (!bus-&gt;run())
+        return;
+
+    MultiprocessTest::add(&quot;WebKitWebContext&quot;, &quot;process-per-web-view&quot;, testProcessPerWebView);
+}
+
+void afterAll()
+{
+    delete bus;
+    g_signal_handlers_disconnect_by_func(webkit_web_context_get_default(),
+        reinterpret_cast&lt;void*&gt;(initializeWebExtensions), nullptr);
+}
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkWebExtensionTestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp (162927 => 162928)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp        2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp        2014-01-28 10:22:47 UTC (rev 162928)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include &lt;wtf/Deque.h&gt;
</span><span class="cx"> #include &lt;wtf/OwnPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/PassOwnPtr.h&gt;
</span><ins>+#include &lt;wtf/ProcessID.h&gt;
</ins><span class="cx"> #include &lt;wtf/gobject/GOwnPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/gobject/GRefPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/gobject/GUniquePtr.h&gt;
</span><span class="lines">@@ -49,6 +50,9 @@
</span><span class="cx">     &quot;  &lt;method name='GetInitializationUserData'&gt;&quot;
</span><span class="cx">     &quot;   &lt;arg type='s' name='userData' direction='out'/&gt;&quot;
</span><span class="cx">     &quot;  &lt;/method&gt;&quot;
</span><ins>+    &quot;  &lt;method name='GetProcessIdentifier'&gt;&quot;
+    &quot;   &lt;arg type='u' name='identifier' direction='out'/&gt;&quot;
+    &quot;  &lt;/method&gt;&quot;
</ins><span class="cx">     &quot;  &lt;signal name='DocumentLoaded'/&gt;&quot;
</span><span class="cx">     &quot;  &lt;signal name='URIChanged'&gt;&quot;
</span><span class="cx">     &quot;   &lt;arg type='s' name='uri' direction='out'/&gt;&quot;
</span><span class="lines">@@ -224,6 +228,9 @@
</span><span class="cx">         g_assert(g_variant_is_of_type(initializationUserData.get(), G_VARIANT_TYPE_STRING));
</span><span class="cx">         g_dbus_method_invocation_return_value(invocation, g_variant_new(&quot;(s)&quot;,
</span><span class="cx">             g_variant_get_string(initializationUserData.get(), nullptr)));
</span><ins>+    } else if (!g_strcmp0(methodName, &quot;GetProcessIdentifier&quot;)) {
+        g_dbus_method_invocation_return_value(invocation,
+            g_variant_new(&quot;(u)&quot;, static_cast&lt;guint32&gt;(getCurrentProcessID())));
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -263,6 +270,18 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static GUniquePtr&lt;char&gt; makeBusName(GVariant* userData)
+{
+    // When the web extension is used by TestMultiprocess, an uint32
+    // identifier is passed as user data. It uniquely identifies
+    // the web process, and the UI side expects it added as suffix to
+    // the bus name.
+    if (userData &amp;&amp; g_variant_is_of_type(userData, G_VARIANT_TYPE_UINT32))
+        return GUniquePtr&lt;char&gt;(g_strdup_printf(&quot;org.webkit.gtk.WebExtensionTest%u&quot;, g_variant_get_uint32(userData)));
+
+    return GUniquePtr&lt;char&gt;(g_strdup(&quot;org.webkit.gtk.WebExtensionTest&quot;));
+}
+
</ins><span class="cx"> extern &quot;C&quot; void webkit_web_extension_initialize_with_user_data(WebKitWebExtension* extension, GVariant* userData)
</span><span class="cx"> {
</span><span class="cx">     initializationUserData = userData;
</span><span class="lines">@@ -270,9 +289,10 @@
</span><span class="cx">     g_signal_connect(extension, &quot;page-created&quot;, G_CALLBACK(pageCreatedCallback), extension);
</span><span class="cx">     g_signal_connect(webkit_script_world_get_default(), &quot;window-object-cleared&quot;, G_CALLBACK(windowObjectCleared), 0);
</span><span class="cx"> 
</span><ins>+    GUniquePtr&lt;char&gt; busName(makeBusName(userData));
</ins><span class="cx">     g_bus_own_name(
</span><span class="cx">         G_BUS_TYPE_SESSION,
</span><del>-        &quot;org.webkit.gtk.WebExtensionTest&quot;,
</del><ins>+        busName.get(),
</ins><span class="cx">         G_BUS_NAME_OWNER_FLAGS_NONE,
</span><span class="cx">         busAcquiredCallback,
</span><span class="cx">         0, 0,
</span></span></pre>
</div>
</div>

</body>
</html>