<!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>[210310] trunk</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/210310">210310</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2017-01-04 17:32:02 -0800 (Wed, 04 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Cocoa] Teach SharedBuffer to return an NSArray of data segments to avoid flattening
https://bugs.webkit.org/show_bug.cgi?id=166696

Reviewed by Tim Horton.

Source/WebCore:

Existing methods of extracting NSData from a SharedBuffer require either merging or copying
data segments. Since data segments are stored in CFDataRefs on Cocoa platforms, it should be
possible to retrieve an NSArray of the segments without having to first flatten to a single
buffer.

This patch implements such a method. This will be used in a follow-on patch, where I will
need to pass SharedBuffer data to QuickLook via an NSArray of NSData.

New API test: SharedBufferTest.createNSDataArray.

* platform/SharedBuffer.h: Declared createNSArrayData(), and exported two functions needed
by the API test.
* platform/cocoa/SharedBufferCocoa.mm:
(WebCore::SharedBuffer::createNSDataArray): Added. Returns m_cfData or a copy of m_fileData
if either exist. Otherwise, adds m_buffer (wrapped in a WebCoreSharedBufferData object) and
the objects in m_dataArray to a NSMutableArray and returns it.

Tools:

* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/PlatformWin.cmake:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp: Moved class SharedBufferTest to SharedBufferTest.{cpp,h}.
* TestWebKitAPI/Tests/WebCore/SharedBufferTest.cpp: Moved class SharedBufferTest from SharedBuffer.cpp.
* TestWebKitAPI/Tests/WebCore/SharedBufferTest.h: Ditto.
* TestWebKitAPI/Tests/WebCore/cocoa/SharedBuffer.mm: Added.
(TestWebKitAPI::expectDataArraysEqual): Added a helper to assert that two NSArrays of NSData are equal.
(TestWebKitAPI::TEST_F): Added a test for createNSDataArray.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformSharedBufferh">trunk/Source/WebCore/platform/SharedBuffer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaSharedBufferCocoamm">trunk/Source/WebCore/platform/cocoa/SharedBufferCocoa.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPIPlatformGTKcmake">trunk/Tools/TestWebKitAPI/PlatformGTK.cmake</a></li>
<li><a href="#trunkToolsTestWebKitAPIPlatformWincmake">trunk/Tools/TestWebKitAPI/PlatformWin.cmake</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreSharedBuffercpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreSharedBufferTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBufferTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreSharedBufferTesth">trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBufferTest.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCorecocoaSharedBuffermm">trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/SharedBuffer.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210309 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-05 01:22:41 UTC (rev 210309)
+++ trunk/Source/WebCore/ChangeLog        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2017-01-04  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [Cocoa] Teach SharedBuffer to return an NSArray of data segments to avoid flattening
+        https://bugs.webkit.org/show_bug.cgi?id=166696
+
+        Reviewed by Tim Horton.
+
+        Existing methods of extracting NSData from a SharedBuffer require either merging or copying
+        data segments. Since data segments are stored in CFDataRefs on Cocoa platforms, it should be
+        possible to retrieve an NSArray of the segments without having to first flatten to a single
+        buffer.
+
+        This patch implements such a method. This will be used in a follow-on patch, where I will
+        need to pass SharedBuffer data to QuickLook via an NSArray of NSData.
+
+        New API test: SharedBufferTest.createNSDataArray.
+
+        * platform/SharedBuffer.h: Declared createNSArrayData(), and exported two functions needed
+        by the API test.
+        * platform/cocoa/SharedBufferCocoa.mm:
+        (WebCore::SharedBuffer::createNSDataArray): Added. Returns m_cfData or a copy of m_fileData
+        if either exist. Otherwise, adds m_buffer (wrapped in a WebCoreSharedBufferData object) and
+        the objects in m_dataArray to a NSMutableArray and returns it.
+
</ins><span class="cx"> 2017-01-04  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r210296.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformSharedBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/SharedBuffer.h (210309 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/SharedBuffer.h        2017-01-05 01:22:41 UTC (rev 210309)
+++ trunk/Source/WebCore/platform/SharedBuffer.h        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(FOUNDATION)
</span><ins>+OBJC_CLASS NSArray;
</ins><span class="cx"> OBJC_CLASS NSData;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -64,6 +65,7 @@
</span><span class="cx">     
</span><span class="cx"> #if USE(FOUNDATION)
</span><span class="cx">     WEBCORE_EXPORT RetainPtr&lt;NSData&gt; createNSData();
</span><ins>+    WEBCORE_EXPORT RetainPtr&lt;NSArray&gt; createNSDataArray();
</ins><span class="cx">     WEBCORE_EXPORT static Ref&lt;SharedBuffer&gt; wrapNSData(NSData *);
</span><span class="cx"> #endif
</span><span class="cx"> #if USE(CF)
</span><span class="lines">@@ -99,8 +101,8 @@
</span><span class="cx">     unsigned platformDataSize() const;
</span><span class="cx"> 
</span><span class="cx"> #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
</span><del>-    static Ref&lt;SharedBuffer&gt; wrapCFDataArray(CFArrayRef);
-    void append(CFDataRef);
</del><ins>+    WEBCORE_EXPORT static Ref&lt;SharedBuffer&gt; wrapCFDataArray(CFArrayRef);
+    WEBCORE_EXPORT void append(CFDataRef);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT Ref&lt;SharedBuffer&gt; copy() const;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaSharedBufferCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/SharedBufferCocoa.mm (210309 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/SharedBufferCocoa.mm        2017-01-05 01:22:41 UTC (rev 210309)
+++ trunk/Source/WebCore/platform/cocoa/SharedBufferCocoa.mm        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2006-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -123,4 +123,28 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RetainPtr&lt;NSArray&gt; SharedBuffer::createNSDataArray()
+{
+    if (auto platformData = (NSData *)m_cfData.get())
+        return @[ platformData ];
+
+    if (m_fileData)
+        return @[ [NSData dataWithBytes:m_fileData.data() length:m_fileData.size()] ];
+
+    auto dataArray = adoptNS([[NSMutableArray alloc] init]);
+    if (m_buffer-&gt;data.size())
+        [dataArray addObject:adoptNS([[WebCoreSharedBufferData alloc] initWithSharedBufferDataBuffer:m_buffer.ptr()]).get()];
+
+#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
+    for (auto&amp; data : m_dataArray)
+        [dataArray addObject:(NSData *)data.get()];
+#else
+    // Cocoa platforms all currently USE(NETWORK_CFDATA_ARRAY_CALLBACK), so implementing a code path for copying segments would be dead code.
+    // If this ever changes, the following static_assert will detect it.
+    static_assert(false, &quot;FIXME: Copy the segments into an array of NSData objects.&quot;);
+#endif
+
+    return WTFMove(dataArray);
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (210309 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-01-05 01:22:41 UTC (rev 210309)
+++ trunk/Tools/ChangeLog        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2017-01-04  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [Cocoa] Teach SharedBuffer to return an NSArray of data segments to avoid flattening
+        https://bugs.webkit.org/show_bug.cgi?id=166696
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/PlatformGTK.cmake:
+        * TestWebKitAPI/PlatformWin.cmake:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp: Moved class SharedBufferTest to SharedBufferTest.{cpp,h}.
+        * TestWebKitAPI/Tests/WebCore/SharedBufferTest.cpp: Moved class SharedBufferTest from SharedBuffer.cpp.
+        * TestWebKitAPI/Tests/WebCore/SharedBufferTest.h: Ditto.
+        * TestWebKitAPI/Tests/WebCore/cocoa/SharedBuffer.mm: Added.
+        (TestWebKitAPI::expectDataArraysEqual): Added a helper to assert that two NSArrays of NSData are equal.
+        (TestWebKitAPI::TEST_F): Added a test for createNSDataArray.
+
</ins><span class="cx"> 2017-01-03  Brian Burg  &lt;bburg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: teach the protocol generator about platform-specific types, events, and commands
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIPlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/PlatformGTK.cmake (210309 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/PlatformGTK.cmake        2017-01-05 01:22:41 UTC (rev 210309)
+++ trunk/Tools/TestWebKitAPI/PlatformGTK.cmake        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -137,6 +137,7 @@
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/PublicSuffix.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/SecurityOrigin.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp
</span><ins>+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBufferTest.cpp
</ins><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/URL.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/URLParser.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/UserAgentQuirks.cpp
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIPlatformWincmake"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/PlatformWin.cmake (210309 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/PlatformWin.cmake        2017-01-05 01:22:41 UTC (rev 210309)
+++ trunk/Tools/TestWebKitAPI/PlatformWin.cmake        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/ParsedContentRange.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/SecurityOrigin.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp
</span><ins>+    ${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBufferTest.cpp
</ins><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/TimeRanges.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/TransformationMatrix.cpp
</span><span class="cx">     ${TESTWEBKITAPI_DIR}/Tests/WebCore/URL.cpp
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (210309 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-01-05 01:22:41 UTC (rev 210309)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -465,6 +465,8 @@
</span><span class="cx">                 A155022A1E05020B00A24C57 /* DuplicateCompletionHandlerCalls.mm in Sources */ = {isa = PBXBuildFile; fileRef = A15502281E05020B00A24C57 /* DuplicateCompletionHandlerCalls.mm */; };
</span><span class="cx">                 A155022C1E050D0300A24C57 /* duplicate-completion-handler-calls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A155022B1E050BC500A24C57 /* duplicate-completion-handler-calls.html */; };
</span><span class="cx">                 A16F66BA1C40EB4F00BD4D24 /* ContentFiltering.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */; };
</span><ins>+                A17991881E1C994E00A505ED /* SharedBuffer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A17991861E1C994E00A505ED /* SharedBuffer.mm */; };
+                A179918B1E1CA24100A505ED /* SharedBufferTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A17991891E1CA24100A505ED /* SharedBufferTest.cpp */; };
</ins><span class="cx">                 A1C4FB731BACD1CA003742D0 /* pages.pages in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1C4FB721BACD1B7003742D0 /* pages.pages */; };
</span><span class="cx">                 A1DF74321C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */; };
</span><span class="cx">                 A57A34F216AF6B2B00C2501F /* PageVisibilityStateWithWindowChanges.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */; };
</span><span class="lines">@@ -1145,6 +1147,9 @@
</span><span class="cx">                 A15502281E05020B00A24C57 /* DuplicateCompletionHandlerCalls.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DuplicateCompletionHandlerCalls.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A155022B1E050BC500A24C57 /* duplicate-completion-handler-calls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;duplicate-completion-handler-calls.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContentFiltering.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                A17991861E1C994E00A505ED /* SharedBuffer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SharedBuffer.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A17991891E1CA24100A505ED /* SharedBufferTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedBufferTest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A179918A1E1CA24100A505ED /* SharedBufferTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedBufferTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 A18AA8CC1C3FA218009B2B97 /* ContentFiltering.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentFiltering.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A1A4FE5D18DD3DB700B5EA8A /* Download.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Download.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A1C4FB6C1BACCE50003742D0 /* QuickLook.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickLook.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1559,6 +1564,8 @@
</span><span class="cx">                                 CD225C071C45A69200140761 /* ParsedContentRange.cpp */,
</span><span class="cx">                                 CE06DF9A1E1851F200E570C9 /* SecurityOrigin.cpp */,
</span><span class="cx">                                 41973B5C1AF22875006C7B36 /* SharedBuffer.cpp */,
</span><ins>+                                A17991891E1CA24100A505ED /* SharedBufferTest.cpp */,
+                                A179918A1E1CA24100A505ED /* SharedBufferTest.h */,
</ins><span class="cx">                                 CDC2C7141797089D00E627FB /* TimeRanges.cpp */,
</span><span class="cx">                                 7AD3FE8D1D75FB8D00B169A4 /* TransformationMatrix.cpp */,
</span><span class="cx">                                 440A1D3814A0103A008A66F2 /* URL.cpp */,
</span><span class="lines">@@ -2158,6 +2165,7 @@
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="cx">                                 5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */,
</span><ins>+                                A17991861E1C994E00A505ED /* SharedBuffer.mm */,
</ins><span class="cx">                                 93A7EB3C18FA63A4009E7670 /* URLExtras.mm */,
</span><span class="cx">                                 CD89D0381C4EDB2A00040A04 /* WebCoreNSURLSession.mm */,
</span><span class="cx">                         );
</span><span class="lines">@@ -2538,6 +2546,7 @@
</span><span class="cx">                                 510477781D29923B009747EB /* IDBDeleteRecovery.mm in Sources */,
</span><span class="cx">                                 51A587861D273AA9004BA9AF /* IndexedDBDatabaseProcessKill.mm in Sources */,
</span><span class="cx">                                 7C83E0BE1D0A651300FEBCF3 /* IndexedDBMultiProcess.mm in Sources */,
</span><ins>+                                A179918B1E1CA24100A505ED /* SharedBufferTest.cpp in Sources */,
</ins><span class="cx">                                 7C83E0BF1D0A652200FEBCF3 /* IndexedDBPersistence.mm in Sources */,
</span><span class="cx">                                 7CCE7EFB1A411AE600447C4C /* InjectedBundleBasic.cpp in Sources */,
</span><span class="cx">                                 8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */,
</span><span class="lines">@@ -2675,6 +2684,7 @@
</span><span class="cx">                                 7CCE7ED81A411A7E00447C4C /* WillSendSubmitEvent.mm in Sources */,
</span><span class="cx">                                 7CCE7ED91A411A7E00447C4C /* WindowlessWebViewWithMedia.mm in Sources */,
</span><span class="cx">                                 1F83571B1D3FFB2300E3967B /* WKBackForwardList.mm in Sources */,
</span><ins>+                                A17991881E1C994E00A505ED /* SharedBuffer.mm in Sources */,
</ins><span class="cx">                                 2EFF06D71D8AF34A0004BB30 /* WKWebViewCandidateTests.mm in Sources */,
</span><span class="cx">                                 7CCE7F2E1A411B1000447C4C /* WKBrowsingContextGroupTest.mm in Sources */,
</span><span class="cx">                                 7CCE7F2F1A411B1000447C4C /* WKBrowsingContextLoadDelegateTest.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreSharedBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp (210309 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp        2017-01-05 01:22:41 UTC (rev 210309)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2015 Canon Inc. All rights reserved.
</span><span class="cx">  * Copyright (C) 2013 Google Inc. All rights reserved.
</span><span class="cx">  *
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;SharedBufferTest.h&quot;
</ins><span class="cx"> #include &quot;Test.h&quot;
</span><span class="cx"> #include &lt;WebCore/SharedBuffer.h&gt;
</span><span class="cx"> #include &lt;wtf/MainThread.h&gt;
</span><span class="lines">@@ -36,38 +37,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx"> 
</span><del>-const char* SharedBufferTestData = &quot;This is a test&quot;;
-
-class SharedBufferTest : public testing::Test {
-public:
-    void SetUp() override
-    {
-        WTF::initializeMainThread();
-        
-        // create temp file
-        PlatformFileHandle handle;
-        m_tempFilePath = openTemporaryFile(&quot;tempTestFile&quot;, handle);
-        writeToFile(handle, SharedBufferTestData, strlen(SharedBufferTestData));
-        closeFile(handle); 
-
-        m_tempEmptyFilePath = openTemporaryFile(&quot;tempEmptyTestFile&quot;, handle);
-        closeFile(handle); 
-    }
-
-    void TearDown() override
-    {
-        deleteFile(m_tempFilePath);
-        deleteFile(m_tempEmptyFilePath);
-    }
-
-    const String&amp; tempFilePath() { return m_tempFilePath; }
-    const String&amp; tempEmptyFilePath() { return m_tempEmptyFilePath; }
-
-private:
-    String m_tempFilePath;
-    String m_tempEmptyFilePath;
-};
-
</del><span class="cx"> TEST_F(SharedBufferTest, createWithContentsOfMissingFile)
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;SharedBuffer&gt; buffer = SharedBuffer::createWithContentsOfFile(String(&quot;not_existing_file&quot;));
</span><span class="lines">@@ -78,8 +47,8 @@
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;SharedBuffer&gt; buffer = SharedBuffer::createWithContentsOfFile(tempFilePath());
</span><span class="cx">     ASSERT_NOT_NULL(buffer);
</span><del>-    EXPECT_TRUE(buffer-&gt;size() == strlen(SharedBufferTestData));
-    EXPECT_TRUE(String(SharedBufferTestData) == String(buffer-&gt;data(), buffer-&gt;size()));
</del><ins>+    EXPECT_TRUE(buffer-&gt;size() == strlen(SharedBufferTest::testData()));
+    EXPECT_TRUE(String(SharedBufferTest::testData()) == String(buffer-&gt;data(), buffer-&gt;size()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST_F(SharedBufferTest, createWithContentsOfExistingEmptyFile)
</span><span class="lines">@@ -113,9 +82,9 @@
</span><span class="cx">     RefPtr&lt;SharedBuffer&gt; buffer = SharedBuffer::createWithContentsOfFile(tempFilePath());
</span><span class="cx">     ASSERT_NOT_NULL(buffer);
</span><span class="cx">     buffer-&gt;append(&quot;a&quot;, 1);
</span><del>-    EXPECT_TRUE(buffer-&gt;size() == (strlen(SharedBufferTestData) + 1));
-    EXPECT_TRUE(!memcmp(buffer-&gt;data(), SharedBufferTestData, strlen(SharedBufferTestData)));
-    EXPECT_EQ('a', buffer-&gt;data()[strlen(SharedBufferTestData)]);
</del><ins>+    EXPECT_TRUE(buffer-&gt;size() == (strlen(SharedBufferTest::testData()) + 1));
+    EXPECT_TRUE(!memcmp(buffer-&gt;data(), SharedBufferTest::testData(), strlen(SharedBufferTest::testData())));
+    EXPECT_EQ('a', buffer-&gt;data()[strlen(SharedBufferTest::testData())]);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST_F(SharedBufferTest, createArrayBuffer)
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreSharedBufferTestcpp"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBufferTest.cpp (0 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBufferTest.cpp                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBufferTest.cpp        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2017 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;SharedBufferTest.h&quot;
+
+#include &lt;WebCore/FileSystem.h&gt;
+#include &lt;wtf/MainThread.h&gt;
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+void SharedBufferTest::SetUp()
+{
+    WTF::initializeMainThread();
+
+    // create temp file
+    PlatformFileHandle handle;
+    m_tempFilePath = openTemporaryFile(&quot;tempTestFile&quot;, handle);
+    writeToFile(handle, testData(), strlen(testData()));
+    closeFile(handle);
+
+    m_tempEmptyFilePath = openTemporaryFile(&quot;tempEmptyTestFile&quot;, handle);
+    closeFile(handle);
+}
+
+void SharedBufferTest::TearDown()
+{
+    deleteFile(m_tempFilePath);
+    deleteFile(m_tempEmptyFilePath);
+}
+
+} // namespace TestWebKitAPI
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreSharedBufferTesth"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBufferTest.h (0 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBufferTest.h                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/SharedBufferTest.h        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+/*
+ * Copyright (C) 2017 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.
+ */
+
+#pragma once
+
+#include &lt;wtf/text/WTFString.h&gt;
+
+namespace TestWebKitAPI {
+
+class SharedBufferTest : public testing::Test {
+public:
+    void SetUp() override;
+    void TearDown() override;
+
+    static const char* testData() { return &quot;This is a test&quot;; }
+    const String&amp; tempFilePath() { return m_tempFilePath; }
+    const String&amp; tempEmptyFilePath() { return m_tempEmptyFilePath; }
+
+private:
+    String m_tempFilePath;
+    String m_tempEmptyFilePath;
+};
+
+} // namespace TestWebKitAPI
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCorecocoaSharedBuffermm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/SharedBuffer.mm (0 => 210310)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/SharedBuffer.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/SharedBuffer.mm        2017-01-05 01:32:02 UTC (rev 210310)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+/*
+ * Copyright (C) 2017 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.
+ */
+
+#import &quot;config.h&quot;
+
+#import &quot;PlatformUtilities.h&quot;
+#import &quot;SharedBufferTest.h&quot;
+#import &lt;WebCore/SharedBuffer.h&gt;
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+static void expectDataArraysEqual(NSArray&lt;NSData *&gt; *expected, NSArray&lt;NSData *&gt; *actual)
+{
+    EXPECT_EQ(expected.count, actual.count);
+    for (NSUInteger i = 0; i &lt; expected.count; ++i) {
+        NSData *expectedData = expected[i];
+        NSData *actualData = actual[i];
+        EXPECT_TRUE([expectedData isKindOfClass:[NSData class]]);
+        EXPECT_TRUE([actualData isKindOfClass:[NSData class]]);
+        EXPECT_TRUE([expectedData isEqualToData:actualData]);
+    }
+}
+
+TEST_F(SharedBufferTest, createNSDataArray)
+{
+    @autoreleasepool {
+        auto buffer = SharedBuffer::create();
+        expectDataArraysEqual(nil, buffer-&gt;createNSDataArray().get());
+
+        NSData *helloData = [NSData dataWithBytes:&quot;hello&quot; length:5];
+        buffer-&gt;append((const char*)helloData.bytes, helloData.length);
+        expectDataArraysEqual(@[ helloData ], buffer-&gt;createNSDataArray().get());
+
+        NSData *worldData = [NSData dataWithBytes:&quot;world&quot; length:5];
+        buffer-&gt;append((CFDataRef)worldData);
+        expectDataArraysEqual(@[ helloData, worldData ], buffer-&gt;createNSDataArray().get());
+
+        expectDataArraysEqual(@[ helloData ], SharedBuffer::wrapNSData(helloData)-&gt;createNSDataArray().get());
+        expectDataArraysEqual(@[ worldData ], SharedBuffer::wrapCFData((CFDataRef)worldData)-&gt;createNSDataArray().get());
+
+        NSArray&lt;NSData *&gt; *dataArray = @[ [NSData dataWithBytes:&quot;one&quot; length:3], [NSData dataWithBytes:&quot;two&quot; length:3], [NSData dataWithBytes:&quot;three&quot; length:5] ];
+        auto wrappedDataArray = SharedBuffer::wrapCFDataArray((CFArrayRef)dataArray);
+        expectDataArraysEqual(dataArray, wrappedDataArray-&gt;createNSDataArray().get());
+
+        NSArray&lt;NSData *&gt; *secondDataArray = @[ [NSData dataWithBytes:&quot;four&quot; length:4], [NSData dataWithBytes:&quot;five&quot; length:4], [NSData dataWithBytes:&quot;six&quot; length:3] ];
+        wrappedDataArray-&gt;append(SharedBuffer::wrapCFDataArray((CFArrayRef)secondDataArray).get());
+        expectDataArraysEqual([dataArray arrayByAddingObjectsFromArray:secondDataArray], wrappedDataArray-&gt;createNSDataArray().get());
+
+        expectDataArraysEqual(@[ [NSData dataWithContentsOfFile:tempFilePath()] ], SharedBuffer::createWithContentsOfFile(tempFilePath())-&gt;createNSDataArray().get());
+    }
+}
+
+}; // namespace TestWebKitAPI
</ins></span></pre>
</div>
</div>

</body>
</html>