- Revision
- 177291
- Author
- [email protected]
- Date
- 2014-12-15 11:05:11 -0800 (Mon, 15 Dec 2014)
Log Message
Simplify tracking of process suppression disabled for PluginProcessManager
https://bugs.webkit.org/show_bug.cgi?id=139611
Reviewed by Darin Adler.
Previously if process suppression state changed for any context we would
iterate over all contexts to recompute.
There was also an inconsistency in the code. When plugin processes are
created they called processSuppressionIsEnabledForAllContexts(), which
checked WebContext::processSuppressionEnabled(), which in turn checks
two things - whether any page is currently visible, and whether the
suppression is currently disabled for any page. However when updating
process supression state we would call
processSuppressionPreferenceIsEnabledForAllContexts(), which would just
check the value of the key from the context's default PageGroup.
We shouldn't be taking visibility into account (this is handled from the
content, where we know which pages have instances of which plugins), but
we should be checking the current pref value of each page.
We already track in each context whether any page has teh pref set to
disable throttling; add a counter to the shared PluginProcessManager to
coallesce across all contexts.
* UIProcess/Plugins/PluginProcessManager.cpp:
(WebKit::PluginProcessManager::PluginProcessManager):
- added m_processSuppressionDisabledForPageCounter, m_processSuppressionEnabled.
* UIProcess/Plugins/PluginProcessManager.h:
(WebKit::PluginProcessManager::processSuppressionDisabledForPageCount):
- accessor for WebContext to increment count.
(WebKit::PluginProcessManager::processSuppressionEnabled):
- accessor for PluginProcessProxy.
* UIProcess/Plugins/PluginProcessProxy.cpp:
(WebKit::PluginProcessProxy::didFinishLaunching):
- get initial supression state from the PluginProcessManager, not WebContext.
* UIProcess/Plugins/mac/PluginProcessManagerMac.mm:
(WebKit::PluginProcessManager::updateProcessSuppressionState):
(WebKit::PluginProcessManager::setProcessSuppressionEnabled): Deleted.
- setProcessSuppressionEnabled -> updateProcessSuppressionState
rather than WebContext setting suppression state, PluginProcessManager detects
when this may need to change & determines a new value for itself.
* UIProcess/WebContext.h:
- removed processSuppressionIsEnabledForAllContexts, processSuppressionPreferenceIsEnabledForAllContexts
updateProcessSuppressionState is no longer const (updates m_pluginProcessManagerProcessSuppressionDisabledCount).
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::updateProcessSuppressionState):
- instead of explicitly recomputing plugin throttling state from Within the WebContext, just update
m_pluginProcessManagerProcessSuppressionDisabledCount to count a RefCounter on the shared PluginProcessManager.
(WebKit::WebContext::processSuppressionIsEnabledForAllContexts): Deleted.
(WebKit::WebContext::processSuppressionPreferenceIsEnabledForAllContexts): Deleted.
- removed.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (177290 => 177291)
--- trunk/Source/WebKit2/ChangeLog 2014-12-15 18:58:32 UTC (rev 177290)
+++ trunk/Source/WebKit2/ChangeLog 2014-12-15 19:05:11 UTC (rev 177291)
@@ -1,3 +1,58 @@
+2014-12-15 Gavin Barraclough <[email protected]>
+
+ Simplify tracking of process suppression disabled for PluginProcessManager
+ https://bugs.webkit.org/show_bug.cgi?id=139611
+
+ Reviewed by Darin Adler.
+
+ Previously if process suppression state changed for any context we would
+ iterate over all contexts to recompute.
+
+ There was also an inconsistency in the code. When plugin processes are
+ created they called processSuppressionIsEnabledForAllContexts(), which
+ checked WebContext::processSuppressionEnabled(), which in turn checks
+ two things - whether any page is currently visible, and whether the
+ suppression is currently disabled for any page. However when updating
+ process supression state we would call
+ processSuppressionPreferenceIsEnabledForAllContexts(), which would just
+ check the value of the key from the context's default PageGroup.
+
+ We shouldn't be taking visibility into account (this is handled from the
+ content, where we know which pages have instances of which plugins), but
+ we should be checking the current pref value of each page.
+
+ We already track in each context whether any page has teh pref set to
+ disable throttling; add a counter to the shared PluginProcessManager to
+ coallesce across all contexts.
+
+ * UIProcess/Plugins/PluginProcessManager.cpp:
+ (WebKit::PluginProcessManager::PluginProcessManager):
+ - added m_processSuppressionDisabledForPageCounter, m_processSuppressionEnabled.
+ * UIProcess/Plugins/PluginProcessManager.h:
+ (WebKit::PluginProcessManager::processSuppressionDisabledForPageCount):
+ - accessor for WebContext to increment count.
+ (WebKit::PluginProcessManager::processSuppressionEnabled):
+ - accessor for PluginProcessProxy.
+ * UIProcess/Plugins/PluginProcessProxy.cpp:
+ (WebKit::PluginProcessProxy::didFinishLaunching):
+ - get initial supression state from the PluginProcessManager, not WebContext.
+ * UIProcess/Plugins/mac/PluginProcessManagerMac.mm:
+ (WebKit::PluginProcessManager::updateProcessSuppressionState):
+ (WebKit::PluginProcessManager::setProcessSuppressionEnabled): Deleted.
+ - setProcessSuppressionEnabled -> updateProcessSuppressionState
+ rather than WebContext setting suppression state, PluginProcessManager detects
+ when this may need to change & determines a new value for itself.
+ * UIProcess/WebContext.h:
+ - removed processSuppressionIsEnabledForAllContexts, processSuppressionPreferenceIsEnabledForAllContexts
+ updateProcessSuppressionState is no longer const (updates m_pluginProcessManagerProcessSuppressionDisabledCount).
+ * UIProcess/mac/WebContextMac.mm:
+ (WebKit::WebContext::updateProcessSuppressionState):
+ - instead of explicitly recomputing plugin throttling state from Within the WebContext, just update
+ m_pluginProcessManagerProcessSuppressionDisabledCount to count a RefCounter on the shared PluginProcessManager.
+ (WebKit::WebContext::processSuppressionIsEnabledForAllContexts): Deleted.
+ (WebKit::WebContext::processSuppressionPreferenceIsEnabledForAllContexts): Deleted.
+ - removed.
+
2014-12-15 Carlos Garcia Campos <[email protected]>
[GTK] Use API::LoaderClient instead of WKPageLoaderClient
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp (177290 => 177291)
--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp 2014-12-15 18:58:32 UTC (rev 177290)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp 2014-12-15 19:05:11 UTC (rev 177291)
@@ -43,6 +43,9 @@
}
PluginProcessManager::PluginProcessManager()
+#if PLATFORM(COCOA)
+ : m_processSuppressionDisabledForPageCounter([this]() { updateProcessSuppressionState(); })
+#endif
{
}
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h (177290 => 177291)
--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h 2014-12-15 18:58:32 UTC (rev 177290)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h 2014-12-15 19:05:11 UTC (rev 177291)
@@ -36,6 +36,7 @@
#include <wtf/HashSet.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/Noncopyable.h>
+#include <wtf/RefCounter.h>
#include <wtf/Vector.h>
namespace IPC {
@@ -64,7 +65,9 @@
void clearSiteData(const PluginModuleInfo&, WebPluginSiteDataManager*, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID);
#if PLATFORM(COCOA)
- void setProcessSuppressionEnabled(bool);
+ inline PassRefPtr<RefCounter::Count> processSuppressionDisabledForPageCount();
+ inline bool processSuppressionEnabled() const;
+ void updateProcessSuppressionState();
#endif
private:
@@ -76,8 +79,23 @@
HashSet<uint64_t> m_knownTokens;
Vector<RefPtr<PluginProcessProxy>> m_pluginProcesses;
+
+#if PLATFORM(COCOA)
+ RefCounter m_processSuppressionDisabledForPageCounter;
+ bool m_processSuppressionEnabled { true };
+#endif
};
+inline PassRefPtr<RefCounter::Count> PluginProcessManager::processSuppressionDisabledForPageCount()
+{
+ return m_processSuppressionDisabledForPageCounter.count();
+}
+
+inline bool PluginProcessManager::processSuppressionEnabled() const
+{
+ return m_processSuppressionEnabled;
+}
+
} // namespace WebKit
#endif // ENABLE(NETSCAPE_PLUGIN_API)
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp (177290 => 177291)
--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp 2014-12-15 18:58:32 UTC (rev 177290)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp 2014-12-15 19:05:11 UTC (rev 177291)
@@ -229,7 +229,7 @@
m_numPendingConnectionRequests = 0;
#if PLATFORM(COCOA)
- if (WebContext::processSuppressionIsEnabledForAllContexts())
+ if (PluginProcessManager::shared().processSuppressionEnabled())
setProcessSuppressionEnabled(true);
#endif
}
Modified: trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessManagerMac.mm (177290 => 177291)
--- trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessManagerMac.mm 2014-12-15 18:58:32 UTC (rev 177290)
+++ trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessManagerMac.mm 2014-12-15 19:05:11 UTC (rev 177291)
@@ -32,8 +32,13 @@
namespace WebKit {
-void PluginProcessManager::setProcessSuppressionEnabled(bool processSuppressionEnabled)
+void PluginProcessManager::updateProcessSuppressionState()
{
+ bool processSuppressionEnabled = !m_processSuppressionDisabledForPageCounter.value();
+ if (m_processSuppressionEnabled == processSuppressionEnabled)
+ return;
+
+ m_processSuppressionEnabled = processSuppressionEnabled;
for (auto& pluginProcess : m_pluginProcesses)
pluginProcess->setProcessSuppressionEnabled(processSuppressionEnabled);
}
Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (177290 => 177291)
--- trunk/Source/WebKit2/UIProcess/WebContext.h 2014-12-15 18:58:32 UTC (rev 177290)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h 2014-12-15 19:05:11 UTC (rev 177291)
@@ -314,8 +314,6 @@
#if PLATFORM(COCOA)
bool processSuppressionEnabled() const;
- static bool processSuppressionIsEnabledForAllContexts();
- static bool processSuppressionPreferenceIsEnabledForAllContexts();
#endif
void windowServerConnectionStateChanged();
@@ -346,7 +344,7 @@
static void unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&);
#if PLATFORM(COCOA)
- void updateProcessSuppressionState() const;
+ void updateProcessSuppressionState();
NSMutableDictionary *ensureBundleParameters();
NSMutableDictionary *bundleParameters() { return m_bundleParameters.get(); }
@@ -575,6 +573,7 @@
#if PLATFORM(COCOA)
RetainPtr<NSMutableDictionary> m_bundleParameters;
+ RefPtr<RefCounter::Count> m_pluginProcessManagerProcessSuppressionDisabledCount;
#endif
};
Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm (177290 => 177291)
--- trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm 2014-12-15 18:58:32 UTC (rev 177290)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm 2014-12-15 19:05:11 UTC (rev 177291)
@@ -103,14 +103,18 @@
[[NSUserDefaults standardUserDefaults] registerDefaults:registrationDictionary];
}
-void WebContext::updateProcessSuppressionState() const
+void WebContext::updateProcessSuppressionState()
{
#if ENABLE(NETWORK_PROCESS)
if (m_usesNetworkProcess && m_networkProcess)
m_networkProcess->setProcessSuppressionEnabled(processSuppressionEnabled());
#endif
+
#if ENABLE(NETSCAPE_PLUGIN_API)
- PluginProcessManager::shared().setProcessSuppressionEnabled(processSuppressionPreferenceIsEnabledForAllContexts());
+ if (!m_processSuppressionDisabledForPageCounter.value())
+ m_pluginProcessManagerProcessSuppressionDisabledCount = nullptr;
+ else if (!m_pluginProcessManagerProcessSuppressionDisabledCount)
+ m_pluginProcessManagerProcessSuppressionDisabledCount = PluginProcessManager::shared().processSuppressionDisabledForPageCount();
#endif
}
@@ -515,24 +519,6 @@
return !m_userObservablePageCounter.value() && !m_processSuppressionDisabledForPageCounter.value();
}
-bool WebContext::processSuppressionIsEnabledForAllContexts()
-{
- for (const auto* context : WebContext::allContexts()) {
- if (!context->processSuppressionEnabled())
- return false;
- }
- return true;
-}
-
-bool WebContext::processSuppressionPreferenceIsEnabledForAllContexts()
-{
- for (const auto* context : WebContext::allContexts()) {
- if (!context->m_defaultPageGroup->preferences().store().getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey()))
- return false;
- }
- return true;
-}
-
void WebContext::registerNotificationObservers()
{
#if !PLATFORM(IOS)