<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[168584] trunk/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/168584">168584</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2014-05-10 15:17:24 -0700 (Sat, 10 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>WebKit2 is leaking an xpc_connection per web process it creates
https://bugs.webkit.org/show_bug.cgi?id=132785
<rdar://problem/14912160>
Reviewed by Sam Weinig.
Introduce an IPC::XPCPtr smart pointer class and use it for XPC connections inside Connection::Identifier and Connection itself.
Make sure we always adopt any connections that are created.
* DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm:
(DatabaseServiceInitializer):
* NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm:
(WebKit::NetworkServiceInitializerDelegate::NetworkServiceInitializerDelegate):
(NetworkServiceInitializer):
* Platform/IPC/Connection.h:
(IPC::Connection::Identifier::Identifier):
(IPC::Connection::xpcConnection):
* Platform/IPC/mac/ConnectionMac.mm:
(IPC::Connection::platformInvalidate):
(IPC::Connection::platformInitialize):
(IPC::Connection::getAuditToken):
* Platform/IPC/mac/XPCPtr.h: Added.
(IPC::XPCPtr::XPCPtr):
(IPC::XPCPtr::~XPCPtr):
(IPC::XPCPtr::get):
(IPC::XPCPtr::operator!):
(IPC::XPCPtr::operator=):
(IPC::adoptXPC):
* PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm:
(WebKit::PluginServiceInitializerDelegate::PluginServiceInitializerDelegate):
(PluginServiceInitializer):
* Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm:
(WebKit::BootstrapMain):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
(WebKit::XPCServiceInitializerDelegate::XPCServiceInitializerDelegate):
(WebKit::XPCServiceInitializer):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::hasEntitlement):
(WebKit::XPCServiceInitializerDelegate::isClientSandboxed):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm:
(WebKit::XPCServiceEventHandler):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
(WebKit::XPCServiceEventHandler):
* UIProcess/Launcher/ProcessLauncher.cpp:
(WebKit::ProcessLauncher::didFinishLaunchingProcess):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::connectToService):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm:
(WebContentServiceInitializer):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessEntryPointmacXPCServiceDatabaseServiceEntryPointmm">trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessEntryPointmacXPCServiceNetworkServiceEntryPointmm">trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCConnectionh">trunk/Source/WebKit2/Platform/IPC/Connection.h</a></li>
<li><a href="#trunkSourceWebKit2PlatformIPCmacConnectionMacmm">trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm</a></li>
<li><a href="#trunkSourceWebKit2PluginProcessEntryPointmacXPCServicePluginServiceEntryPointmm">trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacLegacyProcessChildProcessMainmm">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointh">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceMainDevelopmentmm">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceMainmm">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessLauncherProcessLaunchercpp">trunk/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessLaunchermacProcessLauncherMacmm">trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessEntryPointmacXPCServiceWebContentServiceEntryPointmm">trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2PlatformIPCmacXPCPtrh">trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/ChangeLog        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -1,5 +1,59 @@
</span><span class="cx"> 2014-05-10 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><ins>+ WebKit2 is leaking an xpc_connection per web process it creates
+ https://bugs.webkit.org/show_bug.cgi?id=132785
+ <rdar://problem/14912160>
+
+ Reviewed by Sam Weinig.
+
+ Introduce an IPC::XPCPtr smart pointer class and use it for XPC connections inside Connection::Identifier and Connection itself.
+
+ Make sure we always adopt any connections that are created.
+
+ * DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm:
+ (DatabaseServiceInitializer):
+ * NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm:
+ (WebKit::NetworkServiceInitializerDelegate::NetworkServiceInitializerDelegate):
+ (NetworkServiceInitializer):
+ * Platform/IPC/Connection.h:
+ (IPC::Connection::Identifier::Identifier):
+ (IPC::Connection::xpcConnection):
+ * Platform/IPC/mac/ConnectionMac.mm:
+ (IPC::Connection::platformInvalidate):
+ (IPC::Connection::platformInitialize):
+ (IPC::Connection::getAuditToken):
+ * Platform/IPC/mac/XPCPtr.h: Added.
+ (IPC::XPCPtr::XPCPtr):
+ (IPC::XPCPtr::~XPCPtr):
+ (IPC::XPCPtr::get):
+ (IPC::XPCPtr::operator!):
+ (IPC::XPCPtr::operator=):
+ (IPC::adoptXPC):
+ * PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm:
+ (WebKit::PluginServiceInitializerDelegate::PluginServiceInitializerDelegate):
+ (PluginServiceInitializer):
+ * Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm:
+ (WebKit::BootstrapMain):
+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
+ (WebKit::XPCServiceInitializerDelegate::XPCServiceInitializerDelegate):
+ (WebKit::XPCServiceInitializer):
+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
+ (WebKit::XPCServiceInitializerDelegate::hasEntitlement):
+ (WebKit::XPCServiceInitializerDelegate::isClientSandboxed):
+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm:
+ (WebKit::XPCServiceEventHandler):
+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
+ (WebKit::XPCServiceEventHandler):
+ * UIProcess/Launcher/ProcessLauncher.cpp:
+ (WebKit::ProcessLauncher::didFinishLaunchingProcess):
+ * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+ (WebKit::connectToService):
+ * WebKit2.xcodeproj/project.pbxproj:
+ * WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm:
+ (WebContentServiceInitializer):
+
+2014-05-10 Anders Carlsson <andersca@apple.com>
+
</ins><span class="cx"> Simplify createDataAvailableSource
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=132782
</span><span class="cx"> <rdar://problem/16815202>
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessEntryPointmacXPCServiceDatabaseServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -36,5 +36,5 @@
</span><span class="cx">
</span><span class="cx"> void DatabaseServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
</span><span class="cx"> {
</span><del>- XPCServiceInitializer<DatabaseProcess, XPCServiceInitializerDelegate>(connection, initializerMessage);
</del><ins>+ XPCServiceInitializer<DatabaseProcess, XPCServiceInitializerDelegate>(IPC::adoptXPC(connection), initializerMessage);
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessEntryPointmacXPCServiceNetworkServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -34,8 +34,8 @@
</span><span class="cx">
</span><span class="cx"> class NetworkServiceInitializerDelegate : public XPCServiceInitializerDelegate {
</span><span class="cx"> public:
</span><del>- NetworkServiceInitializerDelegate(xpc_connection_t connection, xpc_object_t initializerMessage)
- : XPCServiceInitializerDelegate(connection, initializerMessage)
</del><ins>+ NetworkServiceInitializerDelegate(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
+ : XPCServiceInitializerDelegate(std::move(connection), initializerMessage)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> };
</span><span class="lines">@@ -53,6 +53,6 @@
</span><span class="cx"> // the this process don't try to insert the shim and crash.
</span><span class="cx"> EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/SecItemShim.dylib");
</span><span class="cx">
</span><del>- XPCServiceInitializer<NetworkProcess, NetworkServiceInitializerDelegate>(connection, initializerMessage);
</del><ins>+ XPCServiceInitializer<NetworkProcess, NetworkServiceInitializerDelegate>(IPC::adoptXPC(connection), initializerMessage);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/Connection.h (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/Connection.h        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.h        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -41,8 +41,8 @@
</span><span class="cx"> #include <wtf/text/CString.h>
</span><span class="cx">
</span><span class="cx"> #if OS(DARWIN)
</span><ins>+#include "XPCPtr.h"
</ins><span class="cx"> #include <mach/mach_port.h>
</span><del>-#include <xpc/xpc.h>
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(GTK) || PLATFORM(EFL)
</span><span class="lines">@@ -92,27 +92,25 @@
</span><span class="cx"> struct Identifier {
</span><span class="cx"> Identifier()
</span><span class="cx"> : port(MACH_PORT_NULL)
</span><del>- , xpcConnection(0)
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Identifier(mach_port_t port)
</span><span class="cx"> : port(port)
</span><del>- , xpcConnection(0)
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>- Identifier(mach_port_t port, xpc_connection_t xpcConnection)
</del><ins>+ Identifier(mach_port_t port, XPCPtr<xpc_connection_t> xpcConnection)
</ins><span class="cx"> : port(port)
</span><del>- , xpcConnection(xpcConnection)
</del><ins>+ , xpcConnection(std::move(xpcConnection))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> mach_port_t port;
</span><del>- xpc_connection_t xpcConnection;
</del><ins>+ XPCPtr<xpc_connection_t> xpcConnection;
</ins><span class="cx"> };
</span><span class="cx"> static bool identifierIsNull(Identifier identifier) { return identifier.port == MACH_PORT_NULL; }
</span><del>- xpc_connection_t xpcConnection() { return m_xpcConnection; }
</del><ins>+ xpc_connection_t xpcConnection() { return m_xpcConnection.get(); }
</ins><span class="cx"> bool getAuditToken(audit_token_t&);
</span><span class="cx"> #elif USE(UNIX_DOMAIN_SOCKETS)
</span><span class="cx"> typedef int Identifier;
</span><span class="lines">@@ -298,7 +296,7 @@
</span><span class="cx"> dispatch_source_t m_exceptionPortDataAvailableSource;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- xpc_connection_t m_xpcConnection;
</del><ins>+ XPCPtr<xpc_connection_t> m_xpcConnection;
</ins><span class="cx">
</span><span class="cx"> #elif USE(UNIX_DOMAIN_SOCKETS)
</span><span class="cx"> // Called on the connection queue.
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCmacConnectionMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -80,10 +80,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- if (m_xpcConnection) {
- xpc_release(m_xpcConnection);
- m_xpcConnection = 0;
- }
</del><ins>+ m_xpcConnection = nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Connection::platformInitialize(Identifier identifier)
</span><span class="lines">@@ -105,10 +102,6 @@
</span><span class="cx"> m_receivePortDataAvailableSource = nullptr;
</span><span class="cx">
</span><span class="cx"> m_xpcConnection = identifier.xpcConnection;
</span><del>- // FIXME: Instead of explicitly retaining the connection here, Identifier::xpcConnection
- // should just be a smart pointer.
- if (m_xpcConnection)
- xpc_retain(m_xpcConnection);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template<typename Function>
</span><span class="lines">@@ -520,13 +513,13 @@
</span><span class="cx"> {
</span><span class="cx"> return Identifier(m_isServer ? m_receivePort : m_sendPort, m_xpcConnection);
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> bool Connection::getAuditToken(audit_token_t& auditToken)
</span><span class="cx"> {
</span><span class="cx"> if (!m_xpcConnection)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- xpc_connection_get_audit_token(m_xpcConnection, &auditToken);
</del><ins>+ xpc_connection_get_audit_token(m_xpcConnection.get(), &auditToken);
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCmacXPCPtrhfromrev168583trunkSourceWebKit2NetworkProcessEntryPointmacXPCServiceNetworkServiceEntryPointmm"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h (from rev 168583, trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm) (0 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h         (rev 0)
+++ trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -0,0 +1,104 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef XPCPtr_h
+#define XPCPtr_h
+
+#include <xpc/xpc.h>
+
+namespace IPC {
+
+struct AdoptXPC { };
+
+template<typename T> class XPCPtr {
+public:
+ XPCPtr()
+ : m_ptr(nullptr)
+ {
+ }
+
+ XPCPtr(AdoptXPC, T ptr)
+ : m_ptr(ptr)
+ {
+ }
+
+ ~XPCPtr()
+ {
+ if (m_ptr)
+ xpc_release(m_ptr);
+ }
+
+ T get() const { return m_ptr; }
+
+ bool operator!() const { return !m_ptr; }
+
+ XPCPtr(const XPCPtr& other)
+ : m_ptr(other.m_ptr)
+ {
+ if (m_ptr)
+ xpc_retain(m_ptr);
+ }
+
+ XPCPtr(XPCPtr&& other)
+ : m_ptr(other.m_ptr)
+ {
+ other.m_ptr = nullptr;
+ }
+
+ XPCPtr& operator=(const XPCPtr& other)
+ {
+ T optr = other.get();
+ if (optr)
+ xpc_retain(optr);
+
+ T ptr = m_ptr;
+ m_ptr = optr;
+
+ if (ptr)
+ xpc_release(ptr);
+
+ return *this;
+ }
+
+ XPCPtr& operator=(std::nullptr_t)
+ {
+ if (m_ptr)
+ xpc_release(m_ptr);
+ m_ptr = nullptr;
+
+ return *this;
+ }
+private:
+ T m_ptr;
+};
+
+template<typename T> inline XPCPtr<T> adoptXPC(T ptr)
+{
+ return XPCPtr<T>(AdoptXPC { }, ptr);
+}
+
+} // namespace IPC
+
+#endif // XPCPtr_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2PluginProcessEntryPointmacXPCServicePluginServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -37,8 +37,8 @@
</span><span class="cx">
</span><span class="cx"> class PluginServiceInitializerDelegate : public XPCServiceInitializerDelegate {
</span><span class="cx"> public:
</span><del>- PluginServiceInitializerDelegate(xpc_connection_t connection, xpc_object_t initializerMessage)
- : XPCServiceInitializerDelegate(connection, initializerMessage)
</del><ins>+ PluginServiceInitializerDelegate(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
+ : XPCServiceInitializerDelegate(std::move(connection), initializerMessage)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -76,6 +76,6 @@
</span><span class="cx"> // spawned by the PluginProcess don't try to insert the shim and crash.
</span><span class="cx"> EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/PluginProcessShim.dylib");
</span><span class="cx">
</span><del>- XPCServiceInitializer<PluginProcess, PluginServiceInitializerDelegate>(connection, initializerMessage);
</del><ins>+ XPCServiceInitializer<PluginProcess, PluginServiceInitializerDelegate>(IPC::adoptXPC(connection), initializerMessage);
</ins><span class="cx"> #endif // ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacLegacyProcessChildProcessMainmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessMain.mm        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx">
</span><span class="cx"> static void* frameworkLibrary = dlopen(argv[1], RTLD_NOW);
</span><span class="cx"> if (!frameworkLibrary) {
</span><del>- NSLog(@"Unable to load WebKit2.framework: %s\n", dlerror());
</del><ins>+ NSLog(@"Unable to load WebKit.framework: %s\n", dlerror());
</ins><span class="cx"> return EXIT_FAILURE;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">
</span><span class="cx"> bootstrapMainFunction = reinterpret_cast<BootstrapMainFunction>(dlsym(frameworkLibrary, [entryPointFunctionName UTF8String]));
</span><span class="cx"> if (!bootstrapMainFunction) {
</span><del>- NSLog(@"Unable to find entry point '%s' in WebKit2.framework: %s\n", [entryPointFunctionName UTF8String], dlerror());
</del><ins>+ NSLog(@"Unable to find entry point '%s' in WebKit.framework: %s\n", [entryPointFunctionName UTF8String], dlerror());
</ins><span class="cx"> return EXIT_FAILURE;
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -28,14 +28,14 @@
</span><span class="cx">
</span><span class="cx"> #import "ChildProcess.h"
</span><span class="cx"> #import "WebKit2Initialize.h"
</span><del>-#import <xpc/xpc.h>
</del><ins>+#import "XPCPtr.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="cx"> class XPCServiceInitializerDelegate {
</span><span class="cx"> public:
</span><del>- XPCServiceInitializerDelegate(xpc_connection_t connection, xpc_object_t initializerMessage)
- : m_connection(connection)
</del><ins>+ XPCServiceInitializerDelegate(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
+ : m_connection(std::move(connection))
</ins><span class="cx"> , m_initializerMessage(initializerMessage)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -55,14 +55,14 @@
</span><span class="cx"> bool hasEntitlement(const char* entitlement);
</span><span class="cx"> bool isClientSandboxed();
</span><span class="cx">
</span><del>- xpc_connection_t m_connection;
</del><ins>+ IPC::XPCPtr<xpc_connection_t> m_connection;
</ins><span class="cx"> xpc_object_t m_initializerMessage;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> template<typename XPCServiceType, typename XPCServiceInitializerDelegateType>
</span><del>-void XPCServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
</del><ins>+void XPCServiceInitializer(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
</ins><span class="cx"> {
</span><del>- XPCServiceInitializerDelegateType delegate(connection, initializerMessage);
</del><ins>+ XPCServiceInitializerDelegateType delegate(std::move(connection), initializerMessage);
</ins><span class="cx">
</span><span class="cx"> // We don't want XPC to be in charge of whether the process should be terminated or not,
</span><span class="cx"> // so ensure that we have an outstanding transaction here.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -95,20 +95,16 @@
</span><span class="cx">
</span><span class="cx"> bool XPCServiceInitializerDelegate::hasEntitlement(const char* entitlement)
</span><span class="cx"> {
</span><del>- xpc_object_t value = xpc_connection_copy_entitlement_value(m_connection, entitlement);
</del><ins>+ auto value = IPC::adoptXPC(xpc_connection_copy_entitlement_value(m_connection.get(), entitlement));
</ins><span class="cx"> if (!value)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- bool result = xpc_get_type(value) == XPC_TYPE_BOOL && xpc_bool_get_value(value);
-
- xpc_release(value);
-
- return result;
</del><ins>+ return xpc_get_type(value.get()) == XPC_TYPE_BOOL && xpc_bool_get_value(value.get());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool XPCServiceInitializerDelegate::isClientSandboxed()
</span><span class="cx"> {
</span><del>- pid_t clientPID = xpc_connection_get_pid(m_connection);
</del><ins>+ pid_t clientPID = xpc_connection_get_pid(m_connection.get());
</ins><span class="cx">
</span><span class="cx"> return sandbox_check(clientPID, nullptr, SANDBOX_FILTER_NONE);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceMainDevelopmentmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #import <spawn.h>
</span><span class="cx"> #import <stdio.h>
</span><span class="cx"> #import <stdlib.h>
</span><del>-#import <xpc/xpc.h>
</del><ins>+#import "XPCPtr.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx"> if (!strcmp(xpc_dictionary_get_string(event, "message-name"), "bootstrap")) {
</span><span class="cx"> static void* frameworkLibrary = dlopen(xpc_dictionary_get_string(event, "framework-executable-path"), RTLD_NOW);
</span><span class="cx"> if (!frameworkLibrary) {
</span><del>- NSLog(@"Unable to load WebKit2.framework at path: %s (Error: %s)", xpc_dictionary_get_string(event, "framework-executable-path"), dlerror());
</del><ins>+ NSLog(@"Unable to load WebKit.framework at path: %s (Error: %s)", xpc_dictionary_get_string(event, "framework-executable-path"), dlerror());
</ins><span class="cx"> exit(EXIT_FAILURE);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -136,10 +136,9 @@
</span><span class="cx"> exit(EXIT_FAILURE);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- xpc_object_t reply = xpc_dictionary_create_reply(event);
- xpc_dictionary_set_string(reply, "message-name", "process-finished-launching");
- xpc_connection_send_message(xpc_dictionary_get_remote_connection(event), reply);
- xpc_release(reply);
</del><ins>+ auto reply = IPC::adoptXPC(xpc_dictionary_create_reply(event));
+ xpc_dictionary_set_string(reply.get(), "message-name", "process-finished-launching");
+ xpc_connection_send_message(xpc_dictionary_get_remote_connection(event), reply.get());
</ins><span class="cx">
</span><span class="cx"> dup2(xpc_dictionary_dup_fd(event, "stdout"), STDOUT_FILENO);
</span><span class="cx"> dup2(xpc_dictionary_dup_fd(event, "stderr"), STDERR_FILENO);
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceMainmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> #import <CoreFoundation/CoreFoundation.h>
</span><del>-#import <xpc/xpc.h>
</del><ins>+#import "XPCPtr.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="lines">@@ -48,14 +48,13 @@
</span><span class="cx"> typedef void (*InitializerFunction)(xpc_connection_t, xpc_object_t);
</span><span class="cx"> InitializerFunction initializerFunctionPtr = reinterpret_cast<InitializerFunction>(CFBundleGetFunctionPointerForName(webKitBundle, entryPointFunctionName));
</span><span class="cx"> if (!initializerFunctionPtr) {
</span><del>- NSLog(@"Unable to find entry point in WebKit2.framework with name: %@", (NSString *)entryPointFunctionName);
</del><ins>+ NSLog(@"Unable to find entry point in WebKit.framework with name: %@", (NSString *)entryPointFunctionName);
</ins><span class="cx"> exit(EXIT_FAILURE);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- xpc_object_t reply = xpc_dictionary_create_reply(event);
- xpc_dictionary_set_string(reply, "message-name", "process-finished-launching");
- xpc_connection_send_message(xpc_dictionary_get_remote_connection(event), reply);
- xpc_release(reply);
</del><ins>+ auto reply = IPC::adoptXPC(xpc_dictionary_create_reply(event));
+ xpc_dictionary_set_string(reply.get(), "message-name", "process-finished-launching");
+ xpc_connection_send_message(xpc_dictionary_get_remote_connection(event), reply.get());
</ins><span class="cx">
</span><span class="cx"> initializerFunctionPtr(peer, event);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessLauncherProcessLaunchercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -57,11 +57,6 @@
</span><span class="cx"> #if OS(DARWIN)
</span><span class="cx"> if (identifier.port)
</span><span class="cx"> mach_port_mod_refs(mach_task_self(), identifier.port, MACH_PORT_RIGHT_RECEIVE, -1);
</span><del>-
- if (identifier.xpcConnection) {
- xpc_release(identifier.xpcConnection);
- identifier.xpcConnection = 0;
- }
</del><span class="cx"> #endif
</span><span class="cx"> return;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessLaunchermacProcessLauncherMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -172,21 +172,20 @@
</span><span class="cx">
</span><span class="cx"> static void connectToService(const ProcessLauncher::LaunchOptions& launchOptions, bool forDevelopment, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction, UUIDHolder* instanceUUID)
</span><span class="cx"> {
</span><del>- // Create a connection to the WebKit2 XPC service.
- xpc_connection_t connection = xpc_connection_create(serviceName(launchOptions, forDevelopment), 0);
- xpc_connection_set_instance(connection, instanceUUID->uuid);
</del><ins>+ // Create a connection to the WebKit XPC service.
+ auto connection = IPC::adoptXPC(xpc_connection_create(serviceName(launchOptions, forDevelopment), 0));
+ xpc_connection_set_instance(connection.get(), instanceUUID->uuid);
</ins><span class="cx">
</span><span class="cx"> // XPC requires having an event handler, even if it is not used.
</span><del>- xpc_connection_set_event_handler(connection, ^(xpc_object_t event) { });
- xpc_connection_resume(connection);
</del><ins>+ xpc_connection_set_event_handler(connection.get(), ^(xpc_object_t event) { });
+ xpc_connection_resume(connection.get());
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(NETWORK_PROCESS) && !PLATFORM(IOS)
</span><span class="cx"> // Leak a boost onto the NetworkProcess.
</span><span class="cx"> if (launchOptions.processType == ProcessLauncher::NetworkProcess) {
</span><del>- xpc_object_t preBootstrapMessage = xpc_dictionary_create(0, 0, 0);
- xpc_dictionary_set_string(preBootstrapMessage, "message-name", "pre-bootstrap");
- xpc_connection_send_message(connection, preBootstrapMessage);
- xpc_release(preBootstrapMessage);
</del><ins>+ auto preBootstrapMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
+ xpc_dictionary_set_string(preBootstrapMessage.get(), "message-name", "pre-bootstrap");
+ xpc_connection_send_message(connection.get(), preBootstrapMessage.get());
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -200,29 +199,28 @@
</span><span class="cx"> NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
</span><span class="cx"> CString clientIdentifier = bundleIdentifier ? String([[NSBundle mainBundle] bundleIdentifier]).utf8() : *_NSGetProgname();
</span><span class="cx">
</span><del>- xpc_object_t bootstrapMessage = xpc_dictionary_create(0, 0, 0);
- xpc_dictionary_set_string(bootstrapMessage, "message-name", "bootstrap");
- xpc_dictionary_set_string(bootstrapMessage, "framework-executable-path", [[[NSBundle bundleWithIdentifier:@"com.apple.WebKit"] executablePath] fileSystemRepresentation]);
- xpc_dictionary_set_mach_send(bootstrapMessage, "server-port", listeningPort);
- xpc_dictionary_set_string(bootstrapMessage, "client-identifier", clientIdentifier.data());
- xpc_dictionary_set_string(bootstrapMessage, "ui-process-name", [[[NSProcessInfo processInfo] processName] UTF8String]);
</del><ins>+ auto bootstrapMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
+ xpc_dictionary_set_string(bootstrapMessage.get(), "message-name", "bootstrap");
+ xpc_dictionary_set_string(bootstrapMessage.get(), "framework-executable-path", [[[NSBundle bundleWithIdentifier:@"com.apple.WebKit"] executablePath] fileSystemRepresentation]);
+ xpc_dictionary_set_mach_send(bootstrapMessage.get(), "server-port", listeningPort);
+ xpc_dictionary_set_string(bootstrapMessage.get(), "client-identifier", clientIdentifier.data());
+ xpc_dictionary_set_string(bootstrapMessage.get(), "ui-process-name", [[[NSProcessInfo processInfo] processName] UTF8String]);
</ins><span class="cx">
</span><span class="cx"> if (forDevelopment) {
</span><del>- xpc_dictionary_set_fd(bootstrapMessage, "stdout", STDOUT_FILENO);
- xpc_dictionary_set_fd(bootstrapMessage, "stderr", STDERR_FILENO);
</del><ins>+ xpc_dictionary_set_fd(bootstrapMessage.get(), "stdout", STDOUT_FILENO);
+ xpc_dictionary_set_fd(bootstrapMessage.get(), "stderr", STDERR_FILENO);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- xpc_object_t extraInitializationData = xpc_dictionary_create(0, 0, 0);
- HashMap<String, String>::const_iterator it = launchOptions.extraInitializationData.begin();
- HashMap<String, String>::const_iterator end = launchOptions.extraInitializationData.end();
- for (; it != end; ++it)
- xpc_dictionary_set_string(extraInitializationData, it->key.utf8().data(), it->value.utf8().data());
- xpc_dictionary_set_value(bootstrapMessage, "extra-initialization-data", extraInitializationData);
- xpc_release(extraInitializationData);
</del><ins>+ auto extraInitializationData = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
</ins><span class="cx">
</span><ins>+ for (const auto& keyValuePair : launchOptions.extraInitializationData)
+ xpc_dictionary_set_string(extraInitializationData.get(), keyValuePair.key.utf8().data(), keyValuePair.value.utf8().data());
+
+ xpc_dictionary_set_value(bootstrapMessage.get(), "extra-initialization-data", extraInitializationData.get());
+
</ins><span class="cx"> that->ref();
</span><span class="cx">
</span><del>- xpc_connection_send_message_with_reply(connection, bootstrapMessage, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(xpc_object_t reply) {
</del><ins>+ xpc_connection_send_message_with_reply(connection.get(), bootstrapMessage.get(), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(xpc_object_t reply) {
</ins><span class="cx"> xpc_type_t type = xpc_get_type(reply);
</span><span class="cx"> if (type == XPC_TYPE_ERROR) {
</span><span class="cx"> // We failed to launch. Release the send right.
</span><span class="lines">@@ -237,15 +235,14 @@
</span><span class="cx"> ASSERT(!strcmp(xpc_dictionary_get_string(reply, "message-name"), "process-finished-launching"));
</span><span class="cx">
</span><span class="cx"> // The process has finished launching, grab the pid from the connection.
</span><del>- pid_t processIdentifier = xpc_connection_get_pid(connection);
</del><ins>+ pid_t processIdentifier = xpc_connection_get_pid(connection.get());
</ins><span class="cx">
</span><del>- // We've finished launching the process, message back to the main run loop.
</del><ins>+ // We've finished launching the process, message back to the main run loop. This takes ownership of the connection.
</ins><span class="cx"> RunLoop::main().dispatch(bind(didFinishLaunchingProcessFunction, that, processIdentifier, IPC::Connection::Identifier(listeningPort, connection)));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> that->deref();
</span><span class="cx"> });
</span><del>- xpc_release(bootstrapMessage);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void connectToReExecService(const ProcessLauncher::LaunchOptions& launchOptions, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction)
</span><span class="lines">@@ -257,6 +254,8 @@
</span><span class="cx"> // FIXME: This UUID should be stored on the ChildProcessProxy.
</span><span class="cx"> RefPtr<UUIDHolder> instanceUUID = UUIDHolder::create();
</span><span class="cx">
</span><ins>+ // FIXME: It would be nice if we could use XPCPtr for this connection as well, but we'd have to be careful
+ // not to introduce any retain cycles in the call to xpc_connection_set_event_handler below.
</ins><span class="cx"> xpc_connection_t reExecConnection = xpc_connection_create(serviceName(launchOptions, true), 0);
</span><span class="cx"> xpc_connection_set_instance(reExecConnection, instanceUUID->uuid);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -380,6 +380,7 @@
</span><span class="cx">                 1AC86FF4130B46D3002C1257 /* WKPluginSiteDataManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC86FF2130B46D3002C1257 /* WKPluginSiteDataManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1AC8702D130B49A2002C1257 /* WebPluginSiteDataManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC8702B130B49A2002C1257 /* WebPluginSiteDataManager.h */; };
</span><span class="cx">                 1AC8702E130B49A2002C1257 /* WebPluginSiteDataManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC8702C130B49A2002C1257 /* WebPluginSiteDataManager.cpp */; };
</span><ins>+                1ACB7987191ECADD006A6A61 /* XPCPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACB7986191ECADD006A6A61 /* XPCPtr.h */; };
</ins><span class="cx">                 1ACECD2417162DB1001FC9EF /* StorageAreaMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ACECD2217162DB1001FC9EF /* StorageAreaMap.cpp */; };
</span><span class="cx">                 1ACECD2517162DB1001FC9EF /* StorageAreaMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACECD2317162DB1001FC9EF /* StorageAreaMap.h */; };
</span><span class="cx">                 1AD01BC81905D37E00C9C45F /* _WKErrorRecoveryAttempting.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AD01BC61905D37E00C9C45F /* _WKErrorRecoveryAttempting.mm */; };
</span><span class="lines">@@ -2216,6 +2217,7 @@
</span><span class="cx">                 1AC86FF2130B46D3002C1257 /* WKPluginSiteDataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPluginSiteDataManager.h; sourceTree = "<group>"; };
</span><span class="cx">                 1AC8702B130B49A2002C1257 /* WebPluginSiteDataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPluginSiteDataManager.h; sourceTree = "<group>"; };
</span><span class="cx">                 1AC8702C130B49A2002C1257 /* WebPluginSiteDataManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPluginSiteDataManager.cpp; sourceTree = "<group>"; };
</span><ins>+                1ACB7986191ECADD006A6A61 /* XPCPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPCPtr.h; sourceTree = "<group>"; };
</ins><span class="cx">                 1ACECD2217162DB1001FC9EF /* StorageAreaMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageAreaMap.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 1ACECD2317162DB1001FC9EF /* StorageAreaMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageAreaMap.h; sourceTree = "<group>"; };
</span><span class="cx">                 1AD01BC61905D37E00C9C45F /* _WKErrorRecoveryAttempting.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKErrorRecoveryAttempting.mm; sourceTree = "<group>"; };
</span><span class="lines">@@ -6272,6 +6274,7 @@
</span><span class="cx">                                 1A30EAC5115D7DA30053E937 /* ConnectionMac.mm */,
</span><span class="cx">                                 1A1EC69D1872092100B951F0 /* ImportanceAssertion.h */,
</span><span class="cx">                                 BCC56F771159957D001CCAF9 /* MachPort.h */,
</span><ins>+                                1ACB7986191ECADD006A6A61 /* XPCPtr.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = mac;
</span><span class="cx">                         sourceTree = "<group>";
</span><span class="lines">@@ -7034,6 +7037,7 @@
</span><span class="cx">                                 33152976130D0CB200ED2483 /* SecurityOriginData.h in Headers */,
</span><span class="cx">                                 518D2CCB12D51DFB003BB93B /* SessionState.h in Headers */,
</span><span class="cx">                                 1AA20D5118AD50E0005D1ED4 /* WKNavigationDelegatePrivate.h in Headers */,
</span><ins>+                                1ACB7987191ECADD006A6A61 /* XPCPtr.h in Headers */,
</ins><span class="cx">                                 1A6420E512DCE2FF00CAAE2C /* ShareableBitmap.h in Headers */,
</span><span class="cx">                                 51217461164C20E30037A5C1 /* ShareableResource.h in Headers */,
</span><span class="cx">                                 1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessEntryPointmacXPCServiceWebContentServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm (168583 => 168584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm        2014-05-10 20:51:20 UTC (rev 168583)
+++ trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm        2014-05-10 22:17:24 UTC (rev 168584)
</span><span class="lines">@@ -52,5 +52,5 @@
</span><span class="cx"> InitWebCoreThreadSystemInterface();
</span><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx">
</span><del>- XPCServiceInitializer<WebProcess, XPCServiceInitializerDelegate>(connection, initializerMessage);
</del><ins>+ XPCServiceInitializer<WebProcess, XPCServiceInitializerDelegate>(IPC::adoptXPC(connection), initializerMessage);
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>