[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
aroben at apple.com
aroben at apple.com
Wed Dec 22 14:29:52 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 8874c6cb53e06b9f6de58a9c3ccae62de86e6066
Author: aroben at apple.com <aroben at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Oct 11 22:15:21 2010 +0000
Implement SharedMemory on Windows
This makes visited links be colored correctly.
Fixes <http://webkit.org/b/47499> <rdar://problem/8422725>.
Reviewed by Anders Carlsson.
* Platform/SharedMemory.h: Add Windows-specific members to
SharedMemory and SharedMemory::Handle.
* Platform/win/SharedMemoryWin.cpp:
(WebKit::SharedMemory::Handle::Handle): Initialize our members.
(WebKit::SharedMemory::Handle::~Handle): Close our HANDLE if we have
one.
(WebKit::SharedMemory::Handle::encode): Encode our size, HANDLE, and
PID. Null out our HANDLE member, as it is now the receiving process's
responsibility to close the HANDLE.
(WebKit::SharedMemory::Handle::decode): Copy the handle from the
sending process into the receiving process and close the HANDLE the
sending process gave us.
(WebKit::SharedMemory::create): Map some memory and store it in a new
SharedMemory object.
(WebKit::accessRights): Helper function to convert a
SharedMemory::Protection to a file-mapping access right.
(WebKit::SharedMemory::create): Map the memory represented by the
Handle, and adopt the HANDLE from it.
(WebKit::SharedMemory::~SharedMemory): Clean up our memory mapping.
(WebKit::SharedMemory::createHandle): Give the Handle a copy of our
HANDLE with the specified protection.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index a7258cd..28bc837 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,5 +1,38 @@
2010-10-11 Adam Roben <aroben at apple.com>
+ Implement SharedMemory on Windows
+
+ This makes visited links be colored correctly.
+
+ Fixes <http://webkit.org/b/47499> <rdar://problem/8422725>.
+
+ Reviewed by Anders Carlsson.
+
+ * Platform/SharedMemory.h: Add Windows-specific members to
+ SharedMemory and SharedMemory::Handle.
+
+ * Platform/win/SharedMemoryWin.cpp:
+ (WebKit::SharedMemory::Handle::Handle): Initialize our members.
+ (WebKit::SharedMemory::Handle::~Handle): Close our HANDLE if we have
+ one.
+ (WebKit::SharedMemory::Handle::encode): Encode our size, HANDLE, and
+ PID. Null out our HANDLE member, as it is now the receiving process's
+ responsibility to close the HANDLE.
+ (WebKit::SharedMemory::Handle::decode): Copy the handle from the
+ sending process into the receiving process and close the HANDLE the
+ sending process gave us.
+ (WebKit::SharedMemory::create): Map some memory and store it in a new
+ SharedMemory object.
+ (WebKit::accessRights): Helper function to convert a
+ SharedMemory::Protection to a file-mapping access right.
+ (WebKit::SharedMemory::create): Map the memory represented by the
+ Handle, and adopt the HANDLE from it.
+ (WebKit::SharedMemory::~SharedMemory): Clean up our memory mapping.
+ (WebKit::SharedMemory::createHandle): Give the Handle a copy of our
+ HANDLE with the specified protection.
+
+2010-10-11 Adam Roben <aroben at apple.com>
+
Make it possible to restart a RunLoop::Timer on Windows
Fixes <http://webkit.org/b/47505> RunLoop::Timer only ever fires once
diff --git a/WebKit2/Platform/SharedMemory.h b/WebKit2/Platform/SharedMemory.h
index 11ed7e4..25d9c24 100644
--- a/WebKit2/Platform/SharedMemory.h
+++ b/WebKit2/Platform/SharedMemory.h
@@ -58,6 +58,8 @@ public:
friend class SharedMemory;
#if PLATFORM(MAC)
mutable mach_port_t m_port;
+#elif PLATFORM(WIN)
+ mutable HANDLE m_handle;
#endif
size_t m_size;
};
@@ -81,6 +83,9 @@ public:
private:
size_t m_size;
void* m_data;
+#if PLATFORM(WIN)
+ HANDLE m_handle;
+#endif
};
};
diff --git a/WebKit2/Platform/win/SharedMemoryWin.cpp b/WebKit2/Platform/win/SharedMemoryWin.cpp
index b9ccc4c..260783a 100644
--- a/WebKit2/Platform/win/SharedMemoryWin.cpp
+++ b/WebKit2/Platform/win/SharedMemoryWin.cpp
@@ -25,53 +25,151 @@
#include "SharedMemory.h"
-#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1
-#include "NotImplemented.h"
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+#include <wtf/RefPtr.h>
namespace WebKit {
SharedMemory::Handle::Handle()
+ : m_handle(0)
+ , m_size(0)
{
- notImplemented();
}
SharedMemory::Handle::~Handle()
{
- notImplemented();
+ if (!m_handle)
+ return;
+
+ ::CloseHandle(m_handle);
}
void SharedMemory::Handle::encode(CoreIPC::ArgumentEncoder* encoder) const
{
- notImplemented();
+ encoder->encodeUInt64(m_size);
+
+ // Hand off ownership of our HANDLE to the receiving process. It will close it for us.
+ // FIXME: If the receiving process crashes before it receives the memory, the memory will be
+ // leaked. See <http://webkit.org/b/47502>.
+ encoder->encodeUInt64(reinterpret_cast<uint64_t>(m_handle));
+ m_handle = 0;
+
+ // Send along our PID so that the receiving process can duplicate the HANDLE for its own use.
+ encoder->encodeUInt32(::GetCurrentProcessId());
}
bool SharedMemory::Handle::decode(CoreIPC::ArgumentDecoder* decoder, Handle& handle)
{
- notImplemented();
- return false;
+ ASSERT_ARG(handle, !handle.m_handle);
+ ASSERT_ARG(handle, !handle.m_size);
+
+ uint64_t size;
+ if (!decoder->decodeUInt64(size))
+ return false;
+
+ uint64_t sourceHandle;
+ if (!decoder->decodeUInt64(sourceHandle))
+ return false;
+
+ uint32_t sourcePID;
+ if (!decoder->decodeUInt32(sourcePID))
+ return false;
+
+ HANDLE sourceProcess = ::OpenProcess(PROCESS_DUP_HANDLE, FALSE, sourcePID);
+ if (!sourceProcess)
+ return false;
+
+ // Copy the handle into our process and close the handle that the sending process created for us.
+ HANDLE duplicatedHandle;
+ BOOL success = ::DuplicateHandle(sourceProcess, reinterpret_cast<HANDLE>(sourceHandle), ::GetCurrentProcess(), &duplicatedHandle, 0, FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
+
+ ::CloseHandle(sourceProcess);
+
+ if (!success)
+ return false;
+
+ handle.m_handle = duplicatedHandle;
+ handle.m_size = size;
+ return true;
}
PassRefPtr<SharedMemory> SharedMemory::create(size_t size)
{
- notImplemented();
+ HANDLE handle = ::CreateFileMappingW(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, 0);
+ if (!handle)
+ return 0;
+
+ void* baseAddress = ::MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, size);
+ if (!baseAddress) {
+ ::CloseHandle(handle);
+ return 0;
+ }
+
+ RefPtr<SharedMemory> memory = adoptRef(new SharedMemory);
+ memory->m_size = size;
+ memory->m_data = baseAddress;
+ memory->m_handle = handle;
+
+ return memory.release();
+}
+
+static DWORD accessRights(SharedMemory::Protection protection)
+{
+ switch (protection) {
+ case SharedMemory::ReadOnly:
+ return FILE_MAP_READ;
+ case SharedMemory::ReadWrite:
+ // FILE_MAP_WRITE implies read access, too.
+ return FILE_MAP_WRITE;
+ }
+
+ ASSERT_NOT_REACHED();
return 0;
}
PassRefPtr<SharedMemory> SharedMemory::create(const Handle& handle, Protection protection)
{
- notImplemented();
- return 0;
+ DWORD desiredAccess = accessRights(protection);
+
+ void* baseAddress = ::MapViewOfFile(handle.m_handle, desiredAccess, 0, 0, handle.m_size);
+ if (!baseAddress)
+ return 0;
+
+ RefPtr<SharedMemory> memory = adoptRef(new SharedMemory);
+ memory->m_size = handle.m_size;
+ memory->m_data = baseAddress;
+
+ // Adopt the HANDLE.
+ memory->m_handle = handle.m_handle;
+ handle.m_handle = 0;
+
+ return memory.release();
}
SharedMemory::~SharedMemory()
{
- notImplemented();
+ ASSERT(m_data);
+ ASSERT(m_handle);
+
+ ::UnmapViewOfFile(m_data);
+ ::CloseHandle(m_handle);
}
bool SharedMemory::createHandle(Handle& handle, Protection protection)
{
- notImplemented();
- return false;
+ ASSERT_ARG(handle, !handle.m_handle);
+ ASSERT_ARG(handle, !handle.m_size);
+
+ HANDLE processHandle = ::GetCurrentProcess();
+
+ HANDLE duplicatedHandle;
+ if (!::DuplicateHandle(processHandle, m_handle, processHandle, &duplicatedHandle, accessRights(protection), FALSE, 0))
+ return false;
+
+ handle.m_handle = duplicatedHandle;
+ handle.m_size = m_size;
+ return true;
}
unsigned SharedMemory::systemPageSize()
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list