Skip to content

Commit 5c98230

Browse files
lopezlozoyarniwa
authored andcommitted
Implement more smart pointers in WebProcess.h/cpp Part #1
https://bugs.webkit.org/show_bug.cgi?id=287440 rdar://145011222 Reviewed by Ryosuke Niwa. Addressing some more smart pointer warnings in WebProcess part #1. * Source/WebKit/WebProcess/WebProcess.cpp: (WebKit::WebProcess::initializeWebProcess): (WebKit::WebProcess::ensureNetworkProcessConnection): (WebKit::WebProcess::prepareToSuspend): (WebKit::WebProcess::markAllLayersVolatile): (WebKit::WebProcess::libWebRTCNetwork): (WebKit::WebProcess::setUseGPUProcessForMedia): * Source/WebKit/WebProcess/WebProcess.h: Canonical link: https://commits.webkit.org/290637@main
1 parent 400b0bd commit 5c98230

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Source/WebKit/WebProcess/WebProcess.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static void scheduleLogMemoryStatistics(LogMemoryStatisticsReason reason)
425425
}
426426

427427
void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters, CompletionHandler<void(ProcessIdentity)>&& completionHandler)
428-
{
428+
{
429429
TraceScope traceScope(InitializeWebProcessStart, InitializeWebProcessEnd);
430430
// Reply immediately so that the identity is available as soon as possible.
431431
completionHandler(ProcessIdentity { ProcessIdentity::CurrentProcess });
@@ -544,7 +544,7 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters,
544544
for (auto& supplement : m_supplements.values())
545545
supplement->initialize(parameters);
546546
#if ENABLE(GPU_PROCESS) && ENABLE(VIDEO)
547-
m_remoteMediaPlayerManager->initialize(parameters);
547+
protectedRemoteMediaPlayerManager()->initialize(parameters);
548548
#endif
549549

550550
setCacheModel(parameters.cacheModel);
@@ -1267,7 +1267,7 @@ NetworkProcessConnection& WebProcess::ensureNetworkProcessConnection()
12671267
#endif
12681268

12691269
// This can be called during a WebPage's constructor, so wait until after the constructor returns to touch the WebPage.
1270-
RunLoop::protectedMain()->dispatch([this] {
1270+
RunLoop::protectedMain()->dispatch([this, protectedThis = Ref { *this }] {
12711271
for (auto& webPage : m_pageMap.values())
12721272
webPage->synchronizeCORSDisablingPatternsWithNetworkProcess();
12731273
});
@@ -1706,7 +1706,7 @@ void WebProcess::prepareToSuspend(bool isSuspensionImminent, MonotonicTime estim
17061706
updateFreezerStatus();
17071707
#endif
17081708

1709-
markAllLayersVolatile([this, completionHandler = WTFMove(completionHandler)]() mutable {
1709+
markAllLayersVolatile([this, protectedThis = Ref { *this }, completionHandler = WTFMove(completionHandler)]() mutable {
17101710
WEBPROCESS_RELEASE_LOG(ProcessSuspension, "prepareToSuspend: Process is ready to suspend");
17111711
completionHandler();
17121712
});
@@ -1731,7 +1731,7 @@ void WebProcess::markAllLayersVolatile(CompletionHandler<void()>&& completionHan
17311731
WEBPROCESS_RELEASE_LOG(ProcessSuspension, "markAllLayersVolatile:");
17321732
auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
17331733
for (auto& page : m_pageMap.values()) {
1734-
page->markLayersVolatile([this, callbackAggregator, pageID = page->identifier()] (bool succeeded) {
1734+
page->markLayersVolatile([this, protectedThis = Ref { *this }, callbackAggregator, pageID = page->identifier()] (bool succeeded) {
17351735
if (succeeded)
17361736
WEBPROCESS_RELEASE_LOG(ProcessSuspension, "markAllLayersVolatile: Successfuly marked layers as volatile for webPageID=%" PRIu64, pageID.toUInt64());
17371737
else
@@ -2074,7 +2074,7 @@ void WebProcess::clearCachedPage(BackForwardItemIdentifier backForwardItemID, Co
20742074
LibWebRTCNetwork& WebProcess::libWebRTCNetwork()
20752075
{
20762076
if (!m_libWebRTCNetwork)
2077-
m_libWebRTCNetwork = makeUniqueWithoutRefCountedCheck<LibWebRTCNetwork>(*this);
2077+
lazyInitialize(m_libWebRTCNetwork, makeUniqueWithoutRefCountedCheck<LibWebRTCNetwork>(*this));
20782078
return *m_libWebRTCNetwork;
20792079
}
20802080

@@ -2371,11 +2371,11 @@ void WebProcess::setUseGPUProcessForMedia(bool useGPUProcessForMedia)
23712371

23722372
#if PLATFORM(COCOA)
23732373
if (useGPUProcessForMedia) {
2374-
SystemBatteryStatusTestingOverrides::singleton().setConfigurationChangedCallback([this] (bool forceUpdate) {
2374+
SystemBatteryStatusTestingOverrides::singleton().setConfigurationChangedCallback([this, protectedThis = Ref { *this }] (bool forceUpdate) {
23752375
ensureGPUProcessConnection().updateMediaConfiguration(forceUpdate);
23762376
});
23772377
#if ENABLE(VP9)
2378-
VP9TestingOverrides::singleton().setConfigurationChangedCallback([this] (bool forceUpdate) {
2378+
VP9TestingOverrides::singleton().setConfigurationChangedCallback([this, protectedThis = Ref { *this }] (bool forceUpdate) {
23792379
ensureGPUProcessConnection().updateMediaConfiguration(forceUpdate);
23802380
});
23812381
#endif

Source/WebKit/WebProcess/WebProcess.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ class WebProcess final : public AuxiliaryProcess {
762762

763763
String m_uiProcessBundleIdentifier;
764764
RefPtr<NetworkProcessConnection> m_networkProcessConnection;
765-
UniqueRef<WebLoaderStrategy> m_webLoaderStrategy;
765+
const UniqueRef<WebLoaderStrategy> m_webLoaderStrategy;
766766
RefPtr<WebFileSystemStorageConnection> m_fileSystemStorageConnection;
767767

768768
#if ENABLE(GPU_PROCESS)
@@ -792,10 +792,10 @@ class WebProcess final : public AuxiliaryProcess {
792792
Ref<RemoteImageDecoderAVFManager> m_remoteImageDecoderAVFManager;
793793
#endif
794794
Ref<WebBroadcastChannelRegistry> m_broadcastChannelRegistry;
795-
Ref<WebCookieJar> m_cookieJar;
795+
const Ref<WebCookieJar> m_cookieJar;
796796
WebSocketChannelManager m_webSocketChannelManager;
797797

798-
std::unique_ptr<LibWebRTCNetwork> m_libWebRTCNetwork;
798+
const std::unique_ptr<LibWebRTCNetwork> m_libWebRTCNetwork;
799799

800800
HashSet<String> m_dnsPrefetchedHosts;
801801
PAL::HysteresisActivity m_dnsPrefetchHystereris;

0 commit comments

Comments
 (0)