diff --git a/Source/WebKit/Platform/SharedMemory.cpp b/Source/WebKit/Platform/SharedMemory.cpp index 6430273dfb90..e92aa8a91a2f 100644 --- a/Source/WebKit/Platform/SharedMemory.cpp +++ b/Source/WebKit/Platform/SharedMemory.cpp @@ -33,6 +33,17 @@ namespace WebKit { using namespace WebCore; +SharedMemoryHandle::SharedMemoryHandle(SharedMemoryHandle::Type&& handle, size_t size) + : m_handle(WTFMove(handle)) + , m_size(size) +{ +} + +bool SharedMemoryHandle::isNull() const +{ + return !m_handle; +} + RefPtr SharedMemory::copyBuffer(const FragmentedSharedBuffer& buffer) { if (buffer.isEmpty()) diff --git a/Source/WebKit/Platform/SharedMemory.h b/Source/WebKit/Platform/SharedMemory.h index 05af7aa2fb82..9e71fee9a31e 100644 --- a/Source/WebKit/Platform/SharedMemory.h +++ b/Source/WebKit/Platform/SharedMemory.h @@ -60,6 +60,7 @@ namespace WebKit { enum class MemoryLedger { None, Default, Network, Media, Graphics, Neural }; class SharedMemoryHandle { + WTF_MAKE_NONCOPYABLE(SharedMemoryHandle); public: using Type = #if USE(UNIX_DOMAIN_SOCKETS) @@ -70,6 +71,12 @@ class SharedMemoryHandle { Win32Handle; #endif + SharedMemoryHandle() = default; + SharedMemoryHandle(SharedMemoryHandle&&) = default; + SharedMemoryHandle(SharedMemoryHandle::Type&&, size_t); + + SharedMemoryHandle& operator=(SharedMemoryHandle&&) = default; + bool isNull() const; size_t size() const { return m_size; } diff --git a/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp b/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp index ac5119b694c7..9eb2d75d4ff5 100644 --- a/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp +++ b/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp @@ -91,11 +91,6 @@ void SharedMemoryHandle::setOwnershipOfMemory(const WebCore::ProcessIdentity& pr #endif } -bool SharedMemoryHandle::isNull() const -{ - return !m_handle; -} - static inline void* toPointer(mach_vm_address_t address) { return reinterpret_cast(static_cast(address)); diff --git a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp index d798fb06a40b..45aeb5ca49ef 100644 --- a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp +++ b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp @@ -52,11 +52,6 @@ namespace WebKit { -bool SharedMemoryHandle::isNull() const -{ - return !m_handle; -} - UnixFileDescriptor SharedMemoryHandle::releaseHandle() { return WTFMove(m_handle); diff --git a/Source/WebKit/Platform/win/SharedMemoryWin.cpp b/Source/WebKit/Platform/win/SharedMemoryWin.cpp index 215e29cebbd2..9e9b1b9d7cd7 100644 --- a/Source/WebKit/Platform/win/SharedMemoryWin.cpp +++ b/Source/WebKit/Platform/win/SharedMemoryWin.cpp @@ -31,11 +31,6 @@ namespace WebKit { -bool SharedMemoryHandle::isNull() const -{ - return !m_handle; -} - RefPtr SharedMemory::allocate(size_t size) { Win32Handle handle { ::CreateFileMappingW(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, 0) }; diff --git a/Source/WebKit/Shared/IPCStreamTester.cpp b/Source/WebKit/Shared/IPCStreamTester.cpp index 6e1826e5e98f..d57eb16fc474 100644 --- a/Source/WebKit/Shared/IPCStreamTester.cpp +++ b/Source/WebKit/Shared/IPCStreamTester.cpp @@ -26,15 +26,15 @@ #include "config.h" #include "IPCStreamTester.h" -#include - #if ENABLE(IPC_TESTING_API) + #include "Decoder.h" #include "IPCStreamTesterMessages.h" #include "IPCStreamTesterProxyMessages.h" #include "IPCUtilities.h" #include "StreamConnectionWorkQueue.h" #include "StreamServerConnection.h" +#include #if USE(FOUNDATION) #include @@ -86,7 +86,7 @@ void IPCStreamTester::syncMessageReturningSharedMemory1(uint32_t byteCount, Comp uint8_t* data = static_cast(sharedMemory->data()); for (size_t i = 0; i < sharedMemory->size(); ++i) data[i] = i; - return *handle; + return WTFMove(*handle); }(); completionHandler(WTFMove(result)); } diff --git a/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp b/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp index 29b40ae0a730..f15f0c30546f 100644 --- a/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp +++ b/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp @@ -1342,7 +1342,7 @@ JSValueRef JSIPCSemaphore::waitFor(JSContextRef context, JSObjectRef, JSObjectRe SharedMemory::Handle JSSharedMemory::createHandle(SharedMemory::Protection protection) { if (auto handle = m_sharedMemory->createHandle(protection)) - return *handle; + return WTFMove(*handle); return { }; }