Skip to content

Commit

Permalink
Deploy more smart pointers in WebProcess.cpp
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260249

Reviewed by Sihui Liu.

Deployed more smart pointers.

* Source/WebKit/WebProcess/WebCoreSupport/WebFileSystemStorageConnection.cpp:
(WebKit::WebFileSystemStorageConnection::create):
(WebKit::WebFileSystemStorageConnection::WebFileSystemStorageConnection):
* Source/WebKit/WebProcess/WebCoreSupport/WebFileSystemStorageConnection.h:
* Source/WebKit/WebProcess/WebProcess.cpp:
(WebKit::WebProcess::createWebPage):
(WebKit::WebProcess::handleInjectedBundleMessage):
(WebKit::WebProcess::setInjectedBundleParameter):
(WebKit::WebProcess::setInjectedBundleParameters):
(WebKit::WebProcess::ensureNetworkProcessConnection):
(WebKit::WebProcess::fileSystemStorageConnection):
(WebKit::WebProcess::ensureGPUProcessConnection):
(WebKit::WebProcess::remotePostMessage):
(WebKit::WebProcess::renderTreeAsText):
(WebKit::WebProcess::establishRemoteWorkerContextConnectionToNetworkProcess):
(WebKit::WebProcess::ensureSpeechRecognitionRealtimeMediaSourceManager):

Canonical link: https://commits.webkit.org/266952@main
  • Loading branch information
rniwa committed Aug 16, 2023
1 parent 5137170 commit 153a083
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@

