Title: [138226] trunk
Revision
138226
Author
commit-qu...@webkit.org
Date
2012-12-19 21:57:47 -0800 (Wed, 19 Dec 2012)

Log Message

Adopt new assertion SPI for process suppression on Mac
https://bugs.webkit.org/show_bug.cgi?id=105378

Patch by Kiran Muppala <cmupp...@apple.com> on 2012-12-19
Reviewed by Mark Rowe.

Source/WebKit2:

Process suppression for WebKit2 child processes is currently enabled or disabled using AutomaticTermination.
This should be replaced with a new assertion SPI specific to process suppression.

* Shared/ChildProcess.cpp:
(WebKit::ChildProcess::ChildProcess): Remove unused member variable m_applicationIsOccluded.
* Shared/ChildProcess.h:
(WebKit::ChildProcess::applicationIsOccluded): Infer occlusion state from m_processVisibleAssertion.
* Shared/mac/ChildProcessMac.mm:
(WebKit::ChildProcess::setApplicationIsOccluded): Use applicationIsOccluded() accessor to check if the
occlusion state has changed and take or release a process visible assertion accordingly.
(WebKit::ChildProcess::platformInitialize): Remove call to initializeTimerCoalescingPolicy(), since taking
a process visible assertion also sets the timer coalescing policy appropriately.  Set the occlusion
state to false on initialization.

WebKitLibraries:

Add WKNSProcessInfoProcessAssertionWithTypes().

* WebKitSystemInterface.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (138225 => 138226)


--- trunk/Source/WebKit2/ChangeLog	2012-12-20 05:52:36 UTC (rev 138225)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-20 05:57:47 UTC (rev 138226)
@@ -1,3 +1,24 @@
+2012-12-19  Kiran Muppala  <cmupp...@apple.com>
+
+        Adopt new assertion SPI for process suppression on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=105378
+
+        Reviewed by Mark Rowe.
+
+        Process suppression for WebKit2 child processes is currently enabled or disabled using AutomaticTermination.
+        This should be replaced with a new assertion SPI specific to process suppression.
+
+        * Shared/ChildProcess.cpp:
+        (WebKit::ChildProcess::ChildProcess): Remove unused member variable m_applicationIsOccluded.
+        * Shared/ChildProcess.h:
+        (WebKit::ChildProcess::applicationIsOccluded): Infer occlusion state from m_processVisibleAssertion.
+        * Shared/mac/ChildProcessMac.mm:
+        (WebKit::ChildProcess::setApplicationIsOccluded): Use applicationIsOccluded() accessor to check if the
+        occlusion state has changed and take or release a process visible assertion accordingly.
+        (WebKit::ChildProcess::platformInitialize): Remove call to initializeTimerCoalescingPolicy(), since taking
+        a process visible assertion also sets the timer coalescing policy appropriately.  Set the occlusion
+        state to false on initialization.
+
 2012-12-19  Alexey Proskuryakov  <a...@apple.com>
 
         <rdar://problem/12890242> [WK2 NetworkProcess] Client doesn't receive SSL certificates

Modified: trunk/Source/WebKit2/Shared/ChildProcess.cpp (138225 => 138226)


--- trunk/Source/WebKit2/Shared/ChildProcess.cpp	2012-12-20 05:52:36 UTC (rev 138225)
+++ trunk/Source/WebKit2/Shared/ChildProcess.cpp	2012-12-20 05:57:47 UTC (rev 138226)
@@ -60,9 +60,6 @@
     : m_terminationTimeout(0)
     , m_terminationCounter(0)
     , m_terminationTimer(RunLoop::main(), this, &ChildProcess::terminationTimerFired)
-#if PLATFORM(MAC)
-    , m_applicationIsOccluded(false)
-#endif
 {
     // FIXME: The termination timer should not be scheduled on the main run loop.
     // It won't work with the threaded mode, but it's not really useful anyway as is.

Modified: trunk/Source/WebKit2/Shared/ChildProcess.h (138225 => 138226)


--- trunk/Source/WebKit2/Shared/ChildProcess.h	2012-12-20 05:52:36 UTC (rev 138225)
+++ trunk/Source/WebKit2/Shared/ChildProcess.h	2012-12-20 05:57:47 UTC (rev 138226)
@@ -28,6 +28,7 @@
 
 #include "Connection.h"
 #include <WebCore/RunLoop.h>
+#include <wtf/RetainPtr.h>
 
 #if PLATFORM(MAC)
 OBJC_CLASS NSString;
@@ -62,7 +63,7 @@
     };
 
 #if PLATFORM(MAC)
-    bool applicationIsOccluded() const { return m_applicationIsOccluded; }
+    bool applicationIsOccluded() const { return !m_processVisibleAssertion; }
     void setApplicationIsOccluded(bool);
 #endif
 
@@ -80,13 +81,6 @@
     virtual bool shouldTerminate() = 0;
     virtual void terminate();
 
-#if PLATFORM(MAC)
-    void disableProcessSuppression(NSString *reason);
-    void enableProcessSuppression(NSString *reason);
-
-    static NSString * const processSuppressionVisibleApplicationReason;
-#endif
-
     void platformInitialize();
 
     // The timeout, in seconds, before this process will be terminated if termination
