Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9d4a23ebe3ea59a1028bb930036be3612d213f7e
      
https://github.com/WebKit/WebKit/commit/9d4a23ebe3ea59a1028bb930036be3612d213f7e
  Author: Chris Dumez <[email protected]>
  Date:   2025-11-16 (Sun, 16 Nov 2025)

  Changed paths:
    M Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorCocoa.mm
    M 
Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorXPCConnection.h
    M 
Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorXPCConnection.mm
    M Source/WTF/WTF.xcodeproj/project.pbxproj
    M Source/WTF/wtf/Forward.h
    M Source/WTF/wtf/OSObjectPtr.h
    M Source/WTF/wtf/TypeTraits.h
    M Source/WTF/wtf/cocoa/Entitlements.mm
    A Source/WTF/wtf/darwin/XPCObjectPtr.h
    M Source/WebCore/platform/VideoReceiverEndpoint.h
    M 
Source/WebKit/GPUProcess/EntryPoint/Cocoa/XPCService/GPUServiceEntryPoint.mm
    M 
Source/WebKit/ModelProcess/EntryPoint/Cocoa/XPCService/ModelServiceEntryPoint.mm
    M 
Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkServiceEntryPoint.mm
    M 
Source/WebKit/NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm
    M Source/WebKit/NetworkProcess/Notifications/WebPushDaemonConnection.h
    M 
Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h
    M 
Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementConnectionCocoa.mm
    M Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.h
    M Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm
    M Source/WebKit/Platform/IPC/Connection.h
    M Source/WebKit/Platform/IPC/DaemonConnection.h
    M Source/WebKit/Platform/IPC/cocoa/DaemonConnectionCocoa.mm
    M Source/WebKit/Platform/cocoa/LayerHostingContext.h
    M Source/WebKit/Platform/cocoa/LayerHostingContext.mm
    M Source/WebKit/Platform/cocoa/XPCUtilities.mm
    M Source/WebKit/Platform/ios/VideoReceiverEndpointMessage.h
    M Source/WebKit/Platform/ios/VideoReceiverEndpointMessage.mm
    M Source/WebKit/Shared/Cocoa/LaunchLogHook.h
    M Source/WebKit/Shared/Cocoa/LaunchLogHook.mm
    M Source/WebKit/Shared/Cocoa/XPCEndpoint.h
    M Source/WebKit/Shared/Cocoa/XPCEndpoint.mm
    M Source/WebKit/Shared/Cocoa/XPCEndpointClient.h
    M Source/WebKit/Shared/Cocoa/XPCEndpointClient.mm
    M Source/WebKit/Shared/Daemon/DaemonUtilities.h
    M Source/WebKit/Shared/Daemon/DaemonUtilities.mm
    M 
Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.h
    M 
Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.mm
    M 
Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm
    M 
Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h
    M 
Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm
    M 
Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm
    M 
Source/WebKit/UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm
    M Source/WebKit/UIProcess/Cocoa/VideoPresentationManagerProxy.mm
    M Source/WebKit/UIProcess/Launcher/ProcessLauncher.h
    M Source/WebKit/UIProcess/Launcher/cocoa/ExtensionProcess.h
    M Source/WebKit/UIProcess/Launcher/cocoa/ExtensionProcess.mm
    M Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm
    M Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
    M Source/WebKit/WebProcess/cocoa/LaunchServicesDatabaseManager.mm
    M Source/WebKit/webpushd/PushClientConnection.h
    M Source/WebKit/webpushd/WebPushDaemon.mm
    M Source/WebKit/webpushd/webpushtool/WebPushToolConnection.h
    M Source/WebKit/webpushd/webpushtool/WebPushToolConnection.mm
    M Source/WebKit/webpushd/webpushtool/WebPushToolMain.mm
    M Tools/Scripts/webkitpy/style/checkers/cpp.py
    M Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
    M Tools/TestWebKitAPI/Tests/WTF/darwin/OSObjectPtr.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/XPCEndpoint.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm
    M Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.mm

  Log Message:
  -----------
  Use xpc_retain() / xpc_release() for XPC objects
https://bugs.webkit.org/show_bug.cgi?id=302524

Reviewed by Darin Adler and Geoffrey Garen.

In our codebase, we currently sometimes use RetainPtr and sometimes
OSObjectPtr to hold XPC objects. This is inconsistent. Technically,
we're supposed to be calling `xpc_retain()` / `xpc_release()` as these
have logic internally to decide whether to call os_retain() / os_release()
or objc_retain() / objc_release(). They also have some extra validation
and special handling for certain XPC types.

