- Revision
- 184223
- Author
- [email protected]
- Date
- 2015-05-12 15:06:44 -0700 (Tue, 12 May 2015)
Log Message
Make {Network, Web}ProcessProxy inherit from ProcessThrottleClient privately
https://bugs.webkit.org/show_bug.cgi?id=144886
Reviewed by Darin Adler.
{Network, Web}ProcessProxy are implemented in terms of ProcessThrottleClient, an
interface that defines the callbacks that ProcessThrottler makes to a client. We
do not want to allow arbitrary callers to make use of the interface ProcessThrottleClient.
So, we should use private inheritance to represent the relationship between
{Network, Web}ProcessProxy and ProcessThrottleClient instead of public inheritance.
Additionally make ProcessThrottler a instance variable of {Network, Web}ProcessProxy instead
of holding a smart pointer to a ProcessThrottler instance because we always want to
have a ProcessThrottler for each instance of {Network, Web}ProcessProxy.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::NetworkProcessProxy): Update code to work now that m_throttler
is an instance of ProcessThrottler instead of a smart pointer to a ProcessThrottler instance.
(WebKit::NetworkProcessProxy::didFinishLaunching): Update code to access functions of
m_throttler by reference instead of by pointer.
(WebKit::NetworkProcessProxy::didCancelProcessSuspension): Ditto.
(WebKit::NetworkProcessProxy::processReadyToSuspend): Ditto.
(WebKit::NetworkProcessProxy::setIsHoldingLockedFiles): Ditto.
* UIProcess/Network/NetworkProcessProxy.h: Inherit from ProcessThrottleClient privately.
(WebKit::NetworkProcessProxy::throttler): Update code to work now that m_throttler is an
instance of ProcessThrottler instead of a smart pointer to a ProcessThrottler instance.
* UIProcess/ProcessThrottler.cpp:
(WebKit::ProcessThrottler::ProcessThrottler): Update code to work now that m_process is
a lvalue reference instead of a pointer.
(WebKit::ProcessThrottler::updateAssertion): Ditto.
(WebKit::ProcessThrottler::assertionWillExpireImminently): Ditto.
* UIProcess/ProcessThrottler.h: Ditto.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::WebProcessProxy): Update code to work now that m_throttler is an
instance of ProcessThrottler instead of a smart pointer to a ProcessThrottler instance.
(WebKit::WebProcessProxy::didFinishLaunching): Update code to access functions of
m_throttler by reference instead of by pointer.
(WebKit::WebProcessProxy::processReadyToSuspend): Ditto.
(WebKit::WebProcessProxy::didCancelProcessSuspension): Ditto.
(WebKit::WebProcessProxy::setIsHoldingLockedFiles): Ditto.
* UIProcess/WebProcessProxy.h: Inherit from ProcessThrottleClient privately.
(WebKit::WebProcessProxy::throttler): Update code to work now that m_throttler is an
instance of ProcessThrottler instead of a smart pointer to a ProcessThrottler instance.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (184222 => 184223)
--- trunk/Source/WebKit2/ChangeLog 2015-05-12 21:50:16 UTC (rev 184222)
+++ trunk/Source/WebKit2/ChangeLog 2015-05-12 22:06:44 UTC (rev 184223)
@@ -1,3 +1,49 @@
+2015-05-12 Daniel Bates <[email protected]>
+
+ Make {Network, Web}ProcessProxy inherit from ProcessThrottleClient privately
+ https://bugs.webkit.org/show_bug.cgi?id=144886
+
+ Reviewed by Darin Adler.
+
+ {Network, Web}ProcessProxy are implemented in terms of ProcessThrottleClient, an
+ interface that defines the callbacks that ProcessThrottler makes to a client. We
+ do not want to allow arbitrary callers to make use of the interface ProcessThrottleClient.
+ So, we should use private inheritance to represent the relationship between
+ {Network, Web}ProcessProxy and ProcessThrottleClient instead of public inheritance.
+
+ Additionally make ProcessThrottler a instance variable of {Network, Web}ProcessProxy instead
+ of holding a smart pointer to a ProcessThrottler instance because we always want to
+ have a ProcessThrottler for each instance of {Network, Web}ProcessProxy.
+
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::NetworkProcessProxy): Update code to work now that m_throttler
+ is an instance of ProcessThrottler instead of a smart pointer to a ProcessThrottler instance.
+ (WebKit::NetworkProcessProxy::didFinishLaunching): Update code to access functions of
+ m_throttler by reference instead of by pointer.
+ (WebKit::NetworkProcessProxy::didCancelProcessSuspension): Ditto.
+ (WebKit::NetworkProcessProxy::processReadyToSuspend): Ditto.
+ (WebKit::NetworkProcessProxy::setIsHoldingLockedFiles): Ditto.
+ * UIProcess/Network/NetworkProcessProxy.h: Inherit from ProcessThrottleClient privately.
+ (WebKit::NetworkProcessProxy::throttler): Update code to work now that m_throttler is an
+ instance of ProcessThrottler instead of a smart pointer to a ProcessThrottler instance.
+ * UIProcess/ProcessThrottler.cpp:
+ (WebKit::ProcessThrottler::ProcessThrottler): Update code to work now that m_process is
+ a lvalue reference instead of a pointer.
+ (WebKit::ProcessThrottler::updateAssertion): Ditto.
+ (WebKit::ProcessThrottler::assertionWillExpireImminently): Ditto.
+ * UIProcess/ProcessThrottler.h: Ditto.
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::WebProcessProxy): Update code to work now that m_throttler is an
+ instance of ProcessThrottler instead of a smart pointer to a ProcessThrottler instance.
+ (WebKit::WebProcessProxy::didFinishLaunching): Update code to access functions of
+ m_throttler by reference instead of by pointer.
+ (WebKit::WebProcessProxy::processReadyToSuspend): Ditto.
+ (WebKit::WebProcessProxy::didCancelProcessSuspension): Ditto.
+ (WebKit::WebProcessProxy::setIsHoldingLockedFiles): Ditto.
+ * UIProcess/WebProcessProxy.h: Inherit from ProcessThrottleClient privately.
+ (WebKit::WebProcessProxy::throttler): Update code to work now that m_throttler is an
+ instance of ProcessThrottler instead of a smart pointer to a ProcessThrottler instance.
+
2015-05-12 Anders Carlsson <[email protected]>
Production builds should link against the shims directly
Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp (184222 => 184223)
--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp 2015-05-12 21:50:16 UTC (rev 184222)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp 2015-05-12 22:06:44 UTC (rev 184223)
@@ -68,7 +68,7 @@
: m_processPool(processPool)
, m_numPendingConnectionRequests(0)
, m_customProtocolManagerProxy(this, processPool)
- , m_throttler(std::make_unique<ProcessThrottler>(this))
+ , m_throttler(*this)
{
connect();
}
@@ -276,7 +276,7 @@
#if PLATFORM(IOS)
if (xpc_connection_t connection = this->connection()->xpcConnection())
- m_throttler->didConnectToProcess(xpc_connection_get_pid(connection));
+ m_throttler.didConnectToProcess(xpc_connection_get_pid(connection));
#endif
}
@@ -337,7 +337,7 @@
void NetworkProcessProxy::didCancelProcessSuspension()
{
- m_throttler->didCancelProcessSuspension();
+ m_throttler.didCancelProcessSuspension();
}
void NetworkProcessProxy::sendProcessDidResume()
@@ -348,7 +348,7 @@
void NetworkProcessProxy::processReadyToSuspend()
{
- m_throttler->processReadyToSuspend();
+ m_throttler.processReadyToSuspend();
}
void NetworkProcessProxy::setIsHoldingLockedFiles(bool isHoldingLockedFiles)
@@ -358,7 +358,7 @@
return;
}
if (!m_tokenForHoldingLockedFiles)
- m_tokenForHoldingLockedFiles = m_throttler->backgroundActivityToken();
+ m_tokenForHoldingLockedFiles = m_throttler.backgroundActivityToken();
}
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h (184222 => 184223)
--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h 2015-05-12 21:50:16 UTC (rev 184222)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h 2015-05-12 22:06:44 UTC (rev 184223)
@@ -52,7 +52,7 @@
class WebProcessPool;
struct NetworkProcessCreationParameters;
-class NetworkProcessProxy : public ChildProcessProxy, public ProcessThrottlerClient {
+class NetworkProcessProxy : public ChildProcessProxy, private ProcessThrottlerClient {
public:
static PassRefPtr<NetworkProcessProxy> create(WebProcessPool&);
~NetworkProcessProxy();
@@ -69,15 +69,12 @@
void setProcessSuppressionEnabled(bool);
#endif
- void sendProcessWillSuspendImminently() override;
- void sendProcessWillSuspend() override;
- void sendCancelProcessWillSuspend() override;
void didCancelProcessSuspension();
void processReadyToSuspend();
- void sendProcessDidResume() override;
+
void setIsHoldingLockedFiles(bool);
- ProcessThrottler& throttler() { return *m_throttler; }
+ ProcessThrottler& throttler() { return m_throttler; }
private:
NetworkProcessProxy(WebProcessPool&);
@@ -89,6 +86,12 @@
void platformGetLaunchOptions(ProcessLauncher::LaunchOptions&);
void networkProcessCrashedOrFailedToLaunch();
+ // ProcessThrottlerClient
+ void sendProcessWillSuspendImminently() override;
+ void sendProcessWillSuspend() override;
+ void sendCancelProcessWillSuspend() override;
+ void sendProcessDidResume() override;
+
// IPC::Connection::Client
virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
virtual void didReceiveSyncMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&) override;
@@ -122,7 +125,7 @@
std::unique_ptr<DownloadProxyMap> m_downloadProxyMap;
CustomProtocolManagerProxy m_customProtocolManagerProxy;
- std::unique_ptr<ProcessThrottler> m_throttler;
+ ProcessThrottler m_throttler;
ProcessThrottler::BackgroundActivityToken m_tokenForHoldingLockedFiles;
};
Modified: trunk/Source/WebKit2/UIProcess/ProcessThrottler.cpp (184222 => 184223)
--- trunk/Source/WebKit2/UIProcess/ProcessThrottler.cpp 2015-05-12 21:50:16 UTC (rev 184222)
+++ trunk/Source/WebKit2/UIProcess/ProcessThrottler.cpp 2015-05-12 22:06:44 UTC (rev 184223)
@@ -32,7 +32,7 @@
static const unsigned processSuspensionTimeout = 30;
-ProcessThrottler::ProcessThrottler(ProcessThrottlerClient* process)
+ProcessThrottler::ProcessThrottler(ProcessThrottlerClient& process)
: m_process(process)
, m_suspendTimer(RunLoop::main(), this, &ProcessThrottler::suspendTimerFired)
, m_foregroundCounter([this](bool) { updateAssertion(); })
@@ -66,7 +66,7 @@
// in the background for too long.
if (m_assertion && m_assertion->state() != AssertionState::Suspended && !m_foregroundCounter.value() && !m_backgroundCounter.value()) {
++m_suspendMessageCount;
- m_process->sendProcessWillSuspend();
+ m_process.sendProcessWillSuspend();
m_suspendTimer.startOneShot(processSuspensionTimeout);
m_assertion->setState(AssertionState::Background);
return;
@@ -76,10 +76,10 @@
// If we're currently waiting for the Web process to do suspension cleanup, but no longer need to be suspended, tell the Web process to cancel the cleanup.
if (m_suspendTimer.isActive() && shouldBeRunnable)
- m_process->sendCancelProcessWillSuspend();
+ m_process.sendCancelProcessWillSuspend();
if (m_assertion && m_assertion->state() == AssertionState::Suspended && shouldBeRunnable)
- m_process->sendProcessDidResume();
+ m_process.sendProcessDidResume();
updateAssertionNow();
}
@@ -112,7 +112,7 @@
void ProcessThrottler::assertionWillExpireImminently()
{
- m_process->sendProcessWillSuspendImminently();
+ m_process.sendProcessWillSuspendImminently();
}
}
Modified: trunk/Source/WebKit2/UIProcess/ProcessThrottler.h (184222 => 184223)
--- trunk/Source/WebKit2/UIProcess/ProcessThrottler.h 2015-05-12 21:50:16 UTC (rev 184222)
+++ trunk/Source/WebKit2/UIProcess/ProcessThrottler.h 2015-05-12 22:06:44 UTC (rev 184223)
@@ -48,7 +48,7 @@
enum BackgroundActivityTokenType { };
typedef RefCounter::Token<BackgroundActivityTokenType> BackgroundActivityToken;
- ProcessThrottler(ProcessThrottlerClient*);
+ ProcessThrottler(ProcessThrottlerClient&);
inline ForegroundActivityToken foregroundActivityToken() const;
inline BackgroundActivityToken backgroundActivityToken() const;
@@ -66,7 +66,7 @@
// ProcessAssertionClient
void assertionWillExpireImminently() override;
- ProcessThrottlerClient* m_process;
+ ProcessThrottlerClient& m_process;
std::unique_ptr<ProcessAndUIAssertion> m_assertion;
RunLoop::Timer<ProcessThrottler> m_suspendTimer;
RefCounter m_foregroundCounter;
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (184222 => 184223)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2015-05-12 21:50:16 UTC (rev 184222)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2015-05-12 22:06:44 UTC (rev 184223)
@@ -106,7 +106,7 @@
, m_mayHaveUniversalFileReadSandboxExtension(false)
, m_customProtocolManagerProxy(this, processPool)
, m_numberOfTimesSuddenTerminationWasDisabled(0)
- , m_throttler(std::make_unique<ProcessThrottler>(this))
+ , m_throttler(*this)
{
WebPasteboardProxy::singleton().addWebProcessProxy(*this);
@@ -588,7 +588,7 @@
#if PLATFORM(IOS)
xpc_connection_t xpcConnection = connection()->xpcConnection();
ASSERT(xpcConnection);
- m_throttler->didConnectToProcess(xpc_connection_get_pid(xpcConnection));
+ m_throttler.didConnectToProcess(xpc_connection_get_pid(xpcConnection));
#endif
initializeNetworkProcessActivityToken();
@@ -929,7 +929,7 @@
void WebProcessProxy::processReadyToSuspend()
{
- m_throttler->processReadyToSuspend();
+ m_throttler.processReadyToSuspend();
#if PLATFORM(IOS) && ENABLE(NETWORK_PROCESS)
m_tokenForNetworkProcess = nullptr;
#endif
@@ -937,7 +937,7 @@
void WebProcessProxy::didCancelProcessSuspension()
{
- m_throttler->didCancelProcessSuspension();
+ m_throttler.didCancelProcessSuspension();
}
void WebProcessProxy::setIsHoldingLockedFiles(bool isHoldingLockedFiles)
@@ -947,7 +947,7 @@
return;
}
if (!m_tokenForHoldingLockedFiles)
- m_tokenForHoldingLockedFiles = m_throttler->backgroundActivityToken();
+ m_tokenForHoldingLockedFiles = m_throttler.backgroundActivityToken();
}
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (184222 => 184223)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h 2015-05-12 21:50:16 UTC (rev 184222)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h 2015-05-12 22:06:44 UTC (rev 184223)
@@ -64,7 +64,7 @@
class WebProcessPool;
struct WebNavigationDataStore;
-class WebProcessProxy : public ChildProcessProxy, ResponsivenessTimer::Client, public ProcessThrottlerClient {
+class WebProcessProxy : public ChildProcessProxy, ResponsivenessTimer::Client, private ProcessThrottlerClient {
public:
typedef HashMap<uint64_t, RefPtr<WebBackForwardListItem>> WebBackForwardListItemMap;
typedef HashMap<uint64_t, RefPtr<WebFrameProxy>> WebFrameProxyMap;
@@ -143,16 +143,12 @@
void windowServerConnectionStateChanged();
- void sendProcessWillSuspendImminently() override;
- void sendProcessWillSuspend() override;
void processReadyToSuspend();
- void sendCancelProcessWillSuspend() override;
void didCancelProcessSuspension();
- void sendProcessDidResume() override;
void setIsHoldingLockedFiles(bool);
- ProcessThrottler& throttler() { return *m_throttler; }
+ ProcessThrottler& throttler() { return m_throttler; }
private:
explicit WebProcessProxy(WebProcessPool&);
@@ -209,6 +205,12 @@
void interactionOccurredWhileUnresponsive(ResponsivenessTimer*) override;
void didBecomeResponsive(ResponsivenessTimer*) override;
+ // ProcessThrottlerClient
+ void sendProcessWillSuspendImminently() override;
+ void sendProcessWillSuspend() override;
+ void sendCancelProcessWillSuspend() override;
+ void sendProcessDidResume() override;
+
// ProcessLauncher::Client
virtual void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
@@ -243,7 +245,7 @@
HashMap<uint64_t, std::function<void ()>> m_pendingDeleteWebsiteDataForOriginsCallbacks;
int m_numberOfTimesSuddenTerminationWasDisabled;
- std::unique_ptr<ProcessThrottler> m_throttler;
+ ProcessThrottler m_throttler;
ProcessThrottler::BackgroundActivityToken m_tokenForHoldingLockedFiles;
#if PLATFORM(IOS) && ENABLE(NETWORK_PROCESS)
ProcessThrottler::ForegroundActivityToken m_tokenForNetworkProcess;