@@ -100,7 +94,7 @@
     WebCore::RunLoop::Timer<ChildProcess> m_terminationTimer;
 
 #if PLATFORM(MAC)
-    bool m_applicationIsOccluded;
+    RetainPtr<id> m_processVisibleAssertion;
 #endif
 };
 

Modified: trunk/Source/WebKit2/Shared/mac/ChildProcessMac.mm (138225 => 138226)


--- trunk/Source/WebKit2/Shared/mac/ChildProcessMac.mm	2012-12-20 05:52:36 UTC (rev 138225)
+++ trunk/Source/WebKit2/Shared/mac/ChildProcessMac.mm	2012-12-20 05:57:47 UTC (rev 138226)
@@ -26,61 +26,30 @@
 #import "config.h"
 #import "ChildProcess.h"
 
+#import "WebKitSystemInterface.h"
 #import <mach/task.h>
 
 namespace WebKit {
 
-NSString * const ChildProcess::processSuppressionVisibleApplicationReason = @"Application is Visible";
-
 void ChildProcess::setApplicationIsOccluded(bool applicationIsOccluded)
 {
-    if (m_applicationIsOccluded == applicationIsOccluded)
+    if (this->applicationIsOccluded() == applicationIsOccluded)
         return;
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-    m_applicationIsOccluded = applicationIsOccluded;
-    if (m_applicationIsOccluded)
-        enableProcessSuppression(processSuppressionVisibleApplicationReason);
+    if (applicationIsOccluded)
+        m_processVisibleAssertion.clear();
     else
-        disableProcessSuppression(processSuppressionVisibleApplicationReason);
+        m_processVisibleAssertion = WKNSProcessInfoProcessAssertionWithTypes(WKProcessAssertionTypeVisible);
 #endif
 }
 
-void ChildProcess::disableProcessSuppression(NSString *reason)
-{
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-    // The following assumes that a process enabling AutomaticTerminationSupport also
-    // takes a AutomaticTermination assertion for the lifetime of the process.
-    [[NSProcessInfo processInfo] disableAutomaticTermination:reason];
-#endif
-}
-
-void ChildProcess::enableProcessSuppression(NSString *reason)
-{
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-    // The following assumes that a process enabling AutomaticTerminationSupport also
-    // takes a AutomaticTermination assertion for the lifetime of the process.
-    [[NSProcessInfo processInfo] enableAutomaticTermination:reason];
-#endif
-}
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-static void initializeTimerCoalescingPolicy()
-{
-    // Set task_latency and task_throughput QOS tiers as appropriate for a visible application.
-    struct task_qos_policy qosinfo = { LATENCY_QOS_TIER_0, THROUGHPUT_QOS_TIER_0 };
-    kern_return_t kr = task_policy_set(mach_task_self(), TASK_BASE_QOS_POLICY, (task_policy_t)&qosinfo, TASK_QOS_POLICY_COUNT);
-    ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
-}
-#endif
-
 void ChildProcess::platformInitialize()
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     setpriority(PRIO_DARWIN_PROCESS, 0, 0);
-    initializeTimerCoalescingPolicy();
 #endif
-    disableProcessSuppression(processSuppressionVisibleApplicationReason);
+    setApplicationIsOccluded(false);
 }
 
 }

Modified: trunk/WebKitLibraries/ChangeLog (138225 => 138226)


--- trunk/WebKitLibraries/ChangeLog	2012-12-20 05:52:36 UTC (rev 138225)
+++ trunk/WebKitLibraries/ChangeLog	2012-12-20 05:57:47 UTC (rev 138226)
@@ -1,3 +1,14 @@
+2012-12-19  Kiran Muppala  <cmupp...@apple.com>
+
+        Adopt new assertion SPI for process suppression on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=105378
+
+        Reviewed by Mark Rowe.
+
+        Add WKNSProcessInfoProcessAssertionWithTypes().
+
+        * WebKitSystemInterface.h:
+
 2012-12-19  Alexis Menard  <ale...@webkit.org>
 
         Implement CSS parsing for CSS transitions unprefixed.

Modified: trunk/WebKitLibraries/WebKitSystemInterface.h (138225 => 138226)


--- trunk/WebKitLibraries/WebKitSystemInterface.h	2012-12-20 05:52:36 UTC (rev 138225)
+++ trunk/WebKitLibraries/WebKitSystemInterface.h	2012-12-20 05:57:47 UTC (rev 138226)
@@ -530,6 +530,13 @@
 
 bool WKRegisterOcclusionNotificationHandler(WKOcclusionNotificationType, WKOcclusionNotificationHandler);
 bool WKUnregisterOcclusionNotificationHandler(WKOcclusionNotificationType, WKOcclusionNotificationHandler);
+
+enum {
+    WKProcessAssertionTypeVisible = (1UL << 10)
+};
+
+typedef NSUInteger WKProcessAssertionTypes;
+id WKNSProcessInfoProcessAssertionWithTypes(WKProcessAssertionTypes);
 #endif
 
 bool WKIsJavaPlugInActive(void);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to