Bug 236167 - [Cocoa] Always sync ResourceRequest isAppInitiated request with NSURLRequest attribution value
Summary: [Cocoa] Always sync ResourceRequest isAppInitiated request with NSURLRequest ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on:
Blocks: 238159
  Show dependency treegraph
 
Reported: 2022-02-04 16:39 PST by Brent Fulgham
Modified: 2022-03-21 15:54 PDT (History)
5 users (show)

See Also:


Attachments
Patch (4.00 KB, patch)
2022-02-04 18:41 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch for landing (11.77 KB, patch)
2022-02-07 17:15 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2022-02-04 16:39:11 PST
As noticed in Bug 236111, we should always keep the state of our 'isAppInitiated' flag in sync with the underlying NSURLRequest object.
Comment 1 Brent Fulgham 2022-02-04 16:44:44 PST
<rdar://88490742>
Comment 2 Brent Fulgham 2022-02-04 18:41:48 PST
Created attachment 450962 [details]
Patch
Comment 3 Darin Adler 2022-02-06 17:01:04 PST
Comment on attachment 450962 [details]
Patch

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

Can we make a regression test to show what this fixes?

> Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm:45
> +    : ResourceRequestBase()

Is this explicit initialization of the base class required? I suggest we try removing this; I believe it will still compile and generate the same code without it.

> Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm:301
> +    nsRequest.get().attribution = request.attribution;

Why use the setAttribution: syntax above, but the assignment syntax here? I would like ie better if it was consistent. I suggest we use the assignment syntax in all three places.
Comment 4 Brent Fulgham 2022-02-07 16:04:46 PST
Comment on attachment 450962 [details]
Patch

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

>> Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm:301
>> +    nsRequest.get().attribution = request.attribution;
> 
> Why use the setAttribution: syntax above, but the assignment syntax here? I would like ie better if it was consistent. I suggest we use the assignment syntax in all three places.

For some reason, the above initializations of nsRequest from 'adoptNS([m_nsRequest mutableCopy])' were computed as 'RetainPtr<id>'. The method call syntax compiled without errors, so I just used that. If I specify that the adoptNS is assigned to a RetainPtr<NSMutableURLRequest> the assignment syntax works.
I could also just cast the result of 'nsRequest.get()', but that seems a little gross. I prefer the "RetainPtr<NSMutableRequest> nsRequest = adoptNS(...)".

Do you have a preference?
Comment 5 Brent Fulgham 2022-02-07 17:15:56 PST
Created attachment 451179 [details]
Patch for landing
Comment 6 Darin Adler 2022-02-07 17:50:01 PST
Comment on attachment 451179 [details]
Patch for landing

I think it’s good the way you wrote it. I am not so surprised that the compiler doesn't know the type of the result of mutableCopy. It doesn’t use (instancetype) or any trick like that, so it’s just a method that returns an id.
Comment 7 EWS 2022-02-07 18:06:17 PST
Committed r289255 (246939@main): <https://commits.webkit.org/246939@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 451179 [details].