<!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>[160278] 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/160278">160278</a></dd>
<dt>Author</dt> <dd>mitz@apple.com</dd>
<dt>Date</dt> <dd>2013-12-07 21:23:29 -0800 (Sat, 07 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Cocoa] WebData has a generic wrapper
https://bugs.webkit.org/show_bug.cgi?id=125402

Reviewed by Sam Weinig.

Added WKNSData, an NSData subclass that confroms to WKObject and wraps a WebData.

* Shared/Cocoa/APIObject.mm:
(API::Object::newObject): Allocate a WKNSData if the API::Object is data.
* Shared/Cocoa/WKNSData.h: Added.
(WebKit::wrapper): Added. Returns a WebData’s wrapper as an NSData.
* Shared/Cocoa/WKNSData.mm: Added.
(-[WKNSData dealloc]): Calls the WebData destructor.
(-[WKNSData length]): Added.
(-[WKNSData bytes]): Added.
(-[WKNSData copyWithZone:]): Retains self.
(-[WKNSData _apiObject]): Returns the wrapped WebData.
* WebKit2.xcodeproj/project.pbxproj: Added references to new files.</pre>

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

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2SharedCocoaWKNSDatah">trunk/Source/WebKit2/Shared/Cocoa/WKNSData.h</a></li>
<li><a href="#trunkSourceWebKit2SharedCocoaWKNSDatamm">trunk/Source/WebKit2/Shared/Cocoa/WKNSData.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (160277 => 160278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2013-12-08 05:22:02 UTC (rev 160277)
+++ trunk/Source/WebKit2/ChangeLog        2013-12-08 05:23:29 UTC (rev 160278)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2013-12-07  Dan Bernstein  &lt;mitz@apple.com&gt;
+
+        [Cocoa] WebData has a generic wrapper
+        https://bugs.webkit.org/show_bug.cgi?id=125402
+
+        Reviewed by Sam Weinig.
+
+        Added WKNSData, an NSData subclass that confroms to WKObject and wraps a WebData.
+
+        * Shared/Cocoa/APIObject.mm:
+        (API::Object::newObject): Allocate a WKNSData if the API::Object is data.
+        * Shared/Cocoa/WKNSData.h: Added.
+        (WebKit::wrapper): Added. Returns a WebData’s wrapper as an NSData.
+        * Shared/Cocoa/WKNSData.mm: Added.
+        (-[WKNSData dealloc]): Calls the WebData destructor.
+        (-[WKNSData length]): Added.
+        (-[WKNSData bytes]): Added.
+        (-[WKNSData copyWithZone:]): Retains self.
+        (-[WKNSData _apiObject]): Returns the wrapped WebData.
+        * WebKit2.xcodeproj/project.pbxproj: Added references to new files.
+
</ins><span class="cx"> 2013-12-07  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [Cocoa] Make WKWebProcessPlugInBrowserContextController work with WKObject wrapping
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCocoaAPIObjectmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm (160277 => 160278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm        2013-12-08 05:22:02 UTC (rev 160277)
+++ trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm        2013-12-08 05:23:29 UTC (rev 160278)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #import &quot;WKBrowsingContextGroupInternal.h&quot;
</span><span class="cx"> #import &quot;WKConnectionInternal.h&quot;
</span><span class="cx"> #import &quot;WKNSArray.h&quot;
</span><ins>+#import &quot;WKNSData.h&quot;
</ins><span class="cx"> #import &quot;WKNSDictionary.h&quot;
</span><span class="cx"> #import &quot;WKNSError.h&quot;
</span><span class="cx"> #import &quot;WKNSString.h&quot;
</span><span class="lines">@@ -93,6 +94,10 @@
</span><span class="cx">         wrapper = [WKProcessGroup alloc];
</span><span class="cx">         break;
</span><span class="cx"> 
</span><ins>+    case Type::Data:
+        wrapper = [WKNSData alloc];
+        break;
+
</ins><span class="cx">     case Type::Dictionary:
</span><span class="cx">         wrapper = [WKNSDictionary alloc];
</span><span class="cx">         break;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCocoaWKNSDatah"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/Cocoa/WKNSData.h (0 => 160278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Cocoa/WKNSData.h                                (rev 0)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSData.h        2013-12-08 05:23:29 UTC (rev 160278)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+/*
+ * Copyright (C) 2013 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;WKFoundation.h&quot;
+
+#if WK_API_ENABLED
+
+#import &quot;WKObject.h&quot;
+#import &quot;WebData.h&quot;
+
+namespace WebKit {
+
+inline NSData *wrapper(WebData&amp; data)
+{
+    ASSERT([data.wrapper() isKindOfClass:[NSData self]]);
+    return (NSData *)data.wrapper();
+}
+
+}
+
+@interface WKNSData : NSData &lt;WKObject&gt;
+@end
+
+#endif // WK_API_ENABLED
</ins></span></pre></div>
<a id="trunkSourceWebKit2SharedCocoaWKNSDatamm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/Cocoa/WKNSData.mm (0 => 160278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Cocoa/WKNSData.mm                                (rev 0)
+++ trunk/Source/WebKit2/Shared/Cocoa/WKNSData.mm        2013-12-08 05:23:29 UTC (rev 160278)
</span><span class="lines">@@ -0,0 +1,72 @@
</span><ins>+/*
+ * Copyright (C) 2013 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;WKNSData.h&quot;
+
+#if WK_API_ENABLED
+
+using namespace WebKit;
+
+@implementation WKNSData {
+    API::ObjectStorage&lt;WebData&gt; _data;
+}
+
+- (void)dealloc
+{
+    _data-&gt;~WebData();
+
+    [super dealloc];
+}
+
+#pragma mark NSData primitive methods
+
+- (NSUInteger)length
+{
+    return _data-&gt;size();
+}
+
+- (const void*)bytes
+{
+    return _data-&gt;bytes();
+}
+
+#pragma mark NSCopying protocol implementation
+
+- (id)copyWithZone:(NSZone *)zone
+{
+    return [self retain];
+}
+
+#pragma mark WKObject protocol implementation
+
+- (API::Object&amp;)_apiObject
+{
+    return *_data;
+}
+
+@end
+
+#endif // WK_API_ENABLED
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (160277 => 160278)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2013-12-08 05:22:02 UTC (rev 160277)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2013-12-08 05:23:29 UTC (rev 160278)
</span><span class="lines">@@ -441,6 +441,8 @@
</span><span class="cx">                 371B32DE184D67490013E2B2 /* WKNSURLProtectionSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 371B32DC184D67490013E2B2 /* WKNSURLProtectionSpace.h */; };
</span><span class="cx">                 372CAF0B1833FD910040AC27 /* WKNSError.h in Headers */ = {isa = PBXBuildFile; fileRef = 372CAF091833FD910040AC27 /* WKNSError.h */; };
</span><span class="cx">                 372CAF0C1833FD910040AC27 /* WKNSError.mm in Sources */ = {isa = PBXBuildFile; fileRef = 372CAF0A1833FD910040AC27 /* WKNSError.mm */; };
</span><ins>+                373CEAD5185417AE008C363D /* WKNSData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 373CEAD3185417AE008C363D /* WKNSData.mm */; };
+                373CEAD6185417AE008C363D /* WKNSData.h in Headers */ = {isa = PBXBuildFile; fileRef = 373CEAD4185417AE008C363D /* WKNSData.h */; };
</ins><span class="cx">                 374436881820E7240049579F /* WKObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 374436871820E7240049579F /* WKObject.mm */; };
</span><span class="cx">                 3760881E150413E900FC82C7 /* WebRenderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3760881C150413E900FC82C7 /* WebRenderObject.cpp */; };
</span><span class="cx">                 3760881F150413E900FC82C7 /* WebRenderObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 3760881D150413E900FC82C7 /* WebRenderObject.h */; };
</span><span class="lines">@@ -1989,6 +1991,8 @@
</span><span class="cx">                 371B32DC184D67490013E2B2 /* WKNSURLProtectionSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSURLProtectionSpace.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 372CAF091833FD910040AC27 /* WKNSError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSError.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 372CAF0A1833FD910040AC27 /* WKNSError.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSError.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                373CEAD3185417AE008C363D /* WKNSData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKNSData.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                373CEAD4185417AE008C363D /* WKNSData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNSData.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 374436871820E7240049579F /* WKObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKObject.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3760881C150413E900FC82C7 /* WebRenderObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebRenderObject.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3760881D150413E900FC82C7 /* WebRenderObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebRenderObject.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -3829,6 +3833,8 @@
</span><span class="cx">                                 378E1A3B181ED6FF0031007A /* APIObject.mm */,
</span><span class="cx">                                 37C4C0921814B3AF003688B9 /* WKNSArray.h */,
</span><span class="cx">                                 37C4C0911814B3AF003688B9 /* WKNSArray.mm */,
</span><ins>+                                373CEAD4185417AE008C363D /* WKNSData.h */,
+                                373CEAD3185417AE008C363D /* WKNSData.mm */,
</ins><span class="cx">                                 371A19401824D29300F32A5E /* WKNSDictionary.h */,
</span><span class="cx">                                 371A193F1824D29300F32A5E /* WKNSDictionary.mm */,
</span><span class="cx">                                 372CAF091833FD910040AC27 /* WKNSError.h */,
</span><span class="lines">@@ -6195,6 +6201,7 @@
</span><span class="cx">                                 BC8F2F2B16273A2C005FACB5 /* WKWebProcessPlugInBrowserContextController.h in Headers */,
</span><span class="cx">                                 BC8F2F2E16273ACC005FACB5 /* WKWebProcessPlugInBrowserContextControllerInternal.h in Headers */,
</span><span class="cx">                                 29501724162A4504004A9D71 /* WKWebProcessPlugInBrowserContextControllerPrivate.h in Headers */,
</span><ins>+                                373CEAD6185417AE008C363D /* WKNSData.h in Headers */,
</ins><span class="cx">                                 1AB8A1F018400B0000E9AE69 /* WKPageFormClient.h in Headers */,
</span><span class="cx">                                 BC989D85161A9890000D46D3 /* WKWebProcessPlugInInternal.h in Headers */,
</span><span class="cx">                                 BC04EFFC16E65AFB00E336F0 /* WKWebProcessPlugInPrivate.h in Headers */,
</span><span class="lines">@@ -7489,6 +7496,7 @@
</span><span class="cx">                                 BC8699B6116AADAA002A925B /* WKView.mm in Sources */,
</span><span class="cx">                                 C5E1AFE816B20B67006CC1F2 /* WKWebArchive.cpp in Sources */,
</span><span class="cx">                                 C5E1AFEA16B20B7B006CC1F2 /* WKWebArchiveResource.cpp in Sources */,
</span><ins>+                                373CEAD5185417AE008C363D /* WKNSData.mm in Sources */,
</ins><span class="cx">                                 BC989D81161A7E5D000D46D3 /* WKWebProcessPlugIn.mm in Sources */,
</span><span class="cx">                                 BC8F2F2A16273A2C005FACB5 /* WKWebProcessPlugInBrowserContextController.mm in Sources */,
</span><span class="cx">                                 BC2E6E8D1141971500A63B1E /* WorkQueue.cpp in Sources */,
</span></span></pre>
</div>
</div>

</body>
</html>