Bug 138893 - Add a version of API::Data::createWithoutCopying that takes an NSData
Summary: Add a version of API::Data::createWithoutCopying that takes an NSData
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-19 15:47 PST by Anders Carlsson
Modified: 2015-02-10 00:20 PST (History)
1 user (show)

See Also:


Attachments
Patch (12.25 KB, patch)
2014-11-19 15:48 PST, Anders Carlsson
no flags Details | Formatted Diff | Diff
Patch (10.50 KB, patch)
2014-11-19 15:53 PST, Anders Carlsson
mitz: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.