Bug 138893

Summary: Add a version of API::Data::createWithoutCopying that takes an NSData
Product: WebKit Reporter: Anders Carlsson <andersca>
Component: New BugsAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal CC: joepeck
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch mitz: review+

Description Anders Carlsson 2014-11-19 15:47:14 PST
Add a version of API::Data::createWithoutCopying that takes an NSData
Comment 1 Anders Carlsson 2014-11-19 15:48:10 PST
Created attachment 241898 [details]
Patch
Comment 2 Anders Carlsson 2014-11-19 15:53:38 PST
Created attachment 241900 [details]
Patch
Comment 3 mitz 2014-11-19 15:56:16 PST
Comment on attachment 241900 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=241900&action=review

> Source/WebKit2/Shared/Cocoa/APIDataCocoa.mm:32
> +PassRefPtr<Data> Data::createWithoutCopying(RetainPtr<NSData> data)
> +{

I think you should first check if data is a WKNSData and if so unwrap it :-|
Comment 4 Anders Carlsson 2014-11-19 16:02:13 PST
Committed r176362: <http://trac.webkit.org/changeset/176362>
Comment 5 Joseph Pecoraro 2015-02-10 00:19:19 PST
Comment on attachment 241900 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=241900&action=review

> Source/WebKit2/UIProcess/API/Cocoa/WKBrowsingContextController.mm:245
>          [data retain];
> -        apiData = API::Data::createWithoutCopying((const unsigned char*)[data bytes], [data length], releaseNSData, data);
> +        apiData = API::Data::createWithoutCopying(data);

Given that the createWithoutCopying now takes a RetainPtr<NSData> and leakRef's its contents, is the [data retain] line here necessary? It seems this would be an unbalanced +1.