<!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>[173367] trunk</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/173367">173367</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2014-09-07 10:56:32 -0700 (Sun, 07 Sep 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>XPCPtr should be converted into an all purpose smart pointer for os_objects
https://bugs.webkit.org/show_bug.cgi?id=136602
Reviewed by Darin Adler.
Source/WebKit2:
* 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):
* Platform/IPC/mac/ConnectionMac.mm:
(IPC::ConnectionTerminationWatchdog::createConnectionTerminationWatchdog):
(IPC::ConnectionTerminationWatchdog::ConnectionTerminationWatchdog):
* Platform/IPC/mac/XPCPtr.h: Removed.
* PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm:
(WebKit::PluginServiceInitializerDelegate::PluginServiceInitializerDelegate):
(PluginServiceInitializer):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
(WebKit::XPCServiceInitializerDelegate::XPCServiceInitializerDelegate):
(WebKit::XPCServiceInitializer):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::checkEntitlements):
(WebKit::XPCServiceInitializerDelegate::hasEntitlement):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm:
(WebKit::XPCServiceEventHandler):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
(WebKit::XPCServiceEventHandler):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::connectToService):
(WebKit::connectToReExecService):
* WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm:
(WebContentServiceInitializer):
Update after the rename of XPCPtr to OSObjectPtr.
Source/WTF:
* WTF.xcodeproj/project.pbxproj:
* wtf/OSObjectPtr.h: Copied from Source/WebKit2/Platform/IPC/mac/XPCPtr.h.
(WTF::retainOSObject):
(WTF::releaseOSObject):
(WTF::OSObjectPtr::OSObjectPtr):
(WTF::OSObjectPtr::~OSObjectPtr):
(WTF::OSObjectPtr::operator=):
(WTF::adoptOSObject):
(IPC::XPCPtr::XPCPtr): Deleted.
(IPC::XPCPtr::~XPCPtr): Deleted.
(IPC::XPCPtr::operator=): Deleted.
(IPC::adoptXPC): Deleted.
Rename/move XPCPtr to OSObjectPtr and make it work with any os_object.
Tools:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/darwin: Added.
* TestWebKitAPI/Tests/WTF/darwin/OSObjectPtr.cpp: Added.
Add basic unit tests for OSObjectPtr.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFWTFxcodeprojprojectpbxproj">trunk/Source/WTF/WTF.xcodeproj/project.pbxproj</a></li>
<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="#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="#trunkSourceWebKit2UIProcessLaunchermacProcessLauncherMacmm">trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessEntryPointmacXPCServiceWebContentServiceEntryPointmm">trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfOSObjectPtrh">trunk/Source/WTF/wtf/OSObjectPtr.h</a></li>
<li>trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/</li>
<li><a href="#trunkToolsTestWebKitAPITestsWTFdarwinOSObjectPtrcpp">trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/OSObjectPtr.cpp</a></li>
</ul>
<h3>Removed 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="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WTF/ChangeLog        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2014-09-06 Sam Weinig <sam@webkit.org>
+
+ XPCPtr should be converted into an all purpose smart pointer for os_objects
+ https://bugs.webkit.org/show_bug.cgi?id=136602
+
+ Reviewed by Darin Adler.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/OSObjectPtr.h: Copied from Source/WebKit2/Platform/IPC/mac/XPCPtr.h.
+ (WTF::retainOSObject):
+ (WTF::releaseOSObject):
+ (WTF::OSObjectPtr::OSObjectPtr):
+ (WTF::OSObjectPtr::~OSObjectPtr):
+ (WTF::OSObjectPtr::operator=):
+ (WTF::adoptOSObject):
+ (IPC::XPCPtr::XPCPtr): Deleted.
+ (IPC::XPCPtr::~XPCPtr): Deleted.
+ (IPC::XPCPtr::operator=): Deleted.
+ (IPC::adoptXPC): Deleted.
+ Rename/move XPCPtr to OSObjectPtr and make it work with any os_object.
+
</ins><span class="cx"> 2014-09-06 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> Make updates suggested by new version of Xcode
</span></span></pre></div>
<a id="trunkSourceWTFWTFxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -73,6 +73,7 @@
</span><span class="cx">                 2CDED0EF18115C38004DBA70 /* RunLoopCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */; };
</span><span class="cx">                 2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0F118115C85004DBA70 /* RunLoop.cpp */; };
</span><span class="cx">                 2CDED0F418115C85004DBA70 /* RunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CDED0F218115C85004DBA70 /* RunLoop.h */; };
</span><ins>+                7CBBA07419BB7FDC00BBF025 /* OSObjectPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */; };
</ins><span class="cx">                 7CDD7FF8186D291E007433CD /* IteratorAdaptors.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDD7FF7186D291E007433CD /* IteratorAdaptors.h */; };
</span><span class="cx">                 7CDD7FFA186D2A54007433CD /* IteratorRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDD7FF9186D2A54007433CD /* IteratorRange.h */; };
</span><span class="cx">                 7E29C33E15FFD79B00516D61 /* ObjcRuntimeExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */; };
</span><span class="lines">@@ -359,6 +360,7 @@
</span><span class="cx">                 5D247B7014689C4700E78B76 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
</span><span class="cx">                 5D247B7314689C4700E78B76 /* WTF.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WTF.xcconfig; sourceTree = "<group>"; };
</span><span class="cx">                 6541CAF41630DB26006D0DEC /* CopyWTFHeaders.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CopyWTFHeaders.xcconfig; sourceTree = "<group>"; };
</span><ins>+                7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSObjectPtr.h; sourceTree = "<group>"; };
</ins><span class="cx">                 7CDD7FF7186D291E007433CD /* IteratorAdaptors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IteratorAdaptors.h; sourceTree = "<group>"; };
</span><span class="cx">                 7CDD7FF9186D2A54007433CD /* IteratorRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IteratorRange.h; sourceTree = "<group>"; };
</span><span class="cx">                 7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjcRuntimeExtras.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -788,6 +790,7 @@
</span><span class="cx">                                 7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */,
</span><span class="cx">                                 A8A472D7151A825B004123FF /* OSAllocator.h */,
</span><span class="cx">                                 A8A472D8151A825B004123FF /* OSAllocatorPosix.cpp */,
</span><ins>+                                7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */,
</ins><span class="cx">                                 A8A472DA151A825B004123FF /* OSRandomSource.cpp */,
</span><span class="cx">                                 A8A472DB151A825B004123FF /* OSRandomSource.h */,
</span><span class="cx">                                 1AFDE6521953B23D00C48FFA /* Optional.h */,
</span><span class="lines">@@ -1082,6 +1085,7 @@
</span><span class="cx">                                 A8A473E8151A825B004123FF /* MathExtras.h in Headers */,
</span><span class="cx">                                 93B1AA80180E5AF3004A2F05 /* PassRef.h in Headers */,
</span><span class="cx">                                 A8A473EA151A825B004123FF /* MD5.h in Headers */,
</span><ins>+                                7CBBA07419BB7FDC00BBF025 /* OSObjectPtr.h in Headers */,
</ins><span class="cx">                                 CD5497AD15857D0300B5BC30 /* MediaTime.h in Headers */,
</span><span class="cx">                                 A8A473EB151A825B004123FF /* MessageQueue.h in Headers */,
</span><span class="cx">                                 A8A473ED151A825B004123FF /* MetaAllocator.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWTFwtfOSObjectPtrhfromrev173141trunkSourceWebKit2PlatformIPCmacXPCPtrh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WTF/wtf/OSObjectPtr.h (from rev 173141, trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h) (0 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/OSObjectPtr.h         (rev 0)
+++ trunk/Source/WTF/wtf/OSObjectPtr.h        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -0,0 +1,155 @@
</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 OSObjectPtr_h
+#define OSObjectPtr_h
+
+#include <os/object.h>
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+
+#if __has_include(<os/object_private.h>)
+#include <os/object_private.h>
+#endif
+
+#if OS_OBJECT_USE_OBJC
+@class OS_object;
+typedef OS_object *_os_object_t;
+#else
+typedef struct _os_object_s *_os_object_t;
+#endif
+
+extern "C" _os_object_t _os_object_retain(_os_object_t object);
+extern "C" void _os_object_release(_os_object_t object);
+
+#endif
+
+
+namespace WTF {
+
+struct AdoptOSObject { };
+
+template<typename T>
+static inline void retainOSObject(T ptr)
+{
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 || PLATFORM(IOS)
+ os_retain(ptr);
+#else
+#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
+ [ptr retain];
+#else
+ _os_object_retain((_os_object_t)ptr);
+#endif
+#endif
+}
+
+template<typename T>
+static inline void releaseOSObject(T ptr)
+{
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 || PLATFORM(IOS)
+ os_release(ptr);
+#else
+#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE
+ [ptr release];
+#else
+ _os_object_release((_os_object_t)ptr);
+#endif
+#endif
+}
+
+template<typename T> class OSObjectPtr {
+public:
+ OSObjectPtr()
+ : m_ptr(nullptr)
+ {
+ }
+
+ OSObjectPtr(AdoptOSObject, T ptr)
+ : m_ptr(ptr)
+ {
+ }
+
+ ~OSObjectPtr()
+ {
+ if (m_ptr)
+ releaseOSObject(m_ptr);
+ }
+
+ T get() const { return m_ptr; }
+
+ explicit operator bool() const { return m_ptr; }
+ bool operator!() const { return !m_ptr; }
+
+ OSObjectPtr(const OSObjectPtr& other)
+ : m_ptr(other.m_ptr)
+ {
+ if (m_ptr)
+ retainOSObject(m_ptr);
+ }
+
+ OSObjectPtr(OSObjectPtr&& other)
+ : m_ptr(other.m_ptr)
+ {
+ other.m_ptr = nullptr;
+ }
+
+ OSObjectPtr& operator=(const OSObjectPtr& other)
+ {
+ T optr = other.get();
+ if (optr)
+ retainOSObject(optr);
+
+ T ptr = m_ptr;
+ m_ptr = optr;
+
+ if (ptr)
+ releaseOSObject(ptr);
+
+ return *this;
+ }
+
+ OSObjectPtr& operator=(std::nullptr_t)
+ {
+ if (m_ptr)
+ releaseOSObject(m_ptr);
+ m_ptr = nullptr;
+
+ return *this;
+ }
+private:
+ T m_ptr;
+};
+
+template<typename T> inline OSObjectPtr<T> adoptOSObject(T ptr)
+{
+ return OSObjectPtr<T>(AdoptOSObject { }, ptr);
+}
+
+} // namespace WTF
+
+using WTF::OSObjectPtr;
+using WTF::adoptOSObject;
+
+#endif // OSObjectPtr_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/ChangeLog        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2014-09-06 Sam Weinig <sam@webkit.org>
+
+ XPCPtr should be converted into an all purpose smart pointer for os_objects
+ https://bugs.webkit.org/show_bug.cgi?id=136602
+
+ Reviewed by Darin Adler.
+
+ * 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):
+ * Platform/IPC/mac/ConnectionMac.mm:
+ (IPC::ConnectionTerminationWatchdog::createConnectionTerminationWatchdog):
+ (IPC::ConnectionTerminationWatchdog::ConnectionTerminationWatchdog):
+ * Platform/IPC/mac/XPCPtr.h: Removed.
+ * PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm:
+ (WebKit::PluginServiceInitializerDelegate::PluginServiceInitializerDelegate):
+ (PluginServiceInitializer):
+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
+ (WebKit::XPCServiceInitializerDelegate::XPCServiceInitializerDelegate):
+ (WebKit::XPCServiceInitializer):
+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
+ (WebKit::XPCServiceInitializerDelegate::checkEntitlements):
+ (WebKit::XPCServiceInitializerDelegate::hasEntitlement):
+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm:
+ (WebKit::XPCServiceEventHandler):
+ * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
+ (WebKit::XPCServiceEventHandler):
+ * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+ (WebKit::connectToService):
+ (WebKit::connectToReExecService):
+ * WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm:
+ (WebContentServiceInitializer):
+ Update after the rename of XPCPtr to OSObjectPtr.
+
</ins><span class="cx"> 2014-09-06 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> Make updates suggested by new version of Xcode
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessEntryPointmacXPCServiceDatabaseServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm        2014-09-07 17:56:32 UTC (rev 173367)
</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>(IPC::adoptXPC(connection), initializerMessage);
</del><ins>+ XPCServiceInitializer<DatabaseProcess, XPCServiceInitializerDelegate>(adoptOSObject(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 (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx">
</span><span class="cx"> class NetworkServiceInitializerDelegate : public XPCServiceInitializerDelegate {
</span><span class="cx"> public:
</span><del>- NetworkServiceInitializerDelegate(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
</del><ins>+ NetworkServiceInitializerDelegate(OSObjectPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
</ins><span class="cx"> : XPCServiceInitializerDelegate(WTF::move(connection), initializerMessage)
</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>(IPC::adoptXPC(connection), initializerMessage);
</del><ins>+ XPCServiceInitializer<NetworkProcess, NetworkServiceInitializerDelegate>(adoptOSObject(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 (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/Connection.h        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/Platform/IPC/Connection.h        2014-09-07 17:56:32 UTC (rev 173367)
</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><del>-#include "XPCPtr.h"
</del><span class="cx"> #include <mach/mach_port.h>
</span><ins>+#include <wtf/OSObjectPtr.h>
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(GTK) || PLATFORM(EFL)
</span><span class="lines">@@ -110,14 +110,14 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>- Identifier(mach_port_t port, XPCPtr<xpc_connection_t> xpcConnection)
</del><ins>+ Identifier(mach_port_t port, OSObjectPtr<xpc_connection_t> xpcConnection)
</ins><span class="cx"> : port(port)
</span><span class="cx"> , xpcConnection(WTF::move(xpcConnection))
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> mach_port_t port;
</span><del>- XPCPtr<xpc_connection_t> xpcConnection;
</del><ins>+ OSObjectPtr<xpc_connection_t> xpcConnection;
</ins><span class="cx"> };
</span><span class="cx"> static bool identifierIsNull(Identifier identifier) { return identifier.port == MACH_PORT_NULL; }
</span><span class="cx"> xpc_connection_t xpcConnection() { return m_xpcConnection.get(); }
</span><span class="lines">@@ -319,7 +319,7 @@
</span><span class="cx"> dispatch_source_t m_exceptionPortDataAvailableSource;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- XPCPtr<xpc_connection_t> m_xpcConnection;
</del><ins>+ OSObjectPtr<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 (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -75,13 +75,13 @@
</span><span class="cx"> // to ensure it has a chance to terminate cleanly.
</span><span class="cx"> class ConnectionTerminationWatchdog {
</span><span class="cx"> public:
</span><del>- static void createConnectionTerminationWatchdog(XPCPtr<xpc_connection_t>& xpcConnection, double intervalInSeconds)
</del><ins>+ static void createConnectionTerminationWatchdog(OSObjectPtr<xpc_connection_t>& xpcConnection, double intervalInSeconds)
</ins><span class="cx"> {
</span><span class="cx"> new ConnectionTerminationWatchdog(xpcConnection, intervalInSeconds);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- ConnectionTerminationWatchdog(XPCPtr<xpc_connection_t>& xpcConnection, double intervalInSeconds)
</del><ins>+ ConnectionTerminationWatchdog(OSObjectPtr<xpc_connection_t>& xpcConnection, double intervalInSeconds)
</ins><span class="cx"> : m_xpcConnection(xpcConnection)
</span><span class="cx"> , m_watchdogTimer(RunLoop::main(), this, &ConnectionTerminationWatchdog::watchdogTimerFired)
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -99,7 +99,7 @@
</span><span class="cx"> delete this;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- XPCPtr<xpc_connection_t> m_xpcConnection;
</del><ins>+ OSObjectPtr<xpc_connection_t> m_xpcConnection;
</ins><span class="cx"> RunLoop::Timer<ConnectionTerminationWatchdog> m_watchdogTimer;
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> std::unique_ptr<WebKit::ProcessAndUIAssertion> m_assertion;
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformIPCmacXPCPtrh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -1,105 +0,0 @@
</span><del>-/*
- * 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; }
-
- explicit operator bool() 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
</del></span></pre></div>
<a id="trunkSourceWebKit2PluginProcessEntryPointmacXPCServicePluginServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx">
</span><span class="cx"> class PluginServiceInitializerDelegate : public XPCServiceInitializerDelegate {
</span><span class="cx"> public:
</span><del>- PluginServiceInitializerDelegate(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
</del><ins>+ PluginServiceInitializerDelegate(OSObjectPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
</ins><span class="cx"> : XPCServiceInitializerDelegate(WTF::move(connection), initializerMessage)
</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>(IPC::adoptXPC(connection), initializerMessage);
</del><ins>+ XPCServiceInitializer<PluginProcess, PluginServiceInitializerDelegate>(adoptOSObject(connection), initializerMessage);
</ins><span class="cx"> #endif // ENABLE(NETSCAPE_PLUGIN_API)
</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 (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #import "ChildProcess.h"
</span><span class="cx"> #import "WebKit2Initialize.h"
</span><del>-#import "XPCPtr.h"
</del><ins>+#import <wtf/OSObjectPtr.h>
</ins><span class="cx">
</span><span class="cx"> #if HAVE(VOUCHERS)
</span><span class="cx"> #if __has_include(<os/voucher_private.h>)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx">
</span><span class="cx"> class XPCServiceInitializerDelegate {
</span><span class="cx"> public:
</span><del>- XPCServiceInitializerDelegate(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
</del><ins>+ XPCServiceInitializerDelegate(OSObjectPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
</ins><span class="cx"> : m_connection(WTF::move(connection))
</span><span class="cx"> , m_initializerMessage(initializerMessage)
</span><span class="cx"> {
</span><span class="lines">@@ -61,12 +61,12 @@
</span><span class="cx"> bool hasEntitlement(const char* entitlement);
</span><span class="cx"> bool isClientSandboxed();
</span><span class="cx">
</span><del>- IPC::XPCPtr<xpc_connection_t> m_connection;
</del><ins>+ OSObjectPtr<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(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
</del><ins>+void XPCServiceInitializer(OSObjectPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
</ins><span class="cx"> {
</span><span class="cx"> XPCServiceInitializerDelegateType delegate(WTF::move(connection), initializerMessage);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>- auto value = IPC::adoptXPC(xpc_connection_copy_entitlement_value(m_connection.get(), "keychain-access-groups"));
</del><ins>+ auto value = adoptOSObject(xpc_connection_copy_entitlement_value(m_connection.get(), "keychain-access-groups"));
</ins><span class="cx"> if (value && xpc_get_type(value.get()) == XPC_TYPE_ARRAY) {
</span><span class="cx"> xpc_array_apply(value.get(), ^bool(size_t index, xpc_object_t object) {
</span><span class="cx"> if (xpc_get_type(object) == XPC_TYPE_STRING && !strcmp(xpc_string_get_string_ptr(object), "com.apple.identities")) {
</span><span class="lines">@@ -99,7 +99,7 @@
</span><span class="cx">
</span><span class="cx"> bool XPCServiceInitializerDelegate::hasEntitlement(const char* entitlement)
</span><span class="cx"> {
</span><del>- auto value = IPC::adoptXPC(xpc_connection_copy_entitlement_value(m_connection.get(), entitlement));
</del><ins>+ auto value = adoptOSObject(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></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceMainDevelopmentmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm        2014-09-07 17:56:32 UTC (rev 173367)
</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 "XPCPtr.h"
</del><ins>+#import <wtf/OSObjectPtr.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="lines">@@ -136,7 +136,7 @@
</span><span class="cx"> exit(EXIT_FAILURE);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- auto reply = IPC::adoptXPC(xpc_dictionary_create_reply(event));
</del><ins>+ auto reply = adoptOSObject(xpc_dictionary_create_reply(event));
</ins><span class="cx"> xpc_dictionary_set_string(reply.get(), "message-name", "process-finished-launching");
</span><span class="cx"> xpc_connection_send_message(xpc_dictionary_get_remote_connection(event), reply.get());
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceMainmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm        2014-09-07 17:56:32 UTC (rev 173367)
</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 "XPCPtr.h"
</del><ins>+#import <wtf/OSObjectPtr.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx"> exit(EXIT_FAILURE);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- auto reply = IPC::adoptXPC(xpc_dictionary_create_reply(event));
</del><ins>+ auto reply = adoptOSObject(xpc_dictionary_create_reply(event));
</ins><span class="cx"> xpc_dictionary_set_string(reply.get(), "message-name", "process-finished-launching");
</span><span class="cx"> xpc_connection_send_message(xpc_dictionary_get_remote_connection(event), reply.get());
</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 (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -202,7 +202,7 @@
</span><span class="cx"> static void connectToService(const ProcessLauncher::LaunchOptions& launchOptions, bool forDevelopment, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction, UUIDHolder* instanceUUID)
</span><span class="cx"> {
</span><span class="cx"> // Create a connection to the WebKit XPC service.
</span><del>- auto connection = IPC::adoptXPC(xpc_connection_create(serviceName(launchOptions, forDevelopment), 0));
</del><ins>+ auto connection = adoptOSObject(xpc_connection_create(serviceName(launchOptions, forDevelopment), 0));
</ins><span class="cx"> xpc_connection_set_instance(connection.get(), instanceUUID->uuid);
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
</span><span class="lines">@@ -211,7 +211,7 @@
</span><span class="cx"> // 1.1. An important case is WebKitTestRunner, where we should use English localizations for all system frameworks.
</span><span class="cx"> // 2. When AppleLanguages is passed as command line argument for UI process, or set in its preferences, we should respect it in child processes.
</span><span class="cx"> if (_CFBundleSetupXPCBootstrapPtr()) {
</span><del>- auto initializationMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
</del><ins>+ auto initializationMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
</ins><span class="cx"> _CFBundleSetupXPCBootstrapPtr()(initializationMessage.get());
</span><span class="cx"> xpc_connection_set_bootstrap(connection.get(), initializationMessage.get());
</span><span class="cx"> }
</span><span class="lines">@@ -222,7 +222,7 @@
</span><span class="cx"> xpc_connection_resume(connection.get());
</span><span class="cx">
</span><span class="cx"> if (shouldLeakBoost(launchOptions)) {
</span><del>- auto preBootstrapMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
</del><ins>+ auto preBootstrapMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
</ins><span class="cx"> xpc_dictionary_set_string(preBootstrapMessage.get(), "message-name", "pre-bootstrap");
</span><span class="cx"> xpc_connection_send_message(connection.get(), preBootstrapMessage.get());
</span><span class="cx"> }
</span><span class="lines">@@ -238,7 +238,7 @@
</span><span class="cx"> CString clientIdentifier = bundleIdentifier ? String([[NSBundle mainBundle] bundleIdentifier]).utf8() : *_NSGetProgname();
</span><span class="cx">
</span><span class="cx"> // FIXME: Switch to xpc_connection_set_bootstrap once it's available everywhere we need.
</span><del>- auto bootstrapMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
</del><ins>+ auto bootstrapMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
</ins><span class="cx"> xpc_dictionary_set_string(bootstrapMessage.get(), "message-name", "bootstrap");
</span><span class="cx"> xpc_dictionary_set_string(bootstrapMessage.get(), "framework-executable-path", [[[NSBundle bundleWithIdentifier:@"com.apple.WebKit"] executablePath] fileSystemRepresentation]);
</span><span class="cx"> xpc_dictionary_set_mach_send(bootstrapMessage.get(), "server-port", listeningPort);
</span><span class="lines">@@ -250,7 +250,7 @@
</span><span class="cx"> xpc_dictionary_set_fd(bootstrapMessage.get(), "stderr", STDERR_FILENO);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- auto extraInitializationData = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
</del><ins>+ auto extraInitializationData = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
</ins><span class="cx">
</span><span class="cx"> for (const auto& keyValuePair : launchOptions.extraInitializationData)
</span><span class="cx"> xpc_dictionary_set_string(extraInitializationData.get(), keyValuePair.key.utf8().data(), keyValuePair.value.utf8().data());
</span><span class="lines">@@ -300,7 +300,7 @@
</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><del>- // FIXME: It would be nice if we could use XPCPtr for this connection as well, but we'd have to be careful
</del><ins>+ // FIXME: It would be nice if we could use OSObjectPtr for this connection as well, but we'd have to be careful
</ins><span class="cx"> // not to introduce any retain cycles in the call to xpc_connection_set_event_handler below.
</span><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></pre></div>
<a id="trunkSourceWebKit2WebProcessEntryPointmacXPCServiceWebContentServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm        2014-09-07 17:56:32 UTC (rev 173367)
</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>(IPC::adoptXPC(connection), initializerMessage);
</del><ins>+ XPCServiceInitializer<WebProcess, XPCServiceInitializerDelegate>(adoptOSObject(connection), initializerMessage);
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Tools/ChangeLog        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-09-06 Sam Weinig <sam@webkit.org>
+
+ XPCPtr should be converted into an all purpose smart pointer for os_objects
+ https://bugs.webkit.org/show_bug.cgi?id=136602
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WTF/darwin: Added.
+ * TestWebKitAPI/Tests/WTF/darwin/OSObjectPtr.cpp: Added.
+ Add basic unit tests for OSObjectPtr.
+
</ins><span class="cx"> 2014-09-06 Saam Barati <saambarati1@gmail.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed. Add myself as a committer.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (173366 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -122,6 +122,7 @@
</span><span class="cx">                 7C74D42F188228F300E5ED57 /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C74D42D188228F300E5ED57 /* StringView.cpp */; };
</span><span class="cx">                 7C8DDAAB1735DEEE00EA5AC0 /* CloseThenTerminate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C8DDAA91735DE1D00EA5AC0 /* CloseThenTerminate.cpp */; };
</span><span class="cx">                 7C9ED98B17A19F4B00E4DC33 /* attributedStringStrikethrough.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7C9ED98A17A19D0600E4DC33 /* attributedStringStrikethrough.html */; };
</span><ins>+                7CBBA07819BB8A9100BBF025 /* OSObjectPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CBBA07619BB8A9100BBF025 /* OSObjectPtr.cpp */; };
</ins><span class="cx">                 7CC3E1FC197E234100BE6252 /* UserContentController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CC3E1FA197E234100BE6252 /* UserContentController.mm */; };
</span><span class="cx">                 7CFBCADF1743234F00B2BFCF /* WillLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */; };
</span><span class="cx">                 7CFBCAE51743238F00B2BFCF /* WillLoad_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */; };
</span><span class="lines">@@ -464,6 +465,7 @@
</span><span class="cx">                 7C74D42D188228F300E5ED57 /* StringView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringView.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C8DDAA91735DE1D00EA5AC0 /* CloseThenTerminate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CloseThenTerminate.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C9ED98A17A19D0600E4DC33 /* attributedStringStrikethrough.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = attributedStringStrikethrough.html; sourceTree = "<group>"; };
</span><ins>+                7CBBA07619BB8A9100BBF025 /* OSObjectPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSObjectPtr.cpp; sourceTree = "<group>"; };
</ins><span class="cx">                 7CC3E1FA197E234100BE6252 /* UserContentController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserContentController.mm; sourceTree = "<group>"; };
</span><span class="cx">                 7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad_Bundle.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -748,6 +750,14 @@
</span><span class="cx">                         path = ios;
</span><span class="cx">                         sourceTree = "<group>";
</span><span class="cx">                 };
</span><ins>+                7CBBA07519BB8A0900BBF025 /* darwin */ = {
+                        isa = PBXGroup;
+                        children = (
+                                7CBBA07619BB8A9100BBF025 /* OSObjectPtr.cpp */,
+                        );
+                        path = darwin;
+                        sourceTree = "<group>";
+                };
</ins><span class="cx">                 BC029B1A1486B23800817DA9 /* ns */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="lines">@@ -893,6 +903,7 @@
</span><span class="cx">                         children = (
</span><span class="cx">                                 C0991C4F143C7D68007998F2 /* cf */,
</span><span class="cx">                                 BC029B1A1486B23800817DA9 /* ns */,
</span><ins>+                                7CBBA07519BB8A0900BBF025 /* darwin */,
</ins><span class="cx">                                 26F1B44215CA434F00D1E4BF /* AtomicString.cpp */,
</span><span class="cx">                                 A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */,
</span><span class="cx">                                 26A2C72E15E2E73C005B1A14 /* CString.cpp */,
</span><span class="lines">@@ -1318,6 +1329,7 @@
</span><span class="cx">                                 1AEF994917A09F5400998EF0 /* GetPIDAfterAbortedProcessLaunch.cpp in Sources */,
</span><span class="cx">                                 BC029B181486AD6400817DA9 /* RetainPtr.cpp in Sources */,
</span><span class="cx">                                 BC029B1C1486B25900817DA9 /* RetainPtr.mm in Sources */,
</span><ins>+                                7CBBA07819BB8A9100BBF025 /* OSObjectPtr.cpp in Sources */,
</ins><span class="cx">                                 C0991C51143C7D68007998F2 /* RetainPtrHashing.cpp in Sources */,
</span><span class="cx">                                 CD5393CA1757BAC400C07123 /* SHA1.cpp in Sources */,
</span><span class="cx">                                 14F3B11315E45EAB00210069 /* SaturatedArithmeticOperations.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFdarwinOSObjectPtrcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/OSObjectPtr.cpp (0 => 173367)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/OSObjectPtr.cpp         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/OSObjectPtr.cpp        2014-09-07 17:56:32 UTC (rev 173367)
</span><span class="lines">@@ -0,0 +1,54 @@
</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.
+ */
+
+#include "config.h"
+
+#include <wtf/OSObjectPtr.h>
+
+#include <dispatch/dispatch.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+namespace TestWebKitAPI {
+
+TEST(OSObjectPtr, AdoptOSObject)
+{
+ OSObjectPtr<dispatch_queue_t> foo = adoptOSObject(dispatch_queue_create(0, DISPATCH_QUEUE_SERIAL));
+
+ EXPECT_EQ(1, CFGetRetainCount(foo.get()));
+}
+
+TEST(OSObjectPtr, RetainRelease)
+{
+ dispatch_queue_t foo = dispatch_queue_create(0, DISPATCH_QUEUE_SERIAL);
+ EXPECT_EQ(1, CFGetRetainCount(foo));
+
+ WTF::retainOSObject(foo);
+ EXPECT_EQ(2, CFGetRetainCount(foo));
+
+ WTF::releaseOSObject(foo);
+ EXPECT_EQ(1, CFGetRetainCount(foo));
+}
+
+} // namespace TestWebKitAPI
</ins></span></pre>
</div>
</div>
</body>
</html>