Title: [187543] trunk
Revision
187543
Author
[email protected]
Date
2015-07-28 23:50:50 -0700 (Tue, 28 Jul 2015)

Log Message

[GTK] Add API to set the maximum number of web processes per WebKitWebContext
https://bugs.webkit.org/show_bug.cgi?id=147108

Reviewed by Gustavo Noronha Silva.

Source/WebKit2:

* UIProcess/API/gtk/WebKitWebContext.cpp:
(webkit_web_context_set_web_process_count_limit):
(webkit_web_context_get_web_process_count_limit):
* UIProcess/API/gtk/WebKitWebContext.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:

Tools:

Add test case to check the web process limit.

* TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp:
(testWebProcessLimit):
(beforeAll):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (187542 => 187543)


--- trunk/Source/WebKit2/ChangeLog	2015-07-29 06:48:23 UTC (rev 187542)
+++ trunk/Source/WebKit2/ChangeLog	2015-07-29 06:50:50 UTC (rev 187543)
@@ -1,5 +1,18 @@
 2015-07-28  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Add API to set the maximum number of web processes per WebKitWebContext
+        https://bugs.webkit.org/show_bug.cgi?id=147108
+
+        Reviewed by Gustavo Noronha Silva.
+
+        * UIProcess/API/gtk/WebKitWebContext.cpp:
+        (webkit_web_context_set_web_process_count_limit):
+        (webkit_web_context_get_web_process_count_limit):
+        * UIProcess/API/gtk/WebKitWebContext.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
+
+2015-07-28  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Fix empty space in popup menus when first item is selected
         https://bugs.webkit.org/show_bug.cgi?id=147358
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (187542 => 187543)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2015-07-29 06:48:23 UTC (rev 187542)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2015-07-29 06:50:50 UTC (rev 187543)
@@ -1158,7 +1158,7 @@
  * the rest of the WebViews in the application will still function
  * normally.
  *
- * This method **must be called before any other functions**,
+ * This method **must be called before any web process has been created**,
  * as early as possible in your application. Calling it later will make
  * your application crash.
  *
@@ -1195,6 +1195,47 @@
     return toWebKitProcessModel(context->priv->context->processModel());
 }
 
+/**
+ * webkit_web_context_set_web_process_count_limit:
+ * @context: the #WebKitWebContext
+ * @limit: the maximum number of web processes
+ *
+ * Sets the maximum number of web processes that can be created at the same time for the @context.
+ * The default value is 0 and means no limit.
+ *
+ * This method **must be called before any web process has been created**,
+ * as early as possible in your application. Calling it later will make
+ * your application crash.
+ *
+ * Since: 2.10
+ */
+void webkit_web_context_set_web_process_count_limit(WebKitWebContext* context, guint limit)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+
+    if (limit == context->priv->context->configuration().maximumProcessCount())
+        return;
+
+    context->priv->context->setMaximumNumberOfProcesses(limit);
+}
+
+/**
+ * webkit_web_context_get_web_process_count_limit:
+ * @context: the #WebKitWebContext
+ *
+ * Gets the maximum number of web processes that can be created at the same time for the @context.
+ *
+ * Returns: the maximum limit of web processes, or 0 if there isn't a limit.
+ *
+ * Since: 2.10
+ */
+guint webkit_web_context_get_web_process_count_limit(WebKitWebContext* context)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
+
+    return context->priv->context->configuration().maximumProcessCount();
+}
+
 WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy)
 {
     GRefPtr<WebKitDownload> download = downloadsMap().get(downloadProxy);

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h (187542 => 187543)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h	2015-07-29 06:48:23 UTC (rev 187542)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h	2015-07-29 06:50:50 UTC (rev 187543)
@@ -162,6 +162,13 @@
 webkit_web_context_get_cache_model                  (WebKitWebContext              *context);
 
 WEBKIT_API void
+webkit_web_context_set_web_process_count_limit      (WebKitWebContext              *context,
+                                                     guint                          limit);
+
+WEBKIT_API guint
+webkit_web_context_get_web_process_count_limit      (WebKitWebContext              *context);
+
+WEBKIT_API void
 webkit_web_context_clear_cache                      (WebKitWebContext              *context);
 
 WEBKIT_API WebKitDownload *

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (187542 => 187543)


--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt	2015-07-29 06:48:23 UTC (rev 187542)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt	2015-07-29 06:50:50 UTC (rev 187543)
@@ -33,6 +33,8 @@
 webkit_web_context_get_website_data_manager
 webkit_web_context_get_cache_model
 webkit_web_context_set_cache_model
+webkit_web_context_get_web_process_count_limit
+webkit_web_context_set_web_process_count_limit
 webkit_web_context_clear_cache
 webkit_web_context_download_uri
 webkit_web_context_get_cookie_manager

Modified: trunk/Tools/ChangeLog (187542 => 187543)


--- trunk/Tools/ChangeLog	2015-07-29 06:48:23 UTC (rev 187542)
+++ trunk/Tools/ChangeLog	2015-07-29 06:50:50 UTC (rev 187543)
@@ -1,3 +1,16 @@
+2015-07-28  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Add API to set the maximum number of web processes per WebKitWebContext
+        https://bugs.webkit.org/show_bug.cgi?id=147108
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Add test case to check the web process limit.
+
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp:
+        (testWebProcessLimit):
+        (beforeAll):
+
 2015-07-28  Michael Catanzaro  <[email protected]>
 
         [GTK] Missing casts in BrowserWindow.c

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp (187542 => 187543)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp	2015-07-29 06:48:23 UTC (rev 187542)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp	2015-07-29 06:50:50 UTC (rev 187543)
@@ -240,6 +240,22 @@
     g_assert_cmpuint(test->m_initializeWebExtensionsSignalCount, ==, 1);
 }
 
+static void testWebProcessLimit(MultiprocessTest* test, gconstpointer)
+{
+    g_assert_cmpuint(webkit_web_context_get_web_process_count_limit(test->m_webContext.get()), ==, 0);
+
+    webkit_web_context_set_web_process_count_limit(test->m_webContext.get(), 1);
+    g_assert_cmpuint(webkit_web_context_get_web_process_count_limit(test->m_webContext.get()), ==, 1);
+
+    // Create two web views but there should be only one web process.
+    for (unsigned i = 0; i < numViews; i++) {
+        test->loadWebViewAndWaitUntilLoaded(i);
+        g_assert(WEBKIT_IS_WEB_VIEW(test->m_webViews[i].get()));
+    }
+
+    g_assert_cmpuint(test->m_initializeWebExtensionsSignalCount, ==, 1);
+}
+
 void beforeAll()
 {
     // Check that default setting is the one stated in the documentation
@@ -259,6 +275,7 @@
 
     MultiprocessTest::add("WebKitWebContext", "process-per-web-view", testProcessPerWebView);
     UIClientMultiprocessTest::add("WebKitWebView", "multiprocess-create-ready-close", testMultiprocessWebViewCreateReadyClose);
+    MultiprocessTest::add("WebKitWebContext", "web-process-limit", testWebProcessLimit);
 }
 
 void afterAll()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to