<!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>[177516] trunk/Source</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/177516">177516</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2014-12-18 12:29:19 -0800 (Thu, 18 Dec 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add a MachSendRight class to WebCore and use it in IOSurface
https://bugs.webkit.org/show_bug.cgi?id=139787

Reviewed by Tim Horton.

Source/WebCore:

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* platform/cocoa/MachSendRight.cpp: Added.
(WebCore::retainSendRight):
(WebCore::releaseSendRight):
(WebCore::MachSendRight::adopt):
(WebCore::MachSendRight::create):
(WebCore::MachSendRight::MachSendRight):
(WebCore::MachSendRight::~MachSendRight):
(WebCore::MachSendRight::operator=):
(WebCore::MachSendRight::leakSendRight):
* platform/cocoa/MachSendRight.h: Added.
* platform/graphics/cocoa/IOSurface.h:
* platform/graphics/cocoa/IOSurface.mm:
(IOSurface::createSendRight):
(IOSurface::createMachPort): Deleted.

Source/WebKit2:

* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::encode):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh">trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm">trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformcocoaMachSendRightcpp">trunk/Source/WebCore/platform/cocoa/MachSendRight.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaMachSendRighth">trunk/Source/WebCore/platform/cocoa/MachSendRight.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (177515 => 177516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-12-18 20:25:21 UTC (rev 177515)
+++ trunk/Source/WebCore/ChangeLog        2014-12-18 20:29:19 UTC (rev 177516)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2014-12-18  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Add a MachSendRight class to WebCore and use it in IOSurface
+        https://bugs.webkit.org/show_bug.cgi?id=139787
+
+        Reviewed by Tim Horton.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/cocoa/MachSendRight.cpp: Added.
+        (WebCore::retainSendRight):
+        (WebCore::releaseSendRight):
+        (WebCore::MachSendRight::adopt):
+        (WebCore::MachSendRight::create):
+        (WebCore::MachSendRight::MachSendRight):
+        (WebCore::MachSendRight::~MachSendRight):
+        (WebCore::MachSendRight::operator=):
+        (WebCore::MachSendRight::leakSendRight):
+        * platform/cocoa/MachSendRight.h: Added.
+        * platform/graphics/cocoa/IOSurface.h:
+        * platform/graphics/cocoa/IOSurface.mm:
+        (IOSurface::createSendRight):
+        (IOSurface::createMachPort): Deleted.
+
</ins><span class="cx"> 2014-12-18  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Ref-ify DOMSettableTokenList.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (177515 => 177516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-12-18 20:25:21 UTC (rev 177515)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-12-18 20:29:19 UTC (rev 177516)
</span><span class="lines">@@ -324,6 +324,8 @@
</span><span class="cx"> __ZN7WebCore13JSHTMLElement6s_infoE
</span><span class="cx"> __ZN7WebCore13KeyboardEventC1ERKNS_21PlatformKeyboardEventEPNS_9DOMWindowE
</span><span class="cx"> __ZN7WebCore13KeyboardEventC1Ev
</span><ins>+__ZN7WebCore13MachSendRight13leakSendRightEv
+__ZN7WebCore13MachSendRightD1Ev
</ins><span class="cx"> __ZN7WebCore13NodeTraversal13deepLastChildEPNS_4NodeE
</span><span class="cx"> __ZN7WebCore13NodeTraversal19nextAncestorSiblingEPKNS_4NodeE
</span><span class="cx"> __ZN7WebCore13NodeTraversal19nextAncestorSiblingEPKNS_4NodeES3_
</span><span class="lines">@@ -3248,7 +3250,7 @@
</span><span class="cx"> __ZN7WebCore9IOSurface21ensurePlatformContextEv
</span><span class="cx"> __ZN7WebCore9IOSurface22releaseGraphicsContextEv
</span><span class="cx"> __ZN7WebCore9IOSurface6createENS_7IntSizeENS_10ColorSpaceE
</span><del>-__ZNK7WebCore9IOSurface14createMachPortEv
</del><ins>+__ZNK7WebCore9IOSurface15createSendRightEv
</ins><span class="cx"> __ZNK7WebCore9IOSurface7isInUseEv
</span><span class="cx"> _wkIOSurfaceContextCreate
</span><span class="cx"> _wkIOSurfaceContextCreateImage
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (177515 => 177516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-12-18 20:25:21 UTC (rev 177515)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-12-18 20:29:19 UTC (rev 177516)
</span><span class="lines">@@ -673,6 +673,8 @@
</span><span class="cx">                 197B180C1506353200E4ADA8 /* SVGRenderingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 197B180B150634C000E4ADA8 /* SVGRenderingContext.h */; };
</span><span class="cx">                 19BFF64E11C0F2AC00B8C04D /* JSSVGFEConvolveMatrixElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 19BFF64911C0F2AC00B8C04D /* JSSVGFEConvolveMatrixElement.cpp */; };
</span><span class="cx">                 19BFF64F11C0F2AC00B8C04D /* JSSVGFEConvolveMatrixElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 19BFF64A11C0F2AC00B8C04D /* JSSVGFEConvolveMatrixElement.h */; };
</span><ins>+                1A0409DC1A4360B5009E47F3 /* MachSendRight.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0409DB1A4360B5009E47F3 /* MachSendRight.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                1A0409F31A43675C009E47F3 /* MachSendRight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0409F21A43675C009E47F3 /* MachSendRight.cpp */; };
</ins><span class="cx">                 1A0D57360A5C77FE007EDD4C /* OverflowEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0D57340A5C77FE007EDD4C /* OverflowEvent.cpp */; };
</span><span class="cx">                 1A0D57370A5C77FE007EDD4C /* OverflowEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0D57350A5C77FE007EDD4C /* OverflowEvent.h */; };
</span><span class="cx">                 1A0D57400A5C7867007EDD4C /* JSOverflowEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0D573E0A5C7867007EDD4C /* JSOverflowEvent.cpp */; };
</span><span class="lines">@@ -7665,6 +7667,8 @@
</span><span class="cx">                 197B180B150634C000E4ADA8 /* SVGRenderingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGRenderingContext.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 19BFF64911C0F2AC00B8C04D /* JSSVGFEConvolveMatrixElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGFEConvolveMatrixElement.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 19BFF64A11C0F2AC00B8C04D /* JSSVGFEConvolveMatrixElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGFEConvolveMatrixElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                1A0409DB1A4360B5009E47F3 /* MachSendRight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MachSendRight.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                1A0409F21A43675C009E47F3 /* MachSendRight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MachSendRight.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 1A0D57340A5C77FE007EDD4C /* OverflowEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = OverflowEvent.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1A0D57350A5C77FE007EDD4C /* OverflowEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OverflowEvent.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1A0D57380A5C7812007EDD4C /* OverflowEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = OverflowEvent.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -18664,6 +18668,8 @@
</span><span class="cx">                                 5D8C4DBE1428222C0026CE72 /* DisplaySleepDisablerCocoa.h */,
</span><span class="cx">                                 A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */,
</span><span class="cx">                                 A5C974D011485FF10066F2AB /* KeyEventCocoa.mm */,
</span><ins>+                                1A0409F21A43675C009E47F3 /* MachSendRight.cpp */,
+                                1A0409DB1A4360B5009E47F3 /* MachSendRight.h */,
</ins><span class="cx">                                 ADB6B29718FB90240081963E /* MemoryPressureHandlerCocoa.mm */,
</span><span class="cx">                                 5D5975B119635F1100D00878 /* SystemVersion.h */,
</span><span class="cx">                                 5D5975B219635F1100D00878 /* SystemVersion.mm */,
</span><span class="lines">@@ -26464,6 +26470,7 @@
</span><span class="cx">                                 B2227A9A0D00BF220071B782 /* SVGRadialGradientElement.h in Headers */,
</span><span class="cx">                                 08EDE19F12A50B8E00B95797 /* SVGRect.h in Headers */,
</span><span class="cx">                                 B2227A9E0D00BF220071B782 /* SVGRectElement.h in Headers */,
</span><ins>+                                1A0409DC1A4360B5009E47F3 /* MachSendRight.h in Headers */,
</ins><span class="cx">                                 197B180C1506353200E4ADA8 /* SVGRenderingContext.h in Headers */,
</span><span class="cx">                                 B2227AA00D00BF220071B782 /* SVGRenderingIntent.h in Headers */,
</span><span class="cx">                                 BC2274790E8366E200E7F975 /* SVGRenderStyle.h in Headers */,
</span><span class="lines">@@ -28441,6 +28448,7 @@
</span><span class="cx">                                 1AE2AA240A1CDAB400B42B25 /* JSHTMLBRElement.cpp in Sources */,
</span><span class="cx">                                 A80E7EA00A1A83E3007FB8C5 /* JSHTMLButtonElement.cpp in Sources */,
</span><span class="cx">                                 938E666009F09B81008A48EC /* JSHTMLCanvasElement.cpp in Sources */,
</span><ins>+                                1A0409F31A43675C009E47F3 /* MachSendRight.cpp in Sources */,
</ins><span class="cx">                                 9392262D1032107B006E7D5D /* JSHTMLCanvasElementCustom.cpp in Sources */,
</span><span class="cx">                                 BCCBAD400C18C14200CE890F /* JSHTMLCollection.cpp in Sources */,
</span><span class="cx">                                 BCCBAD3B0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaMachSendRightcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/cocoa/MachSendRight.cpp (0 => 177516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/MachSendRight.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/MachSendRight.cpp        2014-12-18 20:29:19 UTC (rev 177516)
</span><span class="lines">@@ -0,0 +1,98 @@
</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 &quot;config.h&quot;
+#include &quot;MachSendRight.h&quot;
+
+#include &lt;utility&gt;
+
+namespace WebCore {
+
+static void retainSendRight(mach_port_t port)
+{
+    if (!MACH_PORT_VALID(port))
+        return;
+
+    auto kr = mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, 1);
+    if (kr != KERN_SUCCESS)
+        LOG_ERROR(&quot;mach_port_mod_refs error: %x&quot;, kr);
+}
+
+static void releaseSendRight(mach_port_t port)
+{
+    if (!MACH_PORT_VALID(port))
+        return;
+
+    auto kr = mach_port_deallocate(mach_task_self(), port);
+    if (kr != KERN_SUCCESS)
+        LOG_ERROR(&quot;mach_port_deallocate error: %x&quot;, kr);
+}
+
+MachSendRight MachSendRight::adopt(mach_port_t port)
+{
+    return MachSendRight(port);
+}
+
+MachSendRight MachSendRight::create(mach_port_t port)
+{
+    retainSendRight(port);
+
+    return adopt(port);
+}
+
+MachSendRight::MachSendRight(mach_port_t port)
+    : m_port(port)
+{
+}
+
+MachSendRight::MachSendRight(MachSendRight&amp;&amp; other)
+    : m_port(other.leakSendRight())
+{
+}
+
+MachSendRight::~MachSendRight()
+{
+    releaseSendRight(m_port);
+}
+
+MachSendRight&amp; MachSendRight::operator=(MachSendRight&amp;&amp; other)
+{
+    if (this != &amp;other) {
+        releaseSendRight(m_port);
+        m_port = other.leakSendRight();
+    }
+
+    return *this;
+}
+
+mach_port_t MachSendRight::leakSendRight()
+{
+    mach_port_t port = m_port;
+    m_port = MACH_PORT_NULL;
+
+    return port;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaMachSendRighth"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/cocoa/MachSendRight.h (0 => 177516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/MachSendRight.h                                (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/MachSendRight.h        2014-12-18 20:29:19 UTC (rev 177516)
</span><span class="lines">@@ -0,0 +1,53 @@
</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 MachSendRight_h
+#define MachSendRight_h
+
+#include &lt;mach/mach_port.h&gt;
+
+namespace WebCore {
+
+class MachSendRight {
+public:
+    static MachSendRight adopt(mach_port_t);
+    static MachSendRight create(mach_port_t);
+
+    MachSendRight(MachSendRight&amp;&amp;);
+    ~MachSendRight();
+
+    MachSendRight&amp; operator=(MachSendRight&amp;&amp;);
+
+    mach_port_t leakSendRight() WARN_UNUSED_RETURN;
+
+private:
+    explicit MachSendRight(mach_port_t);
+
+    mach_port_t m_port;
+};
+
+}
+
+#endif // MachSendRight_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (177515 => 177516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2014-12-18 20:25:21 UTC (rev 177515)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2014-12-18 20:29:19 UTC (rev 177516)
</span><span class="lines">@@ -35,6 +35,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class MachSendRight;
+
</ins><span class="cx"> class IOSurface final : public RefCounted&lt;IOSurface&gt; {
</span><span class="cx"> public:
</span><span class="cx">     WEBCORE_EXPORT static PassRefPtr&lt;IOSurface&gt; create(IntSize, ColorSpace);
</span><span class="lines">@@ -44,7 +46,7 @@
</span><span class="cx"> 
</span><span class="cx">     static IntSize maximumSize();
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT mach_port_t createMachPort() const;
</del><ins>+    MachSendRight createSendRight() const;
</ins><span class="cx"> 
</span><span class="cx">     // Any images created from a surface need to be released before releasing
</span><span class="cx">     // the surface, or an expensive GPU readback can result.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (177515 => 177516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2014-12-18 20:25:21 UTC (rev 177515)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2014-12-18 20:29:19 UTC (rev 177516)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;GraphicsContextCG.h&quot;
</span><span class="cx"> #import &quot;IOSurfacePool.h&quot;
</span><ins>+#import &quot;MachSendRight.h&quot;
</ins><span class="cx"> #import &lt;IOSurface/IOSurface.h&gt;
</span><span class="cx"> #import &lt;wtf/Assertions.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -129,9 +130,9 @@
</span><span class="cx">     return IntSize(IOSurfaceGetPropertyMaximum(kIOSurfaceWidth), IOSurfaceGetPropertyMaximum(kIOSurfaceHeight));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-mach_port_t IOSurface::createMachPort() const
</del><ins>+MachSendRight IOSurface::createSendRight() const
</ins><span class="cx"> {
</span><del>-    return IOSurfaceCreateMachPort(m_surface.get());
</del><ins>+    return MachSendRight::adopt(IOSurfaceCreateMachPort(m_surface.get()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RetainPtr&lt;CGImageRef&gt; IOSurface::createImage()
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (177515 => 177516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-12-18 20:25:21 UTC (rev 177515)
+++ trunk/Source/WebKit2/ChangeLog        2014-12-18 20:29:19 UTC (rev 177516)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2014-12-18  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Add a MachSendRight class to WebCore and use it in IOSurface
+        https://bugs.webkit.org/show_bug.cgi?id=139787
+
+        Reviewed by Tim Horton.
+
+        * Shared/mac/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::encode):
+
</ins><span class="cx"> 2014-12-18  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Attempt to fix the iOS build after &lt;http://trac.webkit.org/changeset/177486&gt;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (177515 => 177516)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-12-18 20:25:21 UTC (rev 177515)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-12-18 20:29:19 UTC (rev 177516)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #import &lt;WebCore/GraphicsContextCG.h&gt;
</span><span class="cx"> #import &lt;WebCore/IOSurface.h&gt;
</span><span class="cx"> #import &lt;WebCore/IOSurfacePool.h&gt;
</span><ins>+#import &lt;WebCore/MachSendRight.h&gt;
</ins><span class="cx"> #import &lt;WebCore/QuartzCoreSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/WebLayer.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -106,7 +107,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(IOSURFACE)
</span><span class="cx">     if (m_acceleratesDrawing) {
</span><del>-        mach_port_t port = m_frontBuffer.surface-&gt;createMachPort();
</del><ins>+        mach_port_t port = m_frontBuffer.surface-&gt;createSendRight().leakSendRight();
</ins><span class="cx">         encoder &lt;&lt; IPC::MachPort(port, MACH_MSG_TYPE_MOVE_SEND);
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>