Bug 210407 - Remove addExtraFieldsToSubresourceRequest
Summary: Remove addExtraFieldsToSubresourceRequest
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-12 10:45 PDT by Rob Buis
Modified: 2020-04-13 01:05 PDT (History)
5 users (show)

See Also:


Attachments
Patch (6.83 KB, patch)
2020-04-12 10:47 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (11.04 KB, patch)
2020-04-12 14:21 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (11.15 KB, patch)
2020-04-12 23:55 PDT, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rob Buis 2020-04-12 10:45:43 PDT
Remove addExtraFieldsToSubresourceRequest since it can be replaced by
calling addExtraFieldsToRequest. The loadType parameter is not taken
into account by defaultRequestCachingPolicy so FrameLoadType::Standard
rather than m_loadType is passed.
Comment 1 Rob Buis 2020-04-12 10:47:41 PDT
Created attachment 396231 [details]
Patch
Comment 2 Darin Adler 2020-04-12 12:55:10 PDT
Comment on attachment 396231 [details]
Patch

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

> Source/WebCore/ChangeLog:11
> +        Remove addExtraFieldsToSubresourceRequest since it can be replaced by
> +        calling addExtraFieldsToRequest. The loadType parameter is not taken
> +        into account by defaultRequestCachingPolicy so FrameLoadType::Standard
> +        rather than m_loadType is passed.

I’m not completely comfortable with passing a "wrong" load type, knowing that the load type doesn’t matter. Is there some better way to resolve this.

> Source/WebCore/loader/FrameLoader.cpp:3059
> +    addExtraFieldsToRequest(initialRequest, FrameLoadType::Standard, false);

I’m not thrilled with spreading more mysterious "false" arguments in even more places in the code.
Comment 3 Rob Buis 2020-04-12 14:20:37 PDT
Comment on attachment 396231 [details]
Patch

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

>> Source/WebCore/ChangeLog:11
>> +        rather than m_loadType is passed.
> 
> I’m not completely comfortable with passing a "wrong" load type, knowing that the load type doesn’t matter. Is there some better way to resolve this.

I gave the LoadType parameter a default value so addExtraFieldsToRequest calls for subresources do not need to specify anything for it.

>> Source/WebCore/loader/FrameLoader.cpp:3059
>> +    addExtraFieldsToRequest(initialRequest, FrameLoadType::Standard, false);
> 
> I’m not thrilled with spreading more mysterious "false" arguments in even more places in the code.

Fair enough, I added an enum
Comment 4 Rob Buis 2020-04-12 14:21:16 PDT
Created attachment 396239 [details]
Patch
Comment 5 Darin Adler 2020-04-12 14:30:43 PDT
Comment on attachment 396239 [details]
Patch

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

OK

> Source/WebCore/loader/FrameLoader.h:94
> +enum class MainResource : bool { Yes, No };

I think the name should be either ForMainResource or IsMainResource. A type named MainResource sounds more like a resource than an indicator of the nature of a resource.

Also, I suggest { No, Yes } so we have the traditional representation of 0 for false and 1 for true.

> Source/WebCore/loader/FrameLoader.h:332
> +    void addExtraFieldsToRequest(ResourceRequest&, MainResource, FrameLoadType = FrameLoadType::Standard);

How should a caller know when it’s important to pass in a load type, and when it’s not important?
Comment 6 Rob Buis 2020-04-12 23:55:07 PDT
Created attachment 396259 [details]
Patch
Comment 7 Rob Buis 2020-04-13 00:39:45 PDT
Comment on attachment 396239 [details]
Patch

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

>> Source/WebCore/loader/FrameLoader.h:94
>> +enum class MainResource : bool { Yes, No };
> 
> I think the name should be either ForMainResource or IsMainResource. A type named MainResource sounds more like a resource than an indicator of the nature of a resource.
> 
> Also, I suggest { No, Yes } so we have the traditional representation of 0 for false and 1 for true.

That is better indeed, fixed.

>> Source/WebCore/loader/FrameLoader.h:332
>> +    void addExtraFieldsToRequest(ResourceRequest&, MainResource, FrameLoadType = FrameLoadType::Standard);
> 
> How should a caller know when it’s important to pass in a load type, and when it’s not important?

It is hard to make it clear but I added a comment for it.
Comment 8 EWS 2020-04-13 01:04:43 PDT
Committed r259997: <https://trac.webkit.org/changeset/259997>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 396259 [details].
Comment 9 Radar WebKit Bug Importer 2020-04-13 01:05:14 PDT
<rdar://problem/61703487>