⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 187543 in webkit


Ignore:
Timestamp:
Jul 28, 2015, 11:50:50 PM (11 years ago)
Author:
Carlos Garcia Campos
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):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r187542 r187543  
     12015-07-28  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add API to set the maximum number of web processes per WebKitWebContext
     4        https://bugs.webkit.org/show_bug.cgi?id=147108
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        * UIProcess/API/gtk/WebKitWebContext.cpp:
     9        (webkit_web_context_set_web_process_count_limit):
     10        (webkit_web_context_get_web_process_count_limit):
     11        * UIProcess/API/gtk/WebKitWebContext.h:
     12        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
     13
    1142015-07-28  Carlos Garcia Campos  <cgarcia@igalia.com>
    215
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp

    r186861 r187543  
    11591159 * normally.
    11601160 *
    1161  * This method **must be called before any other functions**,
     1161 * This method **must be called before any web process has been created**,
    11621162 * as early as possible in your application. Calling it later will make
    11631163 * your application crash.
     
    11941194
    11951195    return toWebKitProcessModel(context->priv->context->processModel());
     1196}
     1197
     1198/**
     1199 * webkit_web_context_set_web_process_count_limit:
     1200 * @context: the #WebKitWebContext
     1201 * @limit: the maximum number of web processes
     1202 *
     1203 * Sets the maximum number of web processes that can be created at the same time for the @context.
     1204 * The default value is 0 and means no limit.
     1205 *
     1206 * This method **must be called before any web process has been created**,
     1207 * as early as possible in your application. Calling it later will make
     1208 * your application crash.
     1209 *
     1210 * Since: 2.10
     1211 */
     1212void webkit_web_context_set_web_process_count_limit(WebKitWebContext* context, guint limit)
     1213{
     1214    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
     1215
     1216    if (limit == context->priv->context->configuration().maximumProcessCount())
     1217        return;
     1218
     1219    context->priv->context->setMaximumNumberOfProcesses(limit);
     1220}
     1221
     1222/**
     1223 * webkit_web_context_get_web_process_count_limit:
     1224 * @context: the #WebKitWebContext
     1225 *
     1226 * Gets the maximum number of web processes that can be created at the same time for the @context.
     1227 *
     1228 * Returns: the maximum limit of web processes, or 0 if there isn't a limit.
     1229 *
     1230 * Since: 2.10
     1231 */
     1232guint webkit_web_context_get_web_process_count_limit(WebKitWebContext* context)
     1233{
     1234    g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
     1235
     1236    return context->priv->context->configuration().maximumProcessCount();
    11961237}
    11971238
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h

    r185950 r187543  
    163163
    164164WEBKIT_API void
     165webkit_web_context_set_web_process_count_limit      (WebKitWebContext              *context,
     166                                                     guint                          limit);
     167
     168WEBKIT_API guint
     169webkit_web_context_get_web_process_count_limit      (WebKitWebContext              *context);
     170
     171WEBKIT_API void
    165172webkit_web_context_clear_cache                      (WebKitWebContext              *context);
    166173
  • trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt

    r187220 r187543  
    3434webkit_web_context_get_cache_model
    3535webkit_web_context_set_cache_model
     36webkit_web_context_get_web_process_count_limit
     37webkit_web_context_set_web_process_count_limit
    3638webkit_web_context_clear_cache
    3739webkit_web_context_download_uri
  • trunk/Tools/ChangeLog

    r187541 r187543  
     12015-07-28  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Add API to set the maximum number of web processes per WebKitWebContext
     4        https://bugs.webkit.org/show_bug.cgi?id=147108
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        Add test case to check the web process limit.
     9
     10        * TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp:
     11        (testWebProcessLimit):
     12        (beforeAll):
     13
    1142015-07-28  Michael Catanzaro  <mcatanzaro@igalia.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp

    r176256 r187543  
    241241}
    242242
     243static void testWebProcessLimit(MultiprocessTest* test, gconstpointer)
     244{
     245    g_assert_cmpuint(webkit_web_context_get_web_process_count_limit(test->m_webContext.get()), ==, 0);
     246
     247    webkit_web_context_set_web_process_count_limit(test->m_webContext.get(), 1);
     248    g_assert_cmpuint(webkit_web_context_get_web_process_count_limit(test->m_webContext.get()), ==, 1);
     249
     250    // Create two web views but there should be only one web process.
     251    for (unsigned i = 0; i < numViews; i++) {
     252        test->loadWebViewAndWaitUntilLoaded(i);
     253        g_assert(WEBKIT_IS_WEB_VIEW(test->m_webViews[i].get()));
     254    }
     255
     256    g_assert_cmpuint(test->m_initializeWebExtensionsSignalCount, ==, 1);
     257}
     258
    243259void beforeAll()
    244260{
     
    260276    MultiprocessTest::add("WebKitWebContext", "process-per-web-view", testProcessPerWebView);
    261277    UIClientMultiprocessTest::add("WebKitWebView", "multiprocess-create-ready-close", testMultiprocessWebViewCreateReadyClose);
     278    MultiprocessTest::add("WebKitWebContext", "web-process-limit", testWebProcessLimit);
    262279}
    263280
Note: See TracChangeset for help on using the changeset viewer.