Diff
Modified: trunk/Source/WTF/ChangeLog (173366 => 173367)
--- 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)
@@ -1,3 +1,24 @@
+2014-09-06 Sam Weinig <[email protected]>
+
+ 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.
+
2014-09-06 Darin Adler <[email protected]>
Make updates suggested by new version of Xcode
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (173366 => 173367)
--- 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)
@@ -73,6 +73,7 @@
2CDED0EF18115C38004DBA70 /* RunLoopCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */; };
2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0F118115C85004DBA70 /* RunLoop.cpp */; };
2CDED0F418115C85004DBA70 /* RunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CDED0F218115C85004DBA70 /* RunLoop.h */; };
+ 7CBBA07419BB7FDC00BBF025 /* OSObjectPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */; };
7CDD7FF8186D291E007433CD /* IteratorAdaptors.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDD7FF7186D291E007433CD /* IteratorAdaptors.h */; };
7CDD7FFA186D2A54007433CD /* IteratorRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDD7FF9186D2A54007433CD /* IteratorRange.h */; };
7E29C33E15FFD79B00516D61 /* ObjcRuntimeExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */; };
@@ -359,6 +360,7 @@
5D247B7014689C4700E78B76 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; };
5D247B7314689C4700E78B76 /* WTF.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WTF.xcconfig; sourceTree = "<group>"; };
6541CAF41630DB26006D0DEC /* CopyWTFHeaders.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CopyWTFHeaders.xcconfig; sourceTree = "<group>"; };
+ 7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSObjectPtr.h; sourceTree = "<group>"; };
7CDD7FF7186D291E007433CD /* IteratorAdaptors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IteratorAdaptors.h; sourceTree = "<group>"; };
7CDD7FF9186D2A54007433CD /* IteratorRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IteratorRange.h; sourceTree = "<group>"; };
7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjcRuntimeExtras.h; sourceTree = "<group>"; };
@@ -788,6 +790,7 @@
7E29C33D15FFD79B00516D61 /* ObjcRuntimeExtras.h */,
A8A472D7151A825B004123FF /* OSAllocator.h */,
A8A472D8151A825B004123FF /* OSAllocatorPosix.cpp */,
+ 7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */,
A8A472DA151A825B004123FF /* OSRandomSource.cpp */,
A8A472DB151A825B004123FF /* OSRandomSource.h */,
1AFDE6521953B23D00C48FFA /* Optional.h */,
@@ -1082,6 +1085,7 @@
A8A473E8151A825B004123FF /* MathExtras.h in Headers */,
93B1AA80180E5AF3004A2F05 /* PassRef.h in Headers */,
A8A473EA151A825B004123FF /* MD5.h in Headers */,
+ 7CBBA07419BB7FDC00BBF025 /* OSObjectPtr.h in Headers */,
CD5497AD15857D0300B5BC30 /* MediaTime.h in Headers */,
A8A473EB151A825B004123FF /* MessageQueue.h in Headers */,
A8A473ED151A825B004123FF /* MetaAllocator.h in Headers */,
Copied: trunk/Source/WTF/wtf/OSObjectPtr.h (from rev 173141, trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h) (0 => 173367)
--- trunk/Source/WTF/wtf/OSObjectPtr.h (rev 0)
+++ trunk/Source/WTF/wtf/OSObjectPtr.h 2014-09-07 17:56:32 UTC (rev 173367)
@@ -0,0 +1,155 @@
+/*
+ * 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
Modified: trunk/Source/WebKit2/ChangeLog (173366 => 173367)
--- 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)
@@ -1,3 +1,41 @@
+2014-09-06 Sam Weinig <[email protected]>
+
+ 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.
+
2014-09-06 Darin Adler <[email protected]>
Make updates suggested by new version of Xcode
Modified: trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm (173366 => 173367)
--- 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)
@@ -36,5 +36,5 @@
void DatabaseServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
{
- XPCServiceInitializer<DatabaseProcess, XPCServiceInitializerDelegate>(IPC::adoptXPC(connection), initializerMessage);
+ XPCServiceInitializer<DatabaseProcess, XPCServiceInitializerDelegate>(adoptOSObject(connection), initializerMessage);
}
Modified: trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm (173366 => 173367)
--- 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)
@@ -34,7 +34,7 @@
class NetworkServiceInitializerDelegate : public XPCServiceInitializerDelegate {
public:
- NetworkServiceInitializerDelegate(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
+ NetworkServiceInitializerDelegate(OSObjectPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
: XPCServiceInitializerDelegate(WTF::move(connection), initializerMessage)
{
}
@@ -53,6 +53,6 @@
// the this process don't try to insert the shim and crash.
EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/SecItemShim.dylib");
- XPCServiceInitializer<NetworkProcess, NetworkServiceInitializerDelegate>(IPC::adoptXPC(connection), initializerMessage);
+ XPCServiceInitializer<NetworkProcess, NetworkServiceInitializerDelegate>(adoptOSObject(connection), initializerMessage);
#endif
}
Modified: trunk/Source/WebKit2/Platform/IPC/Connection.h (173366 => 173367)
--- 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)
@@ -41,8 +41,8 @@
#include <wtf/text/CString.h>
#if OS(DARWIN)
-#include "XPCPtr.h"
#include <mach/mach_port.h>
+#include <wtf/OSObjectPtr.h>
#endif
#if PLATFORM(GTK) || PLATFORM(EFL)
@@ -110,14 +110,14 @@
{
}
- Identifier(mach_port_t port, XPCPtr<xpc_connection_t> xpcConnection)
+ Identifier(mach_port_t port, OSObjectPtr<xpc_connection_t> xpcConnection)
: port(port)
, xpcConnection(WTF::move(xpcConnection))
{
}
mach_port_t port;
- XPCPtr<xpc_connection_t> xpcConnection;
+ OSObjectPtr<xpc_connection_t> xpcConnection;
};
static bool identifierIsNull(Identifier identifier) { return identifier.port == MACH_PORT_NULL; }
xpc_connection_t xpcConnection() { return m_xpcConnection.get(); }
@@ -319,7 +319,7 @@
dispatch_source_t m_exceptionPortDataAvailableSource;
#endif
- XPCPtr<xpc_connection_t> m_xpcConnection;
+ OSObjectPtr<xpc_connection_t> m_xpcConnection;
#elif USE(UNIX_DOMAIN_SOCKETS)
// Called on the connection queue.
Modified: trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm (173366 => 173367)
--- 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)
@@ -75,13 +75,13 @@
// to ensure it has a chance to terminate cleanly.
class ConnectionTerminationWatchdog {
public:
- static void createConnectionTerminationWatchdog(XPCPtr<xpc_connection_t>& xpcConnection, double intervalInSeconds)
+ static void createConnectionTerminationWatchdog(OSObjectPtr<xpc_connection_t>& xpcConnection, double intervalInSeconds)
{
new ConnectionTerminationWatchdog(xpcConnection, intervalInSeconds);
}
private:
- ConnectionTerminationWatchdog(XPCPtr<xpc_connection_t>& xpcConnection, double intervalInSeconds)
+ ConnectionTerminationWatchdog(OSObjectPtr<xpc_connection_t>& xpcConnection, double intervalInSeconds)
: m_xpcConnection(xpcConnection)
, m_watchdogTimer(RunLoop::main(), this, &ConnectionTerminationWatchdog::watchdogTimerFired)
#if PLATFORM(IOS)
@@ -99,7 +99,7 @@
delete this;
}
- XPCPtr<xpc_connection_t> m_xpcConnection;
+ OSObjectPtr<xpc_connection_t> m_xpcConnection;
RunLoop::Timer<ConnectionTerminationWatchdog> m_watchdogTimer;
#if PLATFORM(IOS)
std::unique_ptr<WebKit::ProcessAndUIAssertion> m_assertion;
Deleted: trunk/Source/WebKit2/Platform/IPC/mac/XPCPtr.h (173366 => 173367)
--- 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)
@@ -1,105 +0,0 @@
-/*
- * 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
Modified: trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm (173366 => 173367)
--- 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)
@@ -37,7 +37,7 @@
class PluginServiceInitializerDelegate : public XPCServiceInitializerDelegate {
public:
- PluginServiceInitializerDelegate(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
+ PluginServiceInitializerDelegate(OSObjectPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
: XPCServiceInitializerDelegate(WTF::move(connection), initializerMessage)
{
}
@@ -76,6 +76,6 @@
// spawned by the PluginProcess don't try to insert the shim and crash.
EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/PluginProcessShim.dylib");
- XPCServiceInitializer<PluginProcess, PluginServiceInitializerDelegate>(IPC::adoptXPC(connection), initializerMessage);
+ XPCServiceInitializer<PluginProcess, PluginServiceInitializerDelegate>(adoptOSObject(connection), initializerMessage);
#endif // ENABLE(NETSCAPE_PLUGIN_API)
}
Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h (173366 => 173367)
--- 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)
@@ -28,7 +28,7 @@
#import "ChildProcess.h"
#import "WebKit2Initialize.h"
-#import "XPCPtr.h"
+#import <wtf/OSObjectPtr.h>
#if HAVE(VOUCHERS)
#if __has_include(<os/voucher_private.h>)
@@ -42,7 +42,7 @@
class XPCServiceInitializerDelegate {
public:
- XPCServiceInitializerDelegate(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
+ XPCServiceInitializerDelegate(OSObjectPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
: m_connection(WTF::move(connection))
, m_initializerMessage(initializerMessage)
{
@@ -61,12 +61,12 @@
bool hasEntitlement(const char* entitlement);
bool isClientSandboxed();
- IPC::XPCPtr<xpc_connection_t> m_connection;
+ OSObjectPtr<xpc_connection_t> m_connection;
xpc_object_t m_initializerMessage;
};
template<typename XPCServiceType, typename XPCServiceInitializerDelegateType>
-void XPCServiceInitializer(IPC::XPCPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
+void XPCServiceInitializer(OSObjectPtr<xpc_connection_t> connection, xpc_object_t initializerMessage)
{
XPCServiceInitializerDelegateType delegate(WTF::move(connection), initializerMessage);
Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm (173366 => 173367)
--- 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)
@@ -55,7 +55,7 @@
}
#endif
#if PLATFORM(IOS)
- auto value = IPC::adoptXPC(xpc_connection_copy_entitlement_value(m_connection.get(), "keychain-access-groups"));
+ auto value = adoptOSObject(xpc_connection_copy_entitlement_value(m_connection.get(), "keychain-access-groups"));
if (value && xpc_get_type(value.get()) == XPC_TYPE_ARRAY) {
xpc_array_apply(value.get(), ^bool(size_t index, xpc_object_t object) {
if (xpc_get_type(object) == XPC_TYPE_STRING && !strcmp(xpc_string_get_string_ptr(object), "com.apple.identities")) {
@@ -99,7 +99,7 @@
bool XPCServiceInitializerDelegate::hasEntitlement(const char* entitlement)
{
- auto value = IPC::adoptXPC(xpc_connection_copy_entitlement_value(m_connection.get(), entitlement));
+ auto value = adoptOSObject(xpc_connection_copy_entitlement_value(m_connection.get(), entitlement));
if (!value)
return false;
Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.Development.mm (173366 => 173367)
--- 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)
@@ -29,7 +29,7 @@
#import <spawn.h>
#import <stdio.h>
#import <stdlib.h>
-#import "XPCPtr.h"
+#import <wtf/OSObjectPtr.h>
namespace WebKit {
@@ -136,7 +136,7 @@
exit(EXIT_FAILURE);
}
- auto reply = IPC::adoptXPC(xpc_dictionary_create_reply(event));
+ auto reply = adoptOSObject(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());
Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm (173366 => 173367)
--- 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)
@@ -24,7 +24,7 @@
*/
#import <CoreFoundation/CoreFoundation.h>
-#import "XPCPtr.h"
+#import <wtf/OSObjectPtr.h>
namespace WebKit {
@@ -52,7 +52,7 @@
exit(EXIT_FAILURE);
}
- auto reply = IPC::adoptXPC(xpc_dictionary_create_reply(event));
+ auto reply = adoptOSObject(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());
Modified: trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm (173366 => 173367)
--- 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)
@@ -202,7 +202,7 @@
static void connectToService(const ProcessLauncher::LaunchOptions& launchOptions, bool forDevelopment, ProcessLauncher* that, DidFinishLaunchingProcessFunction didFinishLaunchingProcessFunction, UUIDHolder* instanceUUID)
{
// Create a connection to the WebKit XPC service.
- auto connection = IPC::adoptXPC(xpc_connection_create(serviceName(launchOptions, forDevelopment), 0));
+ auto connection = adoptOSObject(xpc_connection_create(serviceName(launchOptions, forDevelopment), 0));
xpc_connection_set_instance(connection.get(), instanceUUID->uuid);
#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
@@ -211,7 +211,7 @@
// 1.1. An important case is WebKitTestRunner, where we should use English localizations for all system frameworks.
// 2. When AppleLanguages is passed as command line argument for UI process, or set in its preferences, we should respect it in child processes.
if (_CFBundleSetupXPCBootstrapPtr()) {
- auto initializationMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
+ auto initializationMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
_CFBundleSetupXPCBootstrapPtr()(initializationMessage.get());
xpc_connection_set_bootstrap(connection.get(), initializationMessage.get());
}
@@ -222,7 +222,7 @@
xpc_connection_resume(connection.get());
if (shouldLeakBoost(launchOptions)) {
- auto preBootstrapMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
+ auto preBootstrapMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
xpc_dictionary_set_string(preBootstrapMessage.get(), "message-name", "pre-bootstrap");
xpc_connection_send_message(connection.get(), preBootstrapMessage.get());
}
@@ -238,7 +238,7 @@
CString clientIdentifier = bundleIdentifier ? String([[NSBundle mainBundle] bundleIdentifier]).utf8() : *_NSGetProgname();
// FIXME: Switch to xpc_connection_set_bootstrap once it's available everywhere we need.
- auto bootstrapMessage = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
+ auto bootstrapMessage = adoptOSObject(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);
@@ -250,7 +250,7 @@
xpc_dictionary_set_fd(bootstrapMessage.get(), "stderr", STDERR_FILENO);
}
- auto extraInitializationData = IPC::adoptXPC(xpc_dictionary_create(nullptr, nullptr, 0));
+ auto extraInitializationData = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
for (const auto& keyValuePair : launchOptions.extraInitializationData)
xpc_dictionary_set_string(extraInitializationData.get(), keyValuePair.key.utf8().data(), keyValuePair.value.utf8().data());
@@ -300,7 +300,7 @@
// FIXME: This UUID should be stored on the ChildProcessProxy.
RefPtr<UUIDHolder> instanceUUID = UUIDHolder::create();
- // FIXME: It would be nice if we could use XPCPtr for this connection as well, but we'd have to be careful
+ // FIXME: It would be nice if we could use OSObjectPtr 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.
xpc_connection_t reExecConnection = xpc_connection_create(serviceName(launchOptions, true), 0);
xpc_connection_set_instance(reExecConnection, instanceUUID->uuid);
Modified: trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm (173366 => 173367)
--- 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)
@@ -52,5 +52,5 @@
InitWebCoreThreadSystemInterface();
#endif // PLATFORM(IOS)
- XPCServiceInitializer<WebProcess, XPCServiceInitializerDelegate>(IPC::adoptXPC(connection), initializerMessage);
+ XPCServiceInitializer<WebProcess, XPCServiceInitializerDelegate>(adoptOSObject(connection), initializerMessage);
}
Modified: trunk/Tools/ChangeLog (173366 => 173367)
--- trunk/Tools/ChangeLog 2014-09-07 09:30:32 UTC (rev 173366)
+++ trunk/Tools/ChangeLog 2014-09-07 17:56:32 UTC (rev 173367)
@@ -1,3 +1,15 @@
+2014-09-06 Sam Weinig <[email protected]>
+
+ 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.
+
2014-09-06 Saam Barati <[email protected]>
Unreviewed. Add myself as a committer.
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (173366 => 173367)
--- 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)
@@ -122,6 +122,7 @@
7C74D42F188228F300E5ED57 /* StringView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C74D42D188228F300E5ED57 /* StringView.cpp */; };
7C8DDAAB1735DEEE00EA5AC0 /* CloseThenTerminate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C8DDAA91735DE1D00EA5AC0 /* CloseThenTerminate.cpp */; };
7C9ED98B17A19F4B00E4DC33 /* attributedStringStrikethrough.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 7C9ED98A17A19D0600E4DC33 /* attributedStringStrikethrough.html */; };
+ 7CBBA07819BB8A9100BBF025 /* OSObjectPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CBBA07619BB8A9100BBF025 /* OSObjectPtr.cpp */; };
7CC3E1FC197E234100BE6252 /* UserContentController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7CC3E1FA197E234100BE6252 /* UserContentController.mm */; };
7CFBCADF1743234F00B2BFCF /* WillLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */; };
7CFBCAE51743238F00B2BFCF /* WillLoad_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */; };
@@ -464,6 +465,7 @@
7C74D42D188228F300E5ED57 /* StringView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringView.cpp; sourceTree = "<group>"; };
7C8DDAA91735DE1D00EA5AC0 /* CloseThenTerminate.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CloseThenTerminate.cpp; sourceTree = "<group>"; };
7C9ED98A17A19D0600E4DC33 /* attributedStringStrikethrough.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = attributedStringStrikethrough.html; sourceTree = "<group>"; };
+ 7CBBA07619BB8A9100BBF025 /* OSObjectPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSObjectPtr.cpp; sourceTree = "<group>"; };
7CC3E1FA197E234100BE6252 /* UserContentController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserContentController.mm; sourceTree = "<group>"; };
7CFBCADD1743234F00B2BFCF /* WillLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad.cpp; sourceTree = "<group>"; };
7CFBCAE31743238E00B2BFCF /* WillLoad_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WillLoad_Bundle.cpp; sourceTree = "<group>"; };
@@ -748,6 +750,14 @@
path = ios;
sourceTree = "<group>";
};
+ 7CBBA07519BB8A0900BBF025 /* darwin */ = {
+ isa = PBXGroup;
+ children = (
+ 7CBBA07619BB8A9100BBF025 /* OSObjectPtr.cpp */,
+ );
+ path = darwin;
+ sourceTree = "<group>";
+ };
BC029B1A1486B23800817DA9 /* ns */ = {
isa = PBXGroup;
children = (
@@ -893,6 +903,7 @@
children = (
C0991C4F143C7D68007998F2 /* cf */,
BC029B1A1486B23800817DA9 /* ns */,
+ 7CBBA07519BB8A0900BBF025 /* darwin */,
26F1B44215CA434F00D1E4BF /* AtomicString.cpp */,
A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */,
26A2C72E15E2E73C005B1A14 /* CString.cpp */,
@@ -1318,6 +1329,7 @@
1AEF994917A09F5400998EF0 /* GetPIDAfterAbortedProcessLaunch.cpp in Sources */,
BC029B181486AD6400817DA9 /* RetainPtr.cpp in Sources */,
BC029B1C1486B25900817DA9 /* RetainPtr.mm in Sources */,
+ 7CBBA07819BB8A9100BBF025 /* OSObjectPtr.cpp in Sources */,
C0991C51143C7D68007998F2 /* RetainPtrHashing.cpp in Sources */,
CD5393CA1757BAC400C07123 /* SHA1.cpp in Sources */,
14F3B11315E45EAB00210069 /* SaturatedArithmeticOperations.cpp in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WTF/darwin/OSObjectPtr.cpp (0 => 173367)
--- 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)
@@ -0,0 +1,54 @@
+/*
+ * 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