Diff
Modified: trunk/Source/WebKit2/ChangeLog (164831 => 164832)
--- trunk/Source/WebKit2/ChangeLog 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/ChangeLog 2014-02-27 23:16:41 UTC (rev 164832)
@@ -1,3 +1,44 @@
+2014-02-27 Anders Carlsson <[email protected]>
+
+ Simplify WebProcessProxy state accessors
+ https://bugs.webkit.org/show_bug.cgi?id=129453
+
+ Reviewed by Andreas Kling.
+
+ Replace WebProcessProxy::isLaunching() and WebProcessProxy::isValid() with a single
+ WebProcessProxy::state() that return one of three values: Launching, Running or Terminated.
+
+ * Shared/ChildProcessProxy.cpp:
+ (WebKit::ChildProcessProxy::state):
+ (WebKit::ChildProcessProxy::sendMessage):
+ (WebKit::ChildProcessProxy::abortProcessLaunchIfNeeded):
+ * Shared/ChildProcessProxy.h:
+ (WebKit::ChildProcessProxy::canSendMessage):
+ * UIProcess/Databases/DatabaseProcessProxy.cpp:
+ (WebKit::DatabaseProcessProxy::getDatabaseProcessConnection):
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::getNetworkProcessConnection):
+ * UIProcess/Network/mac/NetworkProcessProxyMac.mm:
+ (WebKit::NetworkProcessProxy::setProcessSuppressionEnabled):
+ * UIProcess/Plugins/PluginProcessProxy.cpp:
+ (WebKit::PluginProcessProxy::getPluginProcessConnection):
+ (WebKit::PluginProcessProxy::getSitesWithData):
+ (WebKit::PluginProcessProxy::clearSiteData):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy):
+ (WebKit::WebPageProxy::reattachToWebProcess):
+ (WebKit::WebPageProxy::waitForDidUpdateViewState):
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::requestTermination):
+ (WebKit::WebProcessProxy::enableSuddenTermination):
+ (WebKit::WebProcessProxy::disableSuddenTermination):
+ * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+ (WebKit::TiledCoreAnimationDrawingAreaProxy::waitForPossibleGeometryUpdate):
+ * UIProcess/mac/WebPageProxyMac.mm:
+ (WebKit::WebPageProxy::shouldDelayWindowOrderingForEvent):
+ * UIProcess/mac/WebProcessProxyMac.mm:
+ (WebKit::WebProcessProxy::updateProcessSuppressionState):
+
2014-02-27 Simon Fraser <[email protected]>
Crash tapping on play button on video on iOS
Modified: trunk/Source/WebKit2/Shared/ChildProcessProxy.cpp (164831 => 164832)
--- trunk/Source/WebKit2/Shared/ChildProcessProxy.cpp 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/Shared/ChildProcessProxy.cpp 2014-02-27 23:16:41 UTC (rev 164832)
@@ -69,19 +69,33 @@
m_processLauncher->terminateProcess();
}
+ChildProcessProxy::State ChildProcessProxy::state() const
+{
+ if (m_processLauncher && m_processLauncher->isLaunching())
+ return ChildProcessProxy::State::Launching;
+
+ if (!m_connection)
+ return ChildProcessProxy::State::Terminated;
+
+ return ChildProcessProxy::State::Running;
+}
+
bool ChildProcessProxy::sendMessage(std::unique_ptr<IPC::MessageEncoder> encoder, unsigned messageSendFlags)
{
- // If we're waiting for the child process to launch, we need to stash away the messages so we can send them once we have a connection.
- if (isLaunching()) {
+ switch (state()) {
+ case State::Launching:
+ // If we're waiting for the child process to launch, we need to stash away the messages so we can send them once we have a connection.
m_pendingMessages.append(std::make_pair(std::move(encoder), messageSendFlags));
return true;
- }
- // If the web process has exited, connection will be null here.
- if (!m_connection)
+ case State::Running:
+ return connection()->sendMessage(std::move(encoder), messageSendFlags);
+
+ case State::Terminated:
return false;
+ }
- return connection()->sendMessage(std::move(encoder), messageSendFlags);
+ return false;
}
void ChildProcessProxy::addMessageReceiver(IPC::StringReference messageReceiverName, IPC::MessageReceiver& messageReceiver)
@@ -109,14 +123,6 @@
return m_messageReceiverMap.dispatchSyncMessage(connection, decoder, replyEncoder);
}
-bool ChildProcessProxy::isLaunching() const
-{
- if (m_processLauncher)
- return m_processLauncher->isLaunching();
-
- return false;
-}
-
void ChildProcessProxy::didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier connectionIdentifier)
{
ASSERT(!m_connection);
@@ -140,11 +146,11 @@
void ChildProcessProxy::abortProcessLaunchIfNeeded()
{
- if (!isLaunching())
+ if (state() != State::Launching)
return;
m_processLauncher->invalidate();
- m_processLauncher = 0;
+ m_processLauncher = nullptr;
}
void ChildProcessProxy::clearConnection()
Modified: trunk/Source/WebKit2/Shared/ChildProcessProxy.h (164831 => 164832)
--- trunk/Source/WebKit2/Shared/ChildProcessProxy.h 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/Shared/ChildProcessProxy.h 2014-02-27 23:16:41 UTC (rev 164832)
@@ -60,10 +60,16 @@
void addMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID, IPC::MessageReceiver&);
void removeMessageReceiver(IPC::StringReference messageReceiverName, uint64_t destinationID);
- bool isValid() const { return m_connection; }
- bool isLaunching() const;
- bool canSendMessage() const { return isValid() || isLaunching(); }
+ enum class State {
+ Launching,
+ Running,
+ Terminated,
+ };
+ State state() const;
+// bool isValid() const { return m_connection; }
+ bool canSendMessage() const { return state() != State::Terminated;}
+
PlatformProcessIdentifier processIdentifier() const { return m_processLauncher->processIdentifier(); }
bool sendMessage(std::unique_ptr<IPC::MessageEncoder>, unsigned messageSendFlags);
Modified: trunk/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp (164831 => 164832)
--- trunk/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp 2014-02-27 23:16:41 UTC (rev 164832)
@@ -70,7 +70,7 @@
{
m_pendingConnectionReplies.append(reply);
- if (isLaunching()) {
+ if (state() == State::Launching) {
m_numPendingConnectionRequests++;
return;
}
Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp (164831 => 164832)
--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp 2014-02-27 23:16:41 UTC (rev 164832)
@@ -87,7 +87,7 @@
{
m_pendingConnectionReplies.append(reply);
- if (isLaunching()) {
+ if (state() == State::Launching) {
m_numPendingConnectionRequests++;
return;
}
Modified: trunk/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm (164831 => 164832)
--- trunk/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/UIProcess/Network/mac/NetworkProcessProxyMac.mm 2014-02-27 23:16:41 UTC (rev 164832)
@@ -36,7 +36,7 @@
void NetworkProcessProxy::setProcessSuppressionEnabled(bool processSuppressionEnabled)
{
- if (!isValid())
+ if (state() != State::Running)
return;
connection()->send(Messages::NetworkProcess::SetProcessSuppressionEnabled(processSuppressionEnabled), 0);
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp (164831 => 164832)
--- trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp 2014-02-27 23:16:41 UTC (rev 164832)
@@ -88,7 +88,7 @@
{
m_pendingConnectionReplies.append(reply);
- if (isLaunching()) {
+ if (state() == State::Launching) {
m_numPendingConnectionRequests++;
return;
}
@@ -103,7 +103,7 @@
ASSERT(!m_pendingGetSitesReplies.contains(callbackID));
m_pendingGetSitesReplies.set(callbackID, webPluginSiteDataManager);
- if (isLaunching()) {
+ if (state() == State::Launching) {
m_pendingGetSitesRequests.append(callbackID);
return;
}
@@ -117,7 +117,7 @@
ASSERT(!m_pendingClearSiteDataReplies.contains(callbackID));
m_pendingClearSiteDataReplies.set(callbackID, webPluginSiteDataManager);
- if (isLaunching()) {
+ if (state() == State::Launching) {
ClearSiteDataRequest request;
request.sites = sites;
request.flags = flags;
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (164831 => 164832)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2014-02-27 23:16:41 UTC (rev 164832)
@@ -371,7 +371,8 @@
m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
// FIXME: If we ever expose the session storage size as a preference, we need to pass it here.
- m_process->context().storageManager().createSessionStorageNamespace(m_pageID, m_process->isValid() ? m_process->connection() : 0, std::numeric_limits<unsigned>::max());
+ IPC::Connection* connection = m_process->state() == WebProcessProxy::State::Running ? m_process->connection() : nullptr;
+ m_process->context().storageManager().createSessionStorageNamespace(m_pageID, connection, std::numeric_limits<unsigned>::max());
setSession(*configuration.session);
}
@@ -483,8 +484,7 @@
void WebPageProxy::reattachToWebProcess()
{
ASSERT(!isValid());
- ASSERT(!m_process->isValid());
- ASSERT(!m_process->isLaunching());
+ ASSERT(m_process->state() == WebProcessProxy::State::Terminated);
updateViewState();
@@ -1031,7 +1031,7 @@
m_waitingForDidUpdateViewState = true;
- if (!m_process->isLaunching()) {
+ if (m_process->state() != WebProcessProxy::State::Launching) {
auto viewStateUpdateTimeout = std::chrono::milliseconds(250);
m_process->connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::DidUpdateViewState>(m_pageID, viewStateUpdateTimeout);
}
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (164831 => 164832)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2014-02-27 23:16:41 UTC (rev 164832)
@@ -646,7 +646,7 @@
void WebProcessProxy::requestTermination()
{
- if (!isValid())
+ if (state() != State::Running)
return;
ChildProcessProxy::terminate();
@@ -659,7 +659,7 @@
void WebProcessProxy::enableSuddenTermination()
{
- if (!isValid())
+ if (state() != State::Running)
return;
ASSERT(m_numberOfTimesSuddenTerminationWasDisabled);
@@ -669,7 +669,7 @@
void WebProcessProxy::disableSuddenTermination()
{
- if (!isValid())
+ if (state() != State::Running)
return;
WebCore::disableSuddenTermination();
Modified: trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm (164831 => 164832)
--- trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm 2014-02-27 23:16:41 UTC (rev 164832)
@@ -72,7 +72,7 @@
if (!m_isWaitingForDidUpdateGeometry)
return;
- if (m_webPageProxy->process().isLaunching())
+ if (m_webPageProxy->process().state() != WebProcessProxy::State::Running)
return;
m_webPageProxy->process().connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateGeometry>(m_webPageProxy->pageID(), timeout);
Modified: trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm (164831 => 164832)
--- trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm 2014-02-27 23:16:41 UTC (rev 164832)
@@ -437,7 +437,7 @@
bool WebPageProxy::shouldDelayWindowOrderingForEvent(const WebKit::WebMouseEvent& event)
{
- if (!process().isValid())
+ if (process().state() != WebProcessProxy::State::Running)
return false;
bool result = false;
Modified: trunk/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm (164831 => 164832)
--- trunk/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm 2014-02-27 22:55:44 UTC (rev 164831)
+++ trunk/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm 2014-02-27 23:16:41 UTC (rev 164832)
@@ -68,7 +68,7 @@
void WebProcessProxy::updateProcessSuppressionState()
{
- if (!isValid())
+ if (state() != State::Running)
return;
bool canEnable = allPagesAreProcessSuppressible();