As a result, I am introducing a new XPCObjectPtr which is based on
OSObjectPtr but uses traits to call `xpc_retain()` / `xpc_release()`
internally instead of `os_retain()` / `os_release()`. I ported to whole
codebase to use this new XPCObjectPtr type consistently and added a style
checker rule so that we don't regress things in the future.

I am also making OSObjectPtr compatible with hash containers.

* Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorCocoa.mm:
(Inspector::RemoteInspector::setupXPCConnectionIfNeeded):
* Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorXPCConnection.h:
* Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorXPCConnection.mm:
(Inspector::RemoteInspectorXPCConnection::sendMessage):
* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/Forward.h:
* Source/WTF/wtf/OSObjectPtr.h:
(WTF::DefaultOSObjectRetainTraits::retain):
(WTF::DefaultOSObjectRetainTraits::release):
(WTF::OSObjectPtr::~OSObjectPtr):
(WTF::OSObjectPtr::OSObjectPtr):
(WTF::OSObjectPtr::isHashTableDeletedValue const):
(WTF::OSObjectPtr::operator=):
(WTF::OSObjectPtr::hashTableDeletedValue):
(WTF::operator==):
(WTF::adoptOSObject):
(WTF::lazyInitialize):
(WTF::retainOSObject): Deleted.
(WTF::releaseOSObject): Deleted.
* Source/WTF/wtf/TypeTraits.h:
* Source/WTF/wtf/cocoa/Entitlements.mm:
(WTF::hasEntitlement):
* Source/WTF/wtf/darwin/XPCObjectPtr.h: Copied from 
Source/WebKit/Shared/Cocoa/LaunchLogHook.h.
(WTF::XPCObjectRetainTraits::retain):
(WTF::XPCObjectRetainTraits::release):
* Source/WebCore/platform/VideoReceiverEndpoint.h:
* Source/WebKit/GPUProcess/EntryPoint/Cocoa/XPCService/GPUServiceEntryPoint.mm:
(WebKit::GPUServiceInitializerDelegate::GPUServiceInitializerDelegate):
* 
Source/WebKit/ModelProcess/EntryPoint/Cocoa/XPCService/ModelServiceEntryPoint.mm:
(WebKit::ModelServiceInitializerDelegate::ModelServiceInitializerDelegate):
* 
Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkServiceEntryPoint.mm:
(WebKit::NetworkServiceInitializerDelegate::NetworkServiceInitializerDelegate):
* 
Source/WebKit/NetworkProcess/Notifications/Cocoa/WebPushDaemonConnectionCocoa.mm:
(WebKit::WebPushD::messageDictionaryFromEncoder):
* Source/WebKit/NetworkProcess/Notifications/WebPushDaemonConnection.h:
* 
Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h:
* 
Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementConnectionCocoa.mm:
(WebKit::PCM::Connection::dictionaryFromMessage const):
* Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.h:
* Source/WebKit/NetworkProcess/cocoa/LaunchServicesDatabaseObserver.mm:
(WebKit::LaunchServicesDatabaseObserver::LaunchServicesDatabaseObserver):
(WebKit::LaunchServicesDatabaseObserver::startObserving):
* Source/WebKit/Platform/IPC/Connection.h:
(IPC::Connection::Identifier::Identifier):
(IPC::Connection::protectedXPCConnection const):
* Source/WebKit/Platform/IPC/DaemonConnection.h:
(WebKit::Daemon::Connection::create):
(WebKit::Daemon::Connection::Connection):
* Source/WebKit/Platform/IPC/cocoa/DaemonConnectionCocoa.mm:
(WebKit::Daemon::ConnectionToMachService<Traits>::initializeConnectionIfNeeded 
const):
* Source/WebKit/Platform/cocoa/LayerHostingContext.h:
* Source/WebKit/Platform/cocoa/LayerHostingContext.mm:
(WebKit::LayerHostingContext::xpcRepresentation const):
(WebKit::LayerHostingContext::createHostingUpdateCoordinator):
(WebKit::LayerHostingContext::createHostingHandle):
* Source/WebKit/Platform/cocoa/XPCUtilities.mm:
(WebKit::terminateWithReason):
* Source/WebKit/Platform/ios/VideoReceiverEndpointMessage.h:
* Source/WebKit/Platform/ios/VideoReceiverEndpointMessage.mm:
(WebKit::VideoReceiverEndpointMessage::encode const):
(WebKit::VideoReceiverSwapEndpointsMessage::encode const):
* Source/WebKit/Shared/Cocoa/LaunchLogHook.h:
* Source/WebKit/Shared/Cocoa/LaunchLogHook.mm:
(WebKit::LaunchLogHook::initialize):
(WebKit::LaunchLogHook::disable):
* Source/WebKit/Shared/Cocoa/XPCEndpoint.h:
* Source/WebKit/Shared/Cocoa/XPCEndpoint.mm:
(WebKit::XPCEndpoint::XPCEndpoint):
(WebKit::XPCEndpoint::sendEndpointToConnection):
(WebKit::XPCEndpoint::endpoint const):
* Source/WebKit/Shared/Cocoa/XPCEndpointClient.h:
* Source/WebKit/Shared/Cocoa/XPCEndpointClient.mm:
(WebKit::XPCEndpointClient::setEndpoint):
(WebKit::XPCEndpointClient::connection):
* Source/WebKit/Shared/Daemon/DaemonUtilities.h:
* Source/WebKit/Shared/Daemon/DaemonUtilities.mm:
(WebKit::startListeningForMachServiceConnections):
(WebKit::vectorToXPCData):
(WebKit::encoderToXPCData):
* 
Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.h:
* 
Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonConnectionSet.mm:
(WebKit::PCM::DaemonConnectionSet::broadcastConsoleMessage):
* Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm:
(WebKit::CompletionHandler<void):
(WebKit::registerScheduledActivityHandler):
* 
Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:
(WebKit::XPCServiceInitializer):
* 
Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::XPCServiceInitializerDelegate):
* Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
(WebKit::XPCServiceEventHandler):
(WebKit::XPCServiceMain):
* 
Source/WebKit/UIProcess/Authentication/cocoa/AuthenticationChallengeProxyCocoa.mm:
(WebKit::AuthenticationChallengeProxy::sendClientCertificateCredentialOverXpc):
* Source/WebKit/UIProcess/Cocoa/VideoPresentationManagerProxy.mm:
(WebKit::VideoPresentationManagerProxy::setVideoLayerFrame):
* Source/WebKit/UIProcess/Launcher/ProcessLauncher.h:
* Source/WebKit/UIProcess/Launcher/cocoa/ExtensionProcess.h:
* Source/WebKit/UIProcess/Launcher/cocoa/ExtensionProcess.mm:
(WebKit::ExtensionProcess::makeLibXPCConnection const):
* Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm:
(WebKit::ProcessLauncher::launchProcess):
(WebKit::ProcessLauncher::finishLaunchingProcess):
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.h:
* Source/WebKit/WebProcess/cocoa/LaunchServicesDatabaseManager.mm:
(WebKit::LaunchServicesDatabaseManager::didConnect):
* Source/WebKit/webpushd/PushClientConnection.h:
* Source/WebKit/webpushd/WebPushDaemon.mm:
(WebPushD::WebPushDaemon::connectionEventHandler):
* Source/WebKit/webpushd/webpushtool/WebPushToolConnection.h:
* Source/WebKit/webpushd/webpushtool/WebPushToolConnection.mm:
(WebPushTool::Connection::connectToService):
(WebPushTool::messageDictionaryFromEncoder):
* Source/WebKit/webpushd/webpushtool/WebPushToolMain.mm:
(registerDaemonWithLaunchD):
* Tools/Scripts/webkitpy/style/checkers/cpp.py:
(check_wtf_xpc_object_ptr):
(check_style):
(CppChecker):
* Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py:
(WebKitStyleTest.test_wtf_xpc_object_ptr):
* Tools/TestWebKitAPI/Tests/WTF/darwin/OSObjectPtr.cpp:
(TestWebKitAPI::TEST(OS_OBJECT_PTR_TEST_NAME, RetainRelease)):
(TestWebKitAPI::TEST(OS_OBJECT_PTR_TEST_NAME, LeakRef)):
* Tools/TestWebKitAPI/Tests/WebKit/XPCEndpoint.mm:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
(TestWebKitAPI::attemptConnectionInProcessWithoutEntitlement):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm:
(TestWebKitAPI::WebPushXPCConnectionMessageSender::messageDictionaryFromEncoder 
const):
(TestWebKitAPI::createAndConfigureConnectionToService):
(TestWebKitAPI::TEST(WebPushD, BasicCommunication)):
* Tools/TestWebKitAPI/cocoa/DaemonTestUtilities.mm:
(TestWebKitAPI::convertArrayToXPC):
(TestWebKitAPI::convertDictionaryToXPC):

Canonical link: https://commits.webkit.org/303104@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to