Bug 141186

Summary: Drop ResourceLoadPriorityUnresolved resource load priority and use Optional<> instead
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Page LoadingAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, koivisto
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 141230    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Chris Dumez 2015-02-02 19:55:54 PST
Make ResourceLoadPriorityUnresolved a CachedResourceRequest-specific priority as it is not a valid value for ResourceRequest. This makes it clearer ResourceRequest::priority() cannot be ResourceLoadPriorityUnresolved and thus cannot be negative.

A new CachedResourceLoadPriority enum is introduced for CachedResourceRequest's priority. ResourceLoadPriorityUnresolved is also renamed to CachedResourceLoadPriorityTypeDefault as it makes its meaning clearer. If CachedResourceLoadPriorityTypeDefault priority is set on the CachedResourceRequest, it is later going to be converted to a ResourceLoadPriority by selecting the default priority for the CachedResource's type.
Comment 1 Chris Dumez 2015-02-02 20:58:20 PST
Created attachment 245923 [details]
Patch
Comment 2 Antti Koivisto 2015-02-03 02:45:52 PST
Comment on attachment 245923 [details]
Patch

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

> Source/WebCore/platform/network/ResourceLoadPriority.h:44
> +enum CachedResourceLoadPriority {
> +    CachedResourceLoadPriorityTypeDefault = -1,
> +    CachedResourceLoadPriorityVeryLow = 0,
> +    CachedResourceLoadPriorityLow,
> +    CachedResourceLoadPriorityMedium,
> +    CachedResourceLoadPriorityHigh,
> +    CachedResourceLoadPriorityVeryHigh,
> +};
> +
>  enum ResourceLoadPriority {
> -    // The unresolved priority is here for the convenience of the clients. It should not be passed to the ResourceLoadScheduler.
> -    ResourceLoadPriorityUnresolved = -1,
> -    ResourceLoadPriorityVeryLow = 0,
> +    ResourceLoadPriorityVeryLow,
>      ResourceLoadPriorityLow,
>      ResourceLoadPriorityMedium,
>      ResourceLoadPriorityHigh,

It seems pretty unfortunate to have two of these. Could we find other solution, for example by replacing uses of CachedResourceLoadPriority with Optional<ResourceLoadPriority>?

Defining CachedResourceLoadPriority here is a (minor) platform violation. Nothing in platform/ shouldn't know about CachedResources. The definition should probably be in CachedResources.h or thereabouts.
Comment 3 Chris Dumez 2015-02-03 13:54:41 PST
Created attachment 245964 [details]
Patch
Comment 4 Antti Koivisto 2015-02-03 15:34:44 PST
Comment on attachment 245964 [details]
Patch

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

> Source/WebCore/loader/cache/CachedResourceRequest.h:54
> +    void setPriority(Optional<ResourceLoadPriority> priority) { m_priority = WTF::move(priority); }

I can't find any clients for this. Maybe it is not used and could be removed?

> Source/WebCore/platform/network/ResourceRequestBase.h:226
> +        unsigned m_allowCookies : 1;
> +        mutable unsigned m_resourceRequestUpdated : 1;
> +        mutable unsigned m_platformRequestUpdated : 1;
> +        mutable unsigned m_resourceRequestBodyUpdated : 1;
> +        mutable unsigned m_platformRequestBodyUpdated : 1;
> +        unsigned m_reportUploadProgress : 1;
> +        unsigned m_reportLoadTiming : 1;
> +        unsigned m_reportRawHeaders : 1;
> +        unsigned m_hiddenFromInspector : 1;
> +        unsigned m_priority : 4;

These could probably just be regular fields instead of bitfields. I don't think there is meaningful memory savings here.
Comment 5 Chris Dumez 2015-02-03 15:38:46 PST
Created attachment 245978 [details]
Patch
Comment 6 Chris Dumez 2015-02-03 15:39:49 PST
Created attachment 245979 [details]
Patch
Comment 7 WebKit Commit Bot 2015-02-03 17:24:08 PST
Comment on attachment 245979 [details]
Patch

Clearing flags on attachment: 245979

Committed r179584: <http://trac.webkit.org/changeset/179584>
Comment 8 WebKit Commit Bot 2015-02-03 17:24:13 PST
All reviewed patches have been landed.  Closing bug.