Bug 163332 - Make NetworkCache aware of fetch cache mode
Summary: Make NetworkCache aware of fetch cache mode
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-12 08:05 PDT by youenn fablet
Modified: 2017-07-06 11:51 PDT (History)
9 users (show)

See Also:


Attachments
Patch (35.47 KB, patch)
2016-10-12 08:18 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (123.26 KB, patch)
2016-10-13 02:56 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (122.99 KB, patch)
2016-10-13 04:24 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews114 for mac-yosemite (911.98 KB, application/zip)
2016-10-13 05:31 PDT, Build Bot
no flags Details
Fixing assert and builds (122.33 KB, patch)
2016-10-13 06:00 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (122.96 KB, patch)
2016-10-14 00:34 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (123.32 KB, patch)
2016-10-14 00:44 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2016-10-12 08:05:38 PDT
Fetch cache mode handling of MemoryCache is mostly implemented but the same should be done for the NetworkCache.
Comment 1 youenn fablet 2016-10-12 08:18:01 PDT
Created attachment 291357 [details]
Patch
Comment 2 WebKit Commit Bot 2016-10-12 08:20:30 PDT
Attachment 291357 [details] did not pass style-queue:


ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:312:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCache.h:109:  Extra space before ( in function call  [whitespace/parens] [4]
Total errors found: 2 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 youenn fablet 2016-10-12 08:25:36 PDT
(In reply to comment #1)
> Created attachment 291357 [details]
> Patch

I am not exactly sure what is the best option to pass the additional cache mode information from WebCore to NetworkProcess.
There seems to be two choices:
1 Pass FetchOptions::Cache information to NetworkProcess
2 Update ResourceRequestCachePolicy to add more modes: NoCache, NoStore and Reload

I chose option 1 since it is the simplest.

I would prefer option 2:
- No need to add code to pass the new parameter
- No need to check two different parameters in NetworkCache with slightly different meanings
- WK1 could eventually catch up if CF network cache supports these new options.


I chose option 1 since I was not sure whether there is a strong requirement to keep the resource request cache policy aligned with CFNetwork cache policy.

This patch is pending bug 161310.
If that is not possible to go forward with bug 161310, it might be possible to split the test file in several so that the console log issue will not hit all tests.
Comment 4 Antti Koivisto 2016-10-12 11:50:54 PDT
> I chose option 1 since I was not sure whether there is a strong requirement
> to keep the resource request cache policy aligned with CFNetwork cache
> policy.

I think we should consider ResourceRequest/Response as pure WebCore types as opposed to wrappers for CFNetwork types. We shouldn't worry about keeping them aligned.
Comment 5 youenn fablet 2016-10-13 02:56:31 PDT
Created attachment 291469 [details]
Patch
Comment 6 youenn fablet 2016-10-13 04:24:31 PDT
Created attachment 291472 [details]
Patch
Comment 7 Build Bot 2016-10-13 05:31:41 PDT
Comment on attachment 291472 [details]
Patch

Attachment 291472 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/2276449

Number of test failures exceeded the failure limit.
Comment 8 Build Bot 2016-10-13 05:31:44 PDT
Created attachment 291473 [details]
Archive of layout-test-results from ews114 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews114  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 9 youenn fablet 2016-10-13 06:00:15 PDT
Created attachment 291475 [details]
Fixing assert and builds
Comment 10 Antti Koivisto 2016-10-13 08:54:53 PDT
Comment on attachment 291475 [details]
Fixing assert and builds

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

> Source/WebCore/platform/network/ResourceRequestBase.h:44
> +    UseProtocolCachePolicy, // normal load, equivalent to fetch "default" cache mode.
> +    ReloadIgnoringCacheData, // reload, equivalent to fetch "reload"cache mode.
> +    ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data, equivalent to fetch "force-cache" cache mode.
> +    ReturnCacheDataDontLoad, // results of a post - allow stale data and only use cache, equivalent to fetch "only-if-cached" cache mode.
> +    DoNotUseAnyCache, // Bypass the cache entirely, equivalent to fetch "no-store" cache mode.
> +    RefreshAnyCacheData, // Serve cache data only if revalidated, equivalent to fetch "no-cache" mode.

In future it would be good to also improve the existing names so they would require fewer comments to understand. The old names are straight from CFNetwork.

> Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp:176
> +static inline CFURLRequestCachePolicy toPlatformRequestCachePolicy(ResourceRequestCachePolicy policy)
> +{
> +    return (CFURLRequestCachePolicy)((policy <= ReturnCacheDataDontLoad) ? policy : ReloadIgnoringCacheData);
> +}

At least it this should use static_cast but it would really be more understandable with a switch.

> Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm:69
> +        m_cachePolicy = (ResourceRequestCachePolicy)[m_nsRequest.get() cachePolicy];

Please use static_cast or better yet, add a conversion function.

> Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm:120
>  
> +static inline NSURLRequestCachePolicy toPlatformRequestCachePolicy(ResourceRequestCachePolicy policy)
> +{
> +    return (NSURLRequestCachePolicy)((policy <= ReturnCacheDataDontLoad) ? policy : ReloadIgnoringCacheData);
> +}

Same comment as above.
Comment 11 youenn fablet 2016-10-14 00:34:10 PDT
Created attachment 291583 [details]
Patch for landing
Comment 12 youenn fablet 2016-10-14 00:37:09 PDT
Thanks for the review.

(In reply to comment #10)
> Comment on attachment 291475 [details]
> Fixing assert and builds
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=291475&action=review
> 
> > Source/WebCore/platform/network/ResourceRequestBase.h:44
> > +    UseProtocolCachePolicy, // normal load, equivalent to fetch "default" cache mode.
> > +    ReloadIgnoringCacheData, // reload, equivalent to fetch "reload"cache mode.
> > +    ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data, equivalent to fetch "force-cache" cache mode.
> > +    ReturnCacheDataDontLoad, // results of a post - allow stale data and only use cache, equivalent to fetch "only-if-cached" cache mode.
> > +    DoNotUseAnyCache, // Bypass the cache entirely, equivalent to fetch "no-store" cache mode.
> > +    RefreshAnyCacheData, // Serve cache data only if revalidated, equivalent to fetch "no-cache" mode.
> 
> In future it would be good to also improve the existing names so they would
> require fewer comments to understand. The old names are straight from
> CFNetwork.

Agreed.

> > Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp:176
> > +static inline CFURLRequestCachePolicy toPlatformRequestCachePolicy(ResourceRequestCachePolicy policy)
> > +{
> > +    return (CFURLRequestCachePolicy)((policy <= ReturnCacheDataDontLoad) ? policy : ReloadIgnoringCacheData);
> > +}
> 
> At least it this should use static_cast but it would really be more
> understandable with a switch.

Updated to use a switch

> > Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm:69
> > +        m_cachePolicy = (ResourceRequestCachePolicy)[m_nsRequest.get() cachePolicy];
> 
> Please use static_cast or better yet, add a conversion function.

Forgot this one in the landing patch... Will add it.

> > Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm:120
> >  
> > +static inline NSURLRequestCachePolicy toPlatformRequestCachePolicy(ResourceRequestCachePolicy policy)
> > +{
> > +    return (NSURLRequestCachePolicy)((policy <= ReturnCacheDataDontLoad) ? policy : ReloadIgnoringCacheData);
> > +}
> 
> Same comment as above.

Updated to use a switch.
Comment 13 youenn fablet 2016-10-14 00:44:24 PDT
Created attachment 291586 [details]
Patch for landing
Comment 14 WebKit Commit Bot 2016-10-14 01:49:55 PDT
Comment on attachment 291586 [details]
Patch for landing

Clearing flags on attachment: 291586

Committed r207330: <http://trac.webkit.org/changeset/207330>
Comment 15 WebKit Commit Bot 2016-10-14 01:50:00 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 Csaba Osztrogonác 2016-10-14 03:29:03 PDT
(In reply to comment #14)
> Comment on attachment 291586 [details]
> Patch for landing
> 
> Clearing flags on attachment: 291586
> 
> Committed r207330: <http://trac.webkit.org/changeset/207330>

It broke the Apple Windows build, see build.webkit.org for details.
Comment 17 youenn fablet 2016-10-14 03:39:48 PDT
(In reply to comment #16)
> (In reply to comment #14)
> > Comment on attachment 291586 [details]
> > Patch for landing
> > 
> > Clearing flags on attachment: 291586
> > 
> > Committed r207330: <http://trac.webkit.org/changeset/207330>
> 
> It broke the Apple Windows build, see build.webkit.org for details.

Thanks, I will check this!
Comment 18 Alex Christensen 2017-07-06 11:51:01 PDT
http://trac.webkit.org/r219210