Skip to content

Commit

Permalink
Deploy more smart pointers in DownloadProxy and DownloadProxyMap
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260844

Reviewed by Chris Dumez.

Deployed more smart pointers.

* Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::willSendRequest):
* Source/WebKit/UIProcess/Downloads/DownloadProxyMap.cpp:
(WebKit::DownloadProxyMap::protectedProcess):
(WebKit::DownloadProxyMap::createDownloadProxy):
(WebKit::DownloadProxyMap::downloadFinished):
(WebKit::DownloadProxyMap::invalidate):
* Source/WebKit/UIProcess/Downloads/DownloadProxyMap.h:

Canonical link: https://commits.webkit.org/267423@main
  • Loading branch information
rniwa committed Aug 29, 2023
1 parent 491458f commit 616b80d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ void DownloadProxy::willSendRequest(ResourceRequest&& proposedRequest, const Res
m_redirectChain.append(newRequest.url());
if (!protectedThis->m_dataStore)
return;
auto& networkProcessProxy = protectedThis->m_dataStore->networkProcess();
networkProcessProxy.send(Messages::NetworkProcess::ContinueWillSendRequest(protectedThis->m_downloadID, newRequest), 0);
Ref networkProcessProxy = protectedThis->m_dataStore->networkProcess();
networkProcessProxy->send(Messages::NetworkProcess::ContinueWillSendRequest(protectedThis->m_downloadID, newRequest), 0);
});
}

Expand Down
13 changes: 9 additions & 4 deletions Source/WebKit/UIProcess/Downloads/DownloadProxyMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ DownloadProxyMap::~DownloadProxyMap()
platformDestroy();
}

Ref<NetworkProcessProxy> DownloadProxyMap::protectedProcess()
{
return m_process.get();
}

#if !PLATFORM(COCOA)
void DownloadProxyMap::platformCreate()
{
Expand All @@ -81,12 +86,12 @@ Ref<DownloadProxy> DownloadProxyMap::createDownloadProxy(WebsiteDataStore& dataS
m_downloadUIAssertion = ProcessAssertion::create(getCurrentProcessID(), "WebKit downloads"_s, ProcessAssertionType::UnboundedNetworking);

ASSERT(!m_downloadNetworkingAssertion);
m_downloadNetworkingAssertion = ProcessAssertion::create(m_process.processID(), "WebKit downloads"_s, ProcessAssertionType::UnboundedNetworking);
m_downloadNetworkingAssertion = ProcessAssertion::create(m_process->processID(), "WebKit downloads"_s, ProcessAssertionType::UnboundedNetworking);

RELEASE_LOG(ProcessSuspension, "UIProcess took 'WebKit downloads' assertions for UIProcess and NetworkProcess");
}

m_process.addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID().toUInt64(), downloadProxy.get());
protectedProcess()->addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID().toUInt64(), downloadProxy.get());

return downloadProxy;
}
Expand All @@ -99,7 +104,7 @@ void DownloadProxyMap::downloadFinished(DownloadProxy& downloadProxy)

ASSERT(m_downloads.contains(downloadID));

m_process.removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadID.toUInt64());
protectedProcess()->removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadID.toUInt64());
downloadProxy.invalidate();
m_downloads.remove(downloadID);

Expand All @@ -118,7 +123,7 @@ void DownloadProxyMap::invalidate()
for (const auto& download : m_downloads.values()) {
download->processDidClose();
download->invalidate();
m_process.removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), download->downloadID().toUInt64());
protectedProcess()->removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), download->downloadID().toUInt64());
}

m_downloads.clear();
Expand Down
4 changes: 3 additions & 1 deletion Source/WebKit/UIProcess/Downloads/DownloadProxyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ class DownloadProxyMap : public CanMakeWeakPtr<DownloadProxyMap> {
void invalidate();

private:
Ref<NetworkProcessProxy> protectedProcess();

void platformCreate();
void platformDestroy();

NetworkProcessProxy& m_process;
CheckedRef<NetworkProcessProxy> m_process;
HashMap<DownloadID, RefPtr<DownloadProxy>> m_downloads;

bool m_shouldTakeAssertion { false };
Expand Down

0 comments on commit 616b80d

Please sign in to comment.