<!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>[208081] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208081">208081</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2016-10-28 16:39:36 -0700 (Fri, 28 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Rename SharedMemoryMac to SharedMemoryCocoa
https://bugs.webkit.org/show_bug.cgi?id=164156

Patch by Megan Gardner &lt;megan_gardner@apple.com&gt; on 2016-10-28
Reviewed by Alex Christensen.

Renamed SharedMemoryMac to SharedMemoryCocoa, as it runs on all cocoa platforms, not exclusively just mac, and
thus should be named to reflect that reality.

* Platform/cocoa: Added.
* Platform/cocoa/SharedMemoryCocoa.cpp: Copied from Source/WebKit2/Platform/mac/SharedMemoryMac.cpp.
* Platform/mac/SharedMemoryMac.cpp: Removed.
* WebKit2.xcodeproj/project.pbxproj:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/Source/WebKit2/Platform/cocoa/</li>
<li><a href="#trunkSourceWebKit2PlatformcocoaSharedMemoryCocoacpp">trunk/Source/WebKit2/Platform/cocoa/SharedMemoryCocoa.cpp</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2PlatformmacSharedMemoryMaccpp">trunk/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (208080 => 208081)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-10-28 23:35:14 UTC (rev 208080)
+++ trunk/Source/WebKit2/ChangeLog        2016-10-28 23:39:36 UTC (rev 208081)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2016-10-28  Megan Gardner  &lt;megan_gardner@apple.com&gt;
+
+        Rename SharedMemoryMac to SharedMemoryCocoa
+        https://bugs.webkit.org/show_bug.cgi?id=164156
+
+        Reviewed by Alex Christensen.
+
+        Renamed SharedMemoryMac to SharedMemoryCocoa, as it runs on all cocoa platforms, not exclusively just mac, and
+        thus should be named to reflect that reality.
+
+        * Platform/cocoa: Added.
+        * Platform/cocoa/SharedMemoryCocoa.cpp: Copied from Source/WebKit2/Platform/mac/SharedMemoryMac.cpp.
+        * Platform/mac/SharedMemoryMac.cpp: Removed.
+        * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2016-10-28  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Enable CFNetwork connection cache fast lane for WebKit2
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformcocoaSharedMemoryCocoacppfromrev208080trunkSourceWebKit2PlatformmacSharedMemoryMaccpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/Platform/cocoa/SharedMemoryCocoa.cpp (from rev 208080, trunk/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp) (0 => 208081)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/cocoa/SharedMemoryCocoa.cpp                                (rev 0)
+++ trunk/Source/WebKit2/Platform/cocoa/SharedMemoryCocoa.cpp        2016-10-28 23:39:36 UTC (rev 208081)
</span><span class="lines">@@ -0,0 +1,264 @@
</span><ins>+/*
+ * Copyright (C) 2010 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 &quot;config.h&quot;
+#include &quot;SharedMemory.h&quot;
+
+#include &quot;Decoder.h&quot;
+#include &quot;Encoder.h&quot;
+#include &quot;Logging.h&quot;
+#include &quot;MachPort.h&quot;
+#include &lt;WebCore/MachSendRight.h&gt;
+#include &lt;WebCore/MachVMSPI.h&gt;
+#include &lt;mach/mach_error.h&gt;
+#include &lt;mach/mach_port.h&gt;
+#include &lt;mach/vm_map.h&gt;
+#include &lt;wtf/RefPtr.h&gt;
+
+namespace WebKit {
+
+SharedMemory::Handle::Handle()
+    : m_port(MACH_PORT_NULL)
+    , m_size(0)
+{
+}
+
+SharedMemory::Handle::~Handle()
+{
+    clear();
+}
+
+bool SharedMemory::Handle::isNull() const
+{
+    return !m_port;
+}
+
+void SharedMemory::Handle::clear()
+{
+    if (m_port)
+        mach_port_deallocate(mach_task_self(), m_port);
+
+    m_port = MACH_PORT_NULL;
+    m_size = 0;
+}
+
+void SharedMemory::Handle::encode(IPC::Encoder&amp; encoder) const
+{
+    encoder &lt;&lt; static_cast&lt;uint64_t&gt;(m_size);
+    encoder &lt;&lt; IPC::MachPort(m_port, MACH_MSG_TYPE_MOVE_SEND);
+    m_port = MACH_PORT_NULL;
+}
+
+bool SharedMemory::Handle::decode(IPC::Decoder&amp; decoder, Handle&amp; handle)
+{
+    ASSERT(!handle.m_port);
+    ASSERT(!handle.m_size);
+
+    uint64_t size;
+    if (!decoder.decode(size))
+        return false;
+
+    IPC::MachPort machPort;
+    if (!decoder.decode(machPort))
+        return false;
+    
+    handle.m_size = size;
+    handle.m_port = machPort.port();
+    return true;
+}
+
+static inline void* toPointer(mach_vm_address_t address)
+{
+    return reinterpret_cast&lt;void*&gt;(static_cast&lt;uintptr_t&gt;(address));
+}
+
+static inline mach_vm_address_t toVMAddress(void* pointer)
+{
+    return static_cast&lt;mach_vm_address_t&gt;(reinterpret_cast&lt;uintptr_t&gt;(pointer));
+}
+    
+RefPtr&lt;SharedMemory&gt; SharedMemory::allocate(size_t size)
+{
+    ASSERT(size);
+
+    mach_vm_address_t address;
+    kern_return_t kr = mach_vm_allocate(mach_task_self(), &amp;address, round_page(size), VM_FLAGS_ANYWHERE);
+    if (kr != KERN_SUCCESS) {
+#if RELEASE_LOG_DISABLED
+        LOG_ERROR(&quot;Failed to allocate mach_vm_allocate shared memory (%zu bytes). %s (%x)&quot;, size, mach_error_string(kr), kr);
+#else
+        RELEASE_LOG_ERROR(VirtualMemory, &quot;%p - SharedMemory::allocate: Failed to allocate mach_vm_allocate shared memory (%zu bytes). %{public}s (%x)&quot;, nullptr, size, mach_error_string(kr), kr);
+#endif
+        return nullptr;
+    }
+
+    auto sharedMemory = adoptRef(*new SharedMemory);
+    sharedMemory-&gt;m_size = size;
+    sharedMemory-&gt;m_data = toPointer(address);
+    sharedMemory-&gt;m_port = MACH_PORT_NULL;
+    sharedMemory-&gt;m_protection = Protection::ReadWrite;
+
+    return WTFMove(sharedMemory);
+}
+
+static inline vm_prot_t machProtection(SharedMemory::Protection protection)
+{
+    switch (protection) {
+    case SharedMemory::Protection::ReadOnly:
+        return VM_PROT_READ;
+    case SharedMemory::Protection::ReadWrite:
+        return VM_PROT_READ | VM_PROT_WRITE;
+    }
+
+    ASSERT_NOT_REACHED();
+    return VM_PROT_NONE;
+}
+
+static WebCore::MachSendRight makeMemoryEntry(size_t size, vm_offset_t offset, SharedMemory::Protection protection, mach_port_t parentEntry)
+{
+    memory_object_size_t memoryObjectSize = round_page(size);
+
+    mach_port_t port;
+    kern_return_t kr = mach_make_memory_entry_64(mach_task_self(), &amp;memoryObjectSize, offset, machProtection(protection) | VM_PROT_IS_MASK | MAP_MEM_VM_SHARE, &amp;port, parentEntry);
+    if (kr != KERN_SUCCESS) {
+#if RELEASE_LOG_DISABLED
+        LOG_ERROR(&quot;Failed to create a mach port for shared memory. %s (%x)&quot;, mach_error_string(kr), kr);
+#else
+        RELEASE_LOG_ERROR(VirtualMemory, &quot;%p - SharedMemory::makeMemoryEntry: Failed to create a mach port for shared memory. %{public}s (%x)&quot;, nullptr, mach_error_string(kr), kr);
+#endif
+        return { };
+    }
+
+    RELEASE_ASSERT(memoryObjectSize &gt;= size);
+
+    return WebCore::MachSendRight::adopt(port);
+}
+
+RefPtr&lt;SharedMemory&gt; SharedMemory::create(void* data, size_t size, Protection protection)
+{
+    ASSERT(size);
+
+    auto sendRight = makeMemoryEntry(size, toVMAddress(data), protection, MACH_PORT_NULL);
+    if (!sendRight)
+        return nullptr;
+
+    auto sharedMemory(adoptRef(*new SharedMemory));
+    sharedMemory-&gt;m_size = size;
+    sharedMemory-&gt;m_data = nullptr;
+    sharedMemory-&gt;m_port = sendRight.leakSendRight();
+    sharedMemory-&gt;m_protection = protection;
+
+    return WTFMove(sharedMemory);
+}
+
+RefPtr&lt;SharedMemory&gt; SharedMemory::map(const Handle&amp; handle, Protection protection)
+{
+    if (handle.isNull())
+        return 0;
+    
+    ASSERT(round_page(handle.m_size) == handle.m_size);
+
+    vm_prot_t vmProtection = machProtection(protection);
+    mach_vm_address_t mappedAddress = 0;
+    kern_return_t kr = mach_vm_map(mach_task_self(), &amp;mappedAddress, round_page(handle.m_size), 0, VM_FLAGS_ANYWHERE, handle.m_port, 0, false, vmProtection, vmProtection, VM_INHERIT_NONE);
+#if RELEASE_LOG_DISABLED
+    if (kr != KERN_SUCCESS)
+        return nullptr;
+#else
+    if (kr != KERN_SUCCESS) {
+        RELEASE_LOG_ERROR(VirtualMemory, &quot;%p - SharedMemory::map: Failed to map shared memory. %{public}s (%x)&quot;, nullptr, mach_error_string(kr), kr);
+        return nullptr;
+    }
+#endif
+
+    auto sharedMemory(adoptRef(*new SharedMemory));
+    sharedMemory-&gt;m_size = handle.m_size;
+    sharedMemory-&gt;m_data = toPointer(mappedAddress);
+    sharedMemory-&gt;m_port = MACH_PORT_NULL;
+    sharedMemory-&gt;m_protection = protection;
+
+    return WTFMove(sharedMemory);
+}
+
+SharedMemory::~SharedMemory()
+{
+    if (m_data) {
+        kern_return_t kr = mach_vm_deallocate(mach_task_self(), toVMAddress(m_data), round_page(m_size));
+#if RELEASE_LOG_DISABLED
+        ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
+#else
+        if (kr != KERN_SUCCESS) {
+            RELEASE_LOG_ERROR(VirtualMemory, &quot;%p - SharedMemory::~SharedMemory: Failed to deallocate shared memory. %{public}s (%x)&quot;, this, mach_error_string(kr), kr);
+            ASSERT_NOT_REACHED();
+        }
+#endif
+    }
+
+    if (m_port) {
+        kern_return_t kr = mach_port_deallocate(mach_task_self(), m_port);
+#if RELEASE_LOG_DISABLED
+        ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
+#else
+        if (kr != KERN_SUCCESS) {
+            RELEASE_LOG_ERROR(VirtualMemory, &quot;%p - SharedMemory::~SharedMemory: Failed to deallocate port. %{public}s (%x)&quot;, this, mach_error_string(kr), kr);
+            ASSERT_NOT_REACHED();
+        }
+#endif
+    }        
+}
+    
+bool SharedMemory::createHandle(Handle&amp; handle, Protection protection)
+{
+    ASSERT(!handle.m_port);
+    ASSERT(!handle.m_size);
+
+    auto sendRight = createSendRight(protection);
+    if (!sendRight)
+        return false;
+
+    handle.m_port = sendRight.leakSendRight();
+    handle.m_size = round_page(m_size);
+
+    return true;
+}
+
+unsigned SharedMemory::systemPageSize()
+{
+    return vm_page_size;
+}
+
+WebCore::MachSendRight SharedMemory::createSendRight(Protection protection) const
+{
+    ASSERT(m_protection == protection || m_protection == Protection::ReadWrite &amp;&amp; protection == Protection::ReadOnly);
+    ASSERT(!!m_data ^ !!m_port);
+
+    if (m_port &amp;&amp; m_protection == protection)
+        return WebCore::MachSendRight::create(m_port);
+
+    ASSERT(m_data);
+    return makeMemoryEntry(m_size, toVMAddress(m_data), protection, MACH_PORT_NULL);
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2PlatformmacSharedMemoryMaccpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp (208080 => 208081)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp        2016-10-28 23:35:14 UTC (rev 208080)
+++ trunk/Source/WebKit2/Platform/mac/SharedMemoryMac.cpp        2016-10-28 23:39:36 UTC (rev 208081)
</span><span class="lines">@@ -1,264 +0,0 @@
</span><del>-/*
- * Copyright (C) 2010 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 &quot;config.h&quot;
-#include &quot;SharedMemory.h&quot;
-
-#include &quot;Decoder.h&quot;
-#include &quot;Encoder.h&quot;
-#include &quot;Logging.h&quot;
-#include &quot;MachPort.h&quot;
-#include &lt;WebCore/MachSendRight.h&gt;
-#include &lt;WebCore/MachVMSPI.h&gt;
-#include &lt;mach/mach_error.h&gt;
-#include &lt;mach/mach_port.h&gt;
-#include &lt;mach/vm_map.h&gt;
-#include &lt;wtf/RefPtr.h&gt;
-
-namespace WebKit {
-
-SharedMemory::Handle::Handle()
-    : m_port(MACH_PORT_NULL)
-    , m_size(0)
-{
-}
-
-SharedMemory::Handle::~Handle()
-{
-    clear();
-}
-
-bool SharedMemory::Handle::isNull() const
-{
-    return !m_port;
-}
-
-void SharedMemory::Handle::clear()
-{
-    if (m_port)
-        mach_port_deallocate(mach_task_self(), m_port);
-
-    m_port = MACH_PORT_NULL;
-    m_size = 0;
-}
-
-void SharedMemory::Handle::encode(IPC::Encoder&amp; encoder) const
-{
-    encoder &lt;&lt; static_cast&lt;uint64_t&gt;(m_size);
-    encoder &lt;&lt; IPC::MachPort(m_port, MACH_MSG_TYPE_MOVE_SEND);
-    m_port = MACH_PORT_NULL;
-}
-
-bool SharedMemory::Handle::decode(IPC::Decoder&amp; decoder, Handle&amp; handle)
-{
-    ASSERT(!handle.m_port);
-    ASSERT(!handle.m_size);
-
-    uint64_t size;
-    if (!decoder.decode(size))
-        return false;
-
-    IPC::MachPort machPort;
-    if (!decoder.decode(machPort))
-        return false;
-    
-    handle.m_size = size;
-    handle.m_port = machPort.port();
-    return true;
-}
-
-static inline void* toPointer(mach_vm_address_t address)
-{
-    return reinterpret_cast&lt;void*&gt;(static_cast&lt;uintptr_t&gt;(address));
-}
-
-static inline mach_vm_address_t toVMAddress(void* pointer)
-{
-    return static_cast&lt;mach_vm_address_t&gt;(reinterpret_cast&lt;uintptr_t&gt;(pointer));
-}
-    
-RefPtr&lt;SharedMemory&gt; SharedMemory::allocate(size_t size)
-{
-    ASSERT(size);
-
-    mach_vm_address_t address;
-    kern_return_t kr = mach_vm_allocate(mach_task_self(), &amp;address, round_page(size), VM_FLAGS_ANYWHERE);
-    if (kr != KERN_SUCCESS) {
-#if RELEASE_LOG_DISABLED
-        LOG_ERROR(&quot;Failed to allocate mach_vm_allocate shared memory (%zu bytes). %s (%x)&quot;, size, mach_error_string(kr), kr);
-#else
-        RELEASE_LOG_ERROR(VirtualMemory, &quot;%p - SharedMemory::allocate: Failed to allocate mach_vm_allocate shared memory (%zu bytes). %{public}s (%x)&quot;, nullptr, size, mach_error_string(kr), kr);
-#endif
-        return nullptr;
-    }
-
-    auto sharedMemory = adoptRef(*new SharedMemory);
-    sharedMemory-&gt;m_size = size;
-    sharedMemory-&gt;m_data = toPointer(address);
-    sharedMemory-&gt;m_port = MACH_PORT_NULL;
-    sharedMemory-&gt;m_protection = Protection::ReadWrite;
-
-    return WTFMove(sharedMemory);
-}
-
-static inline vm_prot_t machProtection(SharedMemory::Protection protection)
-{
-    switch (protection) {
-    case SharedMemory::Protection::ReadOnly:
-        return VM_PROT_READ;
-    case SharedMemory::Protection::ReadWrite:
-        return VM_PROT_READ | VM_PROT_WRITE;
-    }
-
-    ASSERT_NOT_REACHED();
-    return VM_PROT_NONE;
-}
-
-static WebCore::MachSendRight makeMemoryEntry(size_t size, vm_offset_t offset, SharedMemory::Protection protection, mach_port_t parentEntry)
-{
-    memory_object_size_t memoryObjectSize = round_page(size);
-
-    mach_port_t port;
-    kern_return_t kr = mach_make_memory_entry_64(mach_task_self(), &amp;memoryObjectSize, offset, machProtection(protection) | VM_PROT_IS_MASK | MAP_MEM_VM_SHARE, &amp;port, parentEntry);
-    if (kr != KERN_SUCCESS) {
-#if RELEASE_LOG_DISABLED
-        LOG_ERROR(&quot;Failed to create a mach port for shared memory. %s (%x)&quot;, mach_error_string(kr), kr);
-#else
-        RELEASE_LOG_ERROR(VirtualMemory, &quot;%p - SharedMemory::makeMemoryEntry: Failed to create a mach port for shared memory. %{public}s (%x)&quot;, nullptr, mach_error_string(kr), kr);
-#endif
-        return { };
-    }
-
-    RELEASE_ASSERT(memoryObjectSize &gt;= size);
-
-    return WebCore::MachSendRight::adopt(port);
-}
-
-RefPtr&lt;SharedMemory&gt; SharedMemory::create(void* data, size_t size, Protection protection)
-{
-    ASSERT(size);
-
-    auto sendRight = makeMemoryEntry(size, toVMAddress(data), protection, MACH_PORT_NULL);
-    if (!sendRight)
-        return nullptr;
-
-    auto sharedMemory(adoptRef(*new SharedMemory));
-    sharedMemory-&gt;m_size = size;
-    sharedMemory-&gt;m_data = nullptr;
-    sharedMemory-&gt;m_port = sendRight.leakSendRight();
-    sharedMemory-&gt;m_protection = protection;
-
-    return WTFMove(sharedMemory);
-}
-
-RefPtr&lt;SharedMemory&gt; SharedMemory::map(const Handle&amp; handle, Protection protection)
-{
-    if (handle.isNull())
-        return 0;
-    
-    ASSERT(round_page(handle.m_size) == handle.m_size);
-
-    vm_prot_t vmProtection = machProtection(protection);
-    mach_vm_address_t mappedAddress = 0;
-    kern_return_t kr = mach_vm_map(mach_task_self(), &amp;mappedAddress, round_page(handle.m_size), 0, VM_FLAGS_ANYWHERE, handle.m_port, 0, false, vmProtection, vmProtection, VM_INHERIT_NONE);
-#if RELEASE_LOG_DISABLED
-    if (kr != KERN_SUCCESS)
-        return nullptr;
-#else
-    if (kr != KERN_SUCCESS) {
-        RELEASE_LOG_ERROR(VirtualMemory, &quot;%p - SharedMemory::map: Failed to map shared memory. %{public}s (%x)&quot;, nullptr, mach_error_string(kr), kr);
-        return nullptr;
-    }
-#endif
-
-    auto sharedMemory(adoptRef(*new SharedMemory));
-    sharedMemory-&gt;m_size = handle.m_size;
-    sharedMemory-&gt;m_data = toPointer(mappedAddress);
-    sharedMemory-&gt;m_port = MACH_PORT_NULL;
-    sharedMemory-&gt;m_protection = protection;
-
-    return WTFMove(sharedMemory);
-}
-
-SharedMemory::~SharedMemory()
-{
-    if (m_data) {
-        kern_return_t kr = mach_vm_deallocate(mach_task_self(), toVMAddress(m_data), round_page(m_size));
-#if RELEASE_LOG_DISABLED
-        ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
-#else
-        if (kr != KERN_SUCCESS) {
-            RELEASE_LOG_ERROR(VirtualMemory, &quot;%p - SharedMemory::~SharedMemory: Failed to deallocate shared memory. %{public}s (%x)&quot;, this, mach_error_string(kr), kr);
-            ASSERT_NOT_REACHED();
-        }
-#endif
-    }
-
-    if (m_port) {
-        kern_return_t kr = mach_port_deallocate(mach_task_self(), m_port);
-#if RELEASE_LOG_DISABLED
-        ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
-#else
-        if (kr != KERN_SUCCESS) {
-            RELEASE_LOG_ERROR(VirtualMemory, &quot;%p - SharedMemory::~SharedMemory: Failed to deallocate port. %{public}s (%x)&quot;, this, mach_error_string(kr), kr);
-            ASSERT_NOT_REACHED();
-        }
-#endif
-    }        
-}
-    
-bool SharedMemory::createHandle(Handle&amp; handle, Protection protection)
-{
-    ASSERT(!handle.m_port);
-    ASSERT(!handle.m_size);
-
-    auto sendRight = createSendRight(protection);
-    if (!sendRight)
-        return false;
-
-    handle.m_port = sendRight.leakSendRight();
-    handle.m_size = round_page(m_size);
-
-    return true;
-}
-
-unsigned SharedMemory::systemPageSize()
-{
-    return vm_page_size;
-}
-
-WebCore::MachSendRight SharedMemory::createSendRight(Protection protection) const
-{
-    ASSERT(m_protection == protection || m_protection == Protection::ReadWrite &amp;&amp; protection == Protection::ReadOnly);
-    ASSERT(!!m_data ^ !!m_port);
-
-    if (m_port &amp;&amp; m_protection == protection)
-        return WebCore::MachSendRight::create(m_port);
-
-    ASSERT(m_data);
-    return makeMemoryEntry(m_size, toVMAddress(m_data), protection, MACH_PORT_NULL);
-}
-
-} // namespace WebKit
</del></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (208080 => 208081)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2016-10-28 23:35:14 UTC (rev 208080)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2016-10-28 23:39:36 UTC (rev 208081)
</span><span class="lines">@@ -177,7 +177,6 @@
</span><span class="cx">                 1A24B5F211F531E800C38269 /* MachUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24B5F011F531E800C38269 /* MachUtilities.cpp */; };
</span><span class="cx">                 1A24B5F311F531E800C38269 /* MachUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A24B5F111F531E800C38269 /* MachUtilities.h */; };
</span><span class="cx">                 1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A24BED3120894D100FBB059 /* SharedMemory.h */; };
</span><del>-                1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */; };
</del><span class="cx">                 1A256E3718A1A788006FB922 /* WKNavigationAction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A256E3518A1A788006FB922 /* WKNavigationAction.mm */; };
</span><span class="cx">                 1A256E3818A1A788006FB922 /* WKNavigationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A256E3618A1A788006FB922 /* WKNavigationAction.h */; settings = {ATTRIBUTES = (Public, ); }; };
</span><span class="cx">                 1A256E3A18A1A7DF006FB922 /* WKNavigationActionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A256E3918A1A7DF006FB922 /* WKNavigationActionInternal.h */; };
</span><span class="lines">@@ -859,6 +858,7 @@
</span><span class="cx">                 3F87B9BD158940120090FF62 /* WebColorChooser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F87B9BA15893F630090FF62 /* WebColorChooser.cpp */; };
</span><span class="cx">                 3F87B9BE158940190090FF62 /* WebColorChooser.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F87B9BB15893F630090FF62 /* WebColorChooser.h */; };
</span><span class="cx">                 3F87B9C0158940D80090FF62 /* WebColorPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F87B9BF158940D80090FF62 /* WebColorPicker.h */; };
</span><ins>+                4450AEC01DC3FAE5009943F2 /* SharedMemoryCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */; };
</ins><span class="cx">                 4A3CC18A19B063E700D14AEF /* UserMediaPermissionRequestManagerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A410F3919AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.cpp */; };
</span><span class="cx">                 4A3CC18B19B0640F00D14AEF /* UserMediaPermissionRequestManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A410F3A19AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.h */; };
</span><span class="cx">                 4A3CC18C19B0641500D14AEF /* UserMediaPermissionRequestProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A410F3B19AF7B04002EBAB5 /* UserMediaPermissionRequestProxy.cpp */; };
</span><span class="lines">@@ -2181,7 +2181,6 @@
</span><span class="cx">                 1A24B5F011F531E800C38269 /* MachUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MachUtilities.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1A24B5F111F531E800C38269 /* MachUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MachUtilities.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1A24BED3120894D100FBB059 /* SharedMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedMemory.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemoryMac.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 1A256E3518A1A788006FB922 /* WKNavigationAction.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNavigationAction.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1A256E3618A1A788006FB922 /* WKNavigationAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationAction.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1A256E3918A1A7DF006FB922 /* WKNavigationActionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationActionInternal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -2919,6 +2918,7 @@
</span><span class="cx">                 3F87B9BA15893F630090FF62 /* WebColorChooser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebColorChooser.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3F87B9BB15893F630090FF62 /* WebColorChooser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebColorChooser.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3F87B9BF158940D80090FF62 /* WebColorPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebColorPicker.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SharedMemoryCocoa.cpp; path = cocoa/SharedMemoryCocoa.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 4A410F3519AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserMediaPermissionRequest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 4A410F3619AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserMediaPermissionRequest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 4A410F3919AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaPermissionRequestManagerProxy.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4481,7 +4481,6 @@
</span><span class="cx">                                 1A24B5F111F531E800C38269 /* MachUtilities.h */,
</span><span class="cx">                                 51933DEB1965EB24008AC3EA /* MenuUtilities.h */,
</span><span class="cx">                                 51933DEC1965EB24008AC3EA /* MenuUtilities.mm */,
</span><del>-                                1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */,
</del><span class="cx">                                 296BD85B15019BC30071F424 /* StringUtilities.h */,
</span><span class="cx">                                 296BD85C15019BC30071F424 /* StringUtilities.mm */,
</span><span class="cx">                         );
</span><span class="lines">@@ -5414,6 +5413,14 @@
</span><span class="cx">                         path = Resources/mac;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="cx">                 };
</span><ins>+                4450AEBE1DC3FAAC009943F2 /* cocoa */ = {
+                        isa = PBXGroup;
+                        children = (
+                                4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */,
+                        );
+                        name = cocoa;
+                        sourceTree = &quot;&lt;group&gt;&quot;;
+                };
</ins><span class="cx">                 4A410F4119AF7B27002EBAB5 /* MediaStream */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="lines">@@ -6686,6 +6693,7 @@
</span><span class="cx">                 BC2E6E74114196F000A63B1E /* Platform */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                4450AEBE1DC3FAAC009943F2 /* cocoa */,
</ins><span class="cx">                                 3709504118A88BA40087AE5D /* cf */,
</span><span class="cx">                                 1AA2E51A12E4C05600BC4966 /* cg */,
</span><span class="cx">                                 3709504218A88CDE0087AE5D /* foundation */,
</span><span class="lines">@@ -9367,7 +9375,6 @@
</span><span class="cx">                                 1A6420E412DCE2FF00CAAE2C /* ShareableBitmap.cpp in Sources */,
</span><span class="cx">                                 C01A260112662F2100C9ED55 /* ShareableBitmapCG.cpp in Sources */,
</span><span class="cx">                                 51217460164C20E30037A5C1 /* ShareableResource.cpp in Sources */,
</span><del>-                                1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */,
</del><span class="cx">                                 2DAF06D718BD1A470081CEB1 /* SmartMagnificationController.mm in Sources */,
</span><span class="cx">                                 2DE6943D18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp in Sources */,
</span><span class="cx">                                 5272B28A1406985D0096A5D0 /* StatisticsData.cpp in Sources */,
</span><span class="lines">@@ -9503,6 +9510,7 @@
</span><span class="cx">                                 510523791C73DA77007993CB /* WebIDBConnectionToClientMessageReceiver.cpp in Sources */,
</span><span class="cx">                                 514129951C6428C20059E714 /* WebIDBConnectionToServer.cpp in Sources */,
</span><span class="cx">                                 510523751C73D38F007993CB /* WebIDBConnectionToServerMessageReceiver.cpp in Sources */,
</span><ins>+                                4450AEC01DC3FAE5009943F2 /* SharedMemoryCocoa.cpp in Sources */,
</ins><span class="cx">                                 51A587801D1C5081004BA9AF /* WebIDBResult.cpp in Sources */,
</span><span class="cx">                                 BCCF6ABC12C91EF9008F9C35 /* WebImage.cpp in Sources */,
</span><span class="cx">                                 1C8E28211275D15400BC7BD0 /* WebInspector.cpp in Sources */,
</span></span></pre>
</div>
</div>

</body>
</html>