WebKit2: Need a way to keep the WebProcess alive for testing purposes.
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Apr 2011 17:41:23 +0000 (17:41 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Apr 2011 17:41:23 +0000 (17:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=58592

Reviewed by Sam Weinig.

* UIProcess/API/C/WKContext.cpp:
(WKContextDisableProcessTermination):
(WKContextEnableProcessTermination):
* UIProcess/API/C/WKContextPrivate.h:

* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):
Initialize m_processTerminationEnabled to true.
(WebKit::WebContext::enableProcessTermination):
Set m_processTerminationEnabled to true, and try to terminate the web process.
(WebKit::WebContext::shouldTerminate):
If !m_processTerminationEnabled, return false.
* UIProcess/WebContext.h:
(WebKit::WebContext::disableProcessTermination):
Set m_processTerminationEnabled to false;

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83988 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/WebContext.h

index b39e8fc..00013b9 100644 (file)
@@ -1,3 +1,26 @@
+2011-04-15  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        WebKit2: Need a way to keep the WebProcess alive for testing purposes.
+        https://bugs.webkit.org/show_bug.cgi?id=58592
+
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextDisableProcessTermination):
+        (WKContextEnableProcessTermination):
+        * UIProcess/API/C/WKContextPrivate.h:
+
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::WebContext):
+        Initialize m_processTerminationEnabled to true.
+        (WebKit::WebContext::enableProcessTermination):
+        Set m_processTerminationEnabled to true, and try to terminate the web process.
+        (WebKit::WebContext::shouldTerminate):
+        If !m_processTerminationEnabled, return false.
+        * UIProcess/WebContext.h:
+        (WebKit::WebContext::disableProcessTermination):
+        Set m_processTerminationEnabled to false;
+
 2011-04-15  Nancy Piedra  <nancy.piedra@nokia.com>
 
         Reviewed by Laszlo Gombos.
index a23a582..db138f3 100644 (file)
@@ -217,3 +217,13 @@ void WKContextSetLocalStorageDirectory(WKContextRef contextRef, WKStringRef loca
 {
     toImpl(contextRef)->setLocalStorageDirectory(toImpl(localStorageDirectory)->string());
 }
+
+void WKContextDisableProcessTermination(WKContextRef contextRef)
+{
+    toImpl(contextRef)->disableProcessTermination();
+}
+
+void WKContextEnableProcessTermination(WKContextRef contextRef)
+{
+    toImpl(contextRef)->enableProcessTermination();
+}
index 5fd7dd3..dc91a0f 100644 (file)
@@ -61,6 +61,11 @@ WK_EXPORT void WKContextSetIconDatabasePath(WKContextRef context, WKStringRef ic
 WK_EXPORT void WKContextSetDatabaseDirectory(WKContextRef context, WKStringRef databaseDirectory);
 WK_EXPORT void WKContextSetLocalStorageDirectory(WKContextRef context, WKStringRef localStorageDirectory);
 
+// FIXME: This is a workaround for testing purposes only and should be removed once a better
+// solution has been found for testing.
+WK_EXPORT void WKContextDisableProcessTermination(WKContextRef context);
+WK_EXPORT void WKContextEnableProcessTermination(WKContextRef context);
+
 #ifdef __cplusplus
 }
 #endif
index 3a72787..eecc240 100644 (file)
@@ -126,6 +126,7 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa
     , m_shouldPaintNativeControls(true)
     , m_initialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyAlways)
 #endif
+    , m_processTerminationEnabled(true)
 {
 #ifndef NDEBUG
     WebKit::initializeLogChannelsIfNecessary();
@@ -261,11 +262,21 @@ void WebContext::ensureWebProcess()
     m_pendingMessagesToPostToInjectedBundle.clear();
 }
 
+void WebContext::enableProcessTermination()
+{
+    m_processTerminationEnabled = true;
+    if (shouldTerminate(m_process.get()))
+        m_process->terminate();
+}
+
 bool WebContext::shouldTerminate(WebProcessProxy* process)
 {
     // FIXME: Once we support multiple processes per context, this assertion won't hold.
     ASSERT(process == m_process);
 
+    if (!m_processTerminationEnabled)
+        return false;
+
     if (!m_downloads.isEmpty())
         return false;
 
index f47d34a..303e97d 100644 (file)
@@ -168,6 +168,9 @@ public:
 
     bool shouldTerminate(WebProcessProxy*);
 
+    void disableProcessTermination() { m_processTerminationEnabled = false; }
+    void enableProcessTermination();
+
 private:
     WebContext(ProcessModel, const String& injectedBundlePath);
 
@@ -260,6 +263,8 @@ private:
     String m_overrideDatabaseDirectory;
     String m_overrideIconDatabasePath;
     String m_overrideLocalStorageDirectory;
+
+    bool m_processTerminationEnabled;
 };
 
 template<typename U> inline bool WebContext::sendToAllProcesses(const U& message)