namespace WebKit {

Ref<WebFileSystemStorageConnection> WebFileSystemStorageConnection::create(IPC::Connection& connection)
Ref<WebFileSystemStorageConnection> WebFileSystemStorageConnection::create(Ref<IPC::Connection>&& connection)
{
return adoptRef(*new WebFileSystemStorageConnection(connection));
return adoptRef(*new WebFileSystemStorageConnection(WTFMove(connection)));
}

WebFileSystemStorageConnection::WebFileSystemStorageConnection(IPC::Connection& connection)
: m_connection(&connection)
WebFileSystemStorageConnection::WebFileSystemStorageConnection(Ref<IPC::Connection>&& connection)
: m_connection(WTFMove(connection))
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ namespace WebKit {

class WebFileSystemStorageConnection final : public WebCore::FileSystemStorageConnection {
public:
static Ref<WebFileSystemStorageConnection> create(IPC::Connection&);
static Ref<WebFileSystemStorageConnection> create(Ref<IPC::Connection>&&);
void connectionClosed();
void didReceiveMessage(IPC::Connection&, IPC::Decoder&);

private:
explicit WebFileSystemStorageConnection(IPC::Connection&);
explicit WebFileSystemStorageConnection(Ref<IPC::Connection>&&);

// FileSystemStorageConnection
void closeHandle(WebCore::FileSystemHandleIdentifier) final;
Expand Down
36 changes: 18 additions & 18 deletions Source/WebKit/WebProcess/WebProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@ void WebProcess::createWebPage(PageIdentifier pageID, WebPageCreationParameters&
result.iterator->value = page.ptr();

#if ENABLE(GPU_PROCESS)
if (m_gpuProcessConnection)
page->gpuProcessConnectionDidBecomeAvailable(*m_gpuProcessConnection);
if (RefPtr gpuProcessConnection = m_gpuProcessConnection)
page->gpuProcessConnectionDidBecomeAvailable(*gpuProcessConnection);
#endif

// Balanced by an enableTermination in removeWebPage.
Expand Down Expand Up @@ -1123,7 +1123,7 @@ void WebProcess::setJavaScriptGarbageCollectorTimerEnabled(bool flag)

void WebProcess::handleInjectedBundleMessage(const String& messageName, const UserData& messageBody)
{
InjectedBundle* injectedBundle = WebProcess::singleton().injectedBundle();
RefPtr injectedBundle = WebProcess::singleton().injectedBundle();
if (!injectedBundle)
return;

Expand All @@ -1132,7 +1132,7 @@ void WebProcess::handleInjectedBundleMessage(const String& messageName, const Us

void WebProcess::setInjectedBundleParameter(const String& key, const IPC::DataReference& value)
{
InjectedBundle* injectedBundle = WebProcess::singleton().injectedBundle();
RefPtr injectedBundle = WebProcess::singleton().injectedBundle();
if (!injectedBundle)
return;

Expand All @@ -1141,7 +1141,7 @@ void WebProcess::setInjectedBundleParameter(const String& key, const IPC::DataRe

void WebProcess::setInjectedBundleParameters(const IPC::DataReference& value)
{
InjectedBundle* injectedBundle = WebProcess::singleton().injectedBundle();
RefPtr injectedBundle = WebProcess::singleton().injectedBundle();
if (!injectedBundle)
return;

Expand Down Expand Up @@ -1197,7 +1197,7 @@ NetworkProcessConnection& WebProcess::ensureNetworkProcessConnection()

// If we've lost our connection to the network process (e.g. it crashed) try to re-establish it.
if (!m_networkProcessConnection) {
auto connectionInfo = getNetworkProcessConnection(*parentProcessConnection());
auto connectionInfo = getNetworkProcessConnection(Ref { *parentProcessConnection() });

m_networkProcessConnection = NetworkProcessConnection::create(IPC::Connection::Identifier { WTFMove(connectionInfo.connection) }, connectionInfo.cookieAcceptPolicy);
#if HAVE(AUDIT_TOKEN)
Expand Down Expand Up @@ -1311,7 +1311,7 @@ void WebProcess::networkProcessConnectionClosed(NetworkProcessConnection* connec
WebFileSystemStorageConnection& WebProcess::fileSystemStorageConnection()
{
if (!m_fileSystemStorageConnection)
m_fileSystemStorageConnection = WebFileSystemStorageConnection::create(ensureNetworkProcessConnection().connection());
m_fileSystemStorageConnection = WebFileSystemStorageConnection::create(Ref { ensureNetworkProcessConnection().connection() });

return *m_fileSystemStorageConnection;
}
Expand All @@ -1329,13 +1329,13 @@ GPUProcessConnection& WebProcess::ensureGPUProcessConnection()

// If we've lost our connection to the GPU process (e.g. it crashed) try to re-establish it.
if (!m_gpuProcessConnection) {
m_gpuProcessConnection = GPUProcessConnection::create(*parentProcessConnection());
m_gpuProcessConnection = GPUProcessConnection::create(Ref { *parentProcessConnection() });
if (!m_gpuProcessConnection)
CRASH();
for (auto& page : m_pageMap.values()) {
// If page is null, then it is currently being constructed.
if (page)
page->gpuProcessConnectionDidBecomeAvailable(*m_gpuProcessConnection);
page->gpuProcessConnectionDidBecomeAvailable(Ref { *m_gpuProcessConnection });
}
}
return *m_gpuProcessConnection;
Expand Down Expand Up @@ -1381,18 +1381,18 @@ void WebProcess::setEnhancedAccessibility(bool flag)

void WebProcess::remotePostMessage(WebCore::FrameIdentifier identifier, std::optional<WebCore::SecurityOriginData> target, const WebCore::MessageWithMessagePorts& message)
{
auto* webFrame = WebProcess::singleton().webFrame(identifier);
RefPtr webFrame = WebProcess::singleton().webFrame(identifier);
if (!webFrame)
return;

if (!webFrame->coreLocalFrame())
return;

auto* domWindow = webFrame->coreLocalFrame()->window();
RefPtr domWindow = webFrame->coreLocalFrame()->window();
if (!domWindow)
return;

auto* frame = domWindow->frame();
RefPtr frame = domWindow->frame();
if (!frame)
return;

Expand All @@ -1406,13 +1406,13 @@ void WebProcess::remotePostMessage(WebCore::FrameIdentifier identifier, std::opt

void WebProcess::renderTreeAsText(WebCore::FrameIdentifier frameIdentifier, size_t baseIndent, OptionSet<WebCore::RenderAsTextFlag> behavior, CompletionHandler<void(String)>&& completionHandler)
{
auto* webFrame = WebProcess::singleton().webFrame(frameIdentifier);
RefPtr webFrame = WebProcess::singleton().webFrame(frameIdentifier);
if (!webFrame) {
ASSERT_NOT_REACHED();
return completionHandler({ });
}

auto* coreLocalFrame = webFrame->coreLocalFrame();
RefPtr coreLocalFrame = webFrame->coreLocalFrame();
if (!coreLocalFrame) {
ASSERT_NOT_REACHED();
return completionHandler({ });
Expand Down Expand Up @@ -2003,16 +2003,16 @@ void WebProcess::establishRemoteWorkerContextConnectionToNetworkProcess(RemoteWo
// We are in the Remote Worker context process and the call below establishes our connection to the Network Process
// by calling ensureNetworkProcessConnection. SWContextManager / SharedWorkerContextManager need to use the same underlying IPC::Connection as the
// NetworkProcessConnection for synchronization purposes.
auto& ipcConnection = ensureNetworkProcessConnection().connection();
Ref ipcConnection = ensureNetworkProcessConnection().connection();
switch (workerType) {
case RemoteWorkerType::ServiceWorker:
#if ENABLE(SERVICE_WORKER)
SWContextManager::singleton().setConnection(WebSWContextManagerConnection::create(ipcConnection, WTFMove(registrableDomain), serviceWorkerPageIdentifier, pageGroupID, webPageProxyID, pageID, store, WTFMove(initializationData)));
SWContextManager::singleton().setConnection(WebSWContextManagerConnection::create(WTFMove(ipcConnection), WTFMove(registrableDomain), serviceWorkerPageIdentifier, pageGroupID, webPageProxyID, pageID, store, WTFMove(initializationData)));
SWContextManager::singleton().connection()->establishConnection(WTFMove(completionHandler));
#endif
break;
case RemoteWorkerType::SharedWorker:
SharedWorkerContextManager::singleton().setConnection(makeUnique<WebSharedWorkerContextManagerConnection>(ipcConnection, WTFMove(registrableDomain), pageGroupID, webPageProxyID, pageID, store, WTFMove(initializationData)));
SharedWorkerContextManager::singleton().setConnection(makeUnique<WebSharedWorkerContextManagerConnection>(WTFMove(ipcConnection), WTFMove(registrableDomain), pageGroupID, webPageProxyID, pageID, store, WTFMove(initializationData)));
SharedWorkerContextManager::singleton().connection()->establishConnection(WTFMove(completionHandler));
break;
}
Expand Down Expand Up @@ -2301,7 +2301,7 @@ bool WebProcess::shouldUseRemoteRenderingForWebGL() const
SpeechRecognitionRealtimeMediaSourceManager& WebProcess::ensureSpeechRecognitionRealtimeMediaSourceManager()
{
if (!m_speechRecognitionRealtimeMediaSourceManager)
m_speechRecognitionRealtimeMediaSourceManager = makeUnique<SpeechRecognitionRealtimeMediaSourceManager>(*parentProcessConnection());
m_speechRecognitionRealtimeMediaSourceManager = makeUnique<SpeechRecognitionRealtimeMediaSourceManager>(Ref { *parentProcessConnection() });

return *m_speechRecognitionRealtimeMediaSourceManager;
}
Expand Down

0 comments on commit 153a083

Please sign in to comment.