Title: [177241] trunk/Source/WebKit2
Revision
177241
Author
[email protected]
Date
2014-12-12 15:12:04 -0800 (Fri, 12 Dec 2014)

Log Message

Keep single RefCounter to track whether any pages in a context are process suppressible
https://bugs.webkit.org/show_bug.cgi?id=139576

Reviewed by Sam Weinig.

Currently we keep separate counters in each process, and coallesce these in the
context. Instead we should have a counter in the WebContext.

Also, changed the name to better describe the state we're tracking, rather than
describing what it's currently used for. This counter will also be useful for
iOS, to better manage background state of the networking process.

* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):
    - initialize m_userObservablePageCounter.
* UIProcess/WebContext.h:
(WebKit::WebContext::updateProcessSuppressionState):
    - Added no-op implementation for non-cocoa platforms.
(WebKit::WebContext::userObservablePageCount):
    - Count the number of user visible (audible / visible) pages in Context.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::updateProccessSuppressionState):
    - WebProcessProxy::processSuppressionCounter -> WebContext::userObservablePageCount
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::WebProcessProxy):
(WebKit::WebProcessProxy::didFinishLaunching):
    - moved all processs supression state tracking to the WebContext.
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::processSuppressionCounter): Deleted.
    - moved all processs supression state tracking to the WebContext.
* UIProcess/ios/WebProcessProxyIOS.mm:
(WebKit::WebProcessProxy::allPagesAreProcessSuppressible): Deleted.
(WebKit::WebProcessProxy::updateProcessSuppressionState): Deleted.
    - moved all processs supression state tracking to the WebContext.
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::processSuppressionEnabled):
    - no need to interate all processes; just have a single counter.
* UIProcess/mac/WebProcessProxyMac.mm:
(WebKit::WebProcessProxy::allPagesAreProcessSuppressible): Deleted.
(WebKit::WebProcessProxy::updateProcessSuppressionState): Deleted.
    - moved all processs supression state tracking to the WebContext.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (177240 => 177241)


--- trunk/Source/WebKit2/ChangeLog	2014-12-12 23:04:19 UTC (rev 177240)
+++ trunk/Source/WebKit2/ChangeLog	2014-12-12 23:12:04 UTC (rev 177241)
@@ -1,3 +1,47 @@
+2014-12-12  Gavin Barraclough  <[email protected]>
+
+        Keep single RefCounter to track whether any pages in a context are process suppressible
+        https://bugs.webkit.org/show_bug.cgi?id=139576
+
+        Reviewed by Sam Weinig.
+
+        Currently we keep separate counters in each process, and coallesce these in the
+        context. Instead we should have a counter in the WebContext.
+
+        Also, changed the name to better describe the state we're tracking, rather than
+        describing what it's currently used for. This counter will also be useful for
+        iOS, to better manage background state of the networking process.
+
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::WebContext):
+            - initialize m_userObservablePageCounter.
+        * UIProcess/WebContext.h:
+        (WebKit::WebContext::updateProcessSuppressionState):
+            - Added no-op implementation for non-cocoa platforms.
+        (WebKit::WebContext::userObservablePageCount):
+            - Count the number of user visible (audible / visible) pages in Context.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::updateProccessSuppressionState):
+            - WebProcessProxy::processSuppressionCounter -> WebContext::userObservablePageCount
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::WebProcessProxy):
+        (WebKit::WebProcessProxy::didFinishLaunching):
+            - moved all processs supression state tracking to the WebContext.
+        * UIProcess/WebProcessProxy.h:
+        (WebKit::WebProcessProxy::processSuppressionCounter): Deleted.
+            - moved all processs supression state tracking to the WebContext.
+        * UIProcess/ios/WebProcessProxyIOS.mm:
+        (WebKit::WebProcessProxy::allPagesAreProcessSuppressible): Deleted.
+        (WebKit::WebProcessProxy::updateProcessSuppressionState): Deleted.
+            - moved all processs supression state tracking to the WebContext.
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit::WebContext::processSuppressionEnabled):
+            - no need to interate all processes; just have a single counter.
+        * UIProcess/mac/WebProcessProxyMac.mm:
+        (WebKit::WebProcessProxy::allPagesAreProcessSuppressible): Deleted.
+        (WebKit::WebProcessProxy::updateProcessSuppressionState): Deleted.
+            - moved all processs supression state tracking to the WebContext.
+
 2014-12-12  Alexey Proskuryakov  <[email protected]>
 
         Layout Test http/tests/loading/307-after-303-after-post.html is flaky

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (177240 => 177241)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2014-12-12 23:04:19 UTC (rev 177240)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2014-12-12 23:12:04 UTC (rev 177241)
@@ -194,6 +194,7 @@
     , m_ignoreTLSErrors(true)
 #endif
     , m_memoryCacheDisabled(false)
+    , m_userObservablePageCounter([this]() { updateProcessSuppressionState(); })
 {
     platformInitialize();
 

Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (177240 => 177241)


--- trunk/Source/WebKit2/UIProcess/WebContext.h	2014-12-12 23:04:19 UTC (rev 177240)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h	2014-12-12 23:12:04 UTC (rev 177241)
@@ -48,6 +48,7 @@
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/PassRefPtr.h>
+#include <wtf/RefCounter.h>
 #include <wtf/RefPtr.h>
 #include <wtf/text/StringHash.h>
 #include <wtf/text/WTFString.h>
@@ -349,10 +350,17 @@
 
     NSMutableDictionary *ensureBundleParameters();
     NSMutableDictionary *bundleParameters() { return m_bundleParameters.get(); }
+#else
+    void updateProcessSuppressionState() const { }
 #endif
 
     void setMemoryCacheDisabled(bool);
 
+    PassRefPtr<RefCounter::Count> userObservablePageCount()
+    {
+        return m_userObservablePageCounter.count();
+    }
+
 private:
     void platformInitialize();
 
@@ -557,6 +565,8 @@
 
     bool m_memoryCacheDisabled;
 
+    RefCounter m_userObservablePageCounter;
+
 #if PLATFORM(COCOA)
     RetainPtr<NSMutableDictionary> m_bundleParameters;
 #endif

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (177240 => 177241)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-12-12 23:04:19 UTC (rev 177240)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-12-12 23:12:04 UTC (rev 177241)
@@ -1282,7 +1282,7 @@
     if ((m_viewState & ViewState::IsVisuallyIdle) && m_preferences->pageVisibilityBasedProcessSuppressionEnabled())
         m_preventProcessSuppression = nullptr;
     else if (!m_preventProcessSuppression)
-        m_preventProcessSuppression = m_process->processSuppressionCounter();
+        m_preventProcessSuppression = m_process->context().userObservablePageCount();
 #endif
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (177240 => 177241)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2014-12-12 23:04:19 UTC (rev 177240)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2014-12-12 23:12:04 UTC (rev 177241)
@@ -93,10 +93,6 @@
     , m_context(context)
     , m_mayHaveUniversalFileReadSandboxExtension(false)
     , m_customProtocolManagerProxy(this, context)
-#if PLATFORM(COCOA)
-    , m_pagesPreventingSuppressionCounter([this]() { updateProcessSuppressionState(); })
-    , m_processSuppressionEnabled(false)
-#endif
     , m_numberOfTimesSuddenTerminationWasDisabled(0)
     , m_throttler(std::make_unique<ProcessThrottler>(this))
 {
@@ -506,10 +502,6 @@
 
     m_context->processDidFinishLaunching(this);
 
-#if PLATFORM(COCOA)
-    updateProcessSuppressionState();
-#endif
-    
 #if PLATFORM(IOS) && USE(XPC_SERVICES)
     xpc_connection_t xpcConnection = connection()->xpcConnection();
     ASSERT(xpcConnection);

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (177240 => 177241)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2014-12-12 23:04:19 UTC (rev 177240)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2014-12-12 23:12:04 UTC (rev 177241)
@@ -43,7 +43,6 @@
 #include <wtf/HashMap.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
-#include <wtf/RefCounter.h>
 
 #if PLATFORM(IOS)
 #include "ProcessThrottler.h"
@@ -119,21 +118,9 @@
 
     DownloadProxy* createDownloadProxy(const WebCore::ResourceRequest&);
 
-#if PLATFORM(COCOA)
-    PassRefPtr<RefCounter::Count> processSuppressionCounter()
-    {
-        return m_pagesPreventingSuppressionCounter.count();
-    }
-#endif
-
     void didSaveToPageCache();
     void releasePageCache();
 
-#if PLATFORM(COCOA)
-    bool allPagesAreProcessSuppressible() const;
-    void updateProcessSuppressionState();
-#endif
-
     void enableSuddenTermination();
     void disableSuddenTermination();
 
@@ -230,11 +217,6 @@
     std::unique_ptr<DownloadProxyMap> m_downloadProxyMap;
     CustomProtocolManagerProxy m_customProtocolManagerProxy;
 
-#if PLATFORM(COCOA)
-    RefCounter m_pagesPreventingSuppressionCounter;
-    bool m_processSuppressionEnabled;
-#endif
-
     int m_numberOfTimesSuddenTerminationWasDisabled;
     std::unique_ptr<ProcessThrottler> m_throttler;
     std::unique_ptr<ProcessThrottler::BackgroundActivityToken> m_tokenForHoldingLockedFiles;

Modified: trunk/Source/WebKit2/UIProcess/ios/WebProcessProxyIOS.mm (177240 => 177241)


--- trunk/Source/WebKit2/UIProcess/ios/WebProcessProxyIOS.mm	2014-12-12 23:04:19 UTC (rev 177240)
+++ trunk/Source/WebKit2/UIProcess/ios/WebProcessProxyIOS.mm	2014-12-12 23:12:04 UTC (rev 177241)
@@ -50,17 +50,6 @@
     launchOptions.useXPC = true;
 }
 
-bool WebProcessProxy::allPagesAreProcessSuppressible() const
-{
-    notImplemented();
-    return false;
-}
-
-void WebProcessProxy::updateProcessSuppressionState()
-{
-    notImplemented();
-}
-
 } // namespace WebKit
 
 #endif // PLATFORM(IOS)

Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm (177240 => 177241)


--- trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2014-12-12 23:04:19 UTC (rev 177240)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2014-12-12 23:12:04 UTC (rev 177241)
@@ -512,11 +512,7 @@
 
 bool WebContext::processSuppressionEnabled() const
 {
-    for (const auto& process : m_processes) {
-        if (!process->allPagesAreProcessSuppressible())
-            return false;
-    }
-    return true;
+    return !m_userObservablePageCounter.value();
 }
 
 bool WebContext::processSuppressionIsEnabledForAllContexts()

Modified: trunk/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm (177240 => 177241)


--- trunk/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm	2014-12-12 23:04:19 UTC (rev 177240)
+++ trunk/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm	2014-12-12 23:12:04 UTC (rev 177241)
@@ -60,24 +60,6 @@
     launchOptions.useXPC = shouldUseXPC();
 }
 
-bool WebProcessProxy::allPagesAreProcessSuppressible() const
-{
-    return !m_pagesPreventingSuppressionCounter.value();
-}
-
-void WebProcessProxy::updateProcessSuppressionState()
-{
-    if (state() != State::Running)
-        return;
-
-    bool canEnable = allPagesAreProcessSuppressible();
-    if (m_processSuppressionEnabled == canEnable)
-        return;
-    m_processSuppressionEnabled = canEnable;
-
-    m_context->updateProcessSuppressionState();
-}
-
 } // namespace WebKit
 
 #endif // PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to