Bug 194651

Summary: Make ServiceWorkerClientFetch closer to WebResourceLoader
Product: WebKit Reporter: youenn fablet <youennf>
Component: Service WorkersAssignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, cdumez, commit-queue, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 194716    
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing
none
Patch none

Description youenn fablet 2019-02-14 07:53:40 PST
Now that service worker registrations are in the network process, we could consider serve service worker content through the regular network process loading code path.
The first step is to make ServiceWorkerClientFetch closer to WebResourceLoader.
Comment 1 youenn fablet 2019-02-14 08:33:10 PST
Created attachment 362019 [details]
Patch
Comment 2 youenn fablet 2019-02-14 15:02:53 PST
Created attachment 362067 [details]
Patch
Comment 3 Alex Christensen 2019-02-15 10:49:12 PST
Comment on attachment 362067 [details]
Patch

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

> Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp:220
> +    }, WorkerRunLoop::defaultMode());

Could we make this a default parameter?

> Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h:65
> +    void didReceiveRedirectResponse(WebCore::ResourceResponse&&);

Do we want to just inform that a redirect happened, or will we in the future have a need for the service worker to be able to reject the redirect?

> Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:201
> +        auto formData = WTFMove(m_formData);
> +        didReceiveFormDataAndFinish(formData.releaseNonNull());

Could we just call m_formData.releaseNonNull() without WTFMove?

> Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h:86
> +    RefPtr<WebCore::SharedBuffer> m_buffer;
> +    RefPtr<FormData> m_formData;

Can these be a Variant, or could we have more than one of these?

> Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h:88
> +    Optional<ResourceError> m_error;

Making this a std::unique_ptr would save memory in the common case.
Comment 4 youenn fablet 2019-02-15 11:54:49 PST
Created attachment 362140 [details]
Patch for landing
Comment 5 youenn fablet 2019-02-15 11:56:39 PST
Thanks for the review.

(In reply to Alex Christensen from comment #3)
> Comment on attachment 362067 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=362067&action=review
> 
> > Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp:220
> > +    }, WorkerRunLoop::defaultMode());
> 
> Could we make this a default parameter?

Sure, could be done as a separate patch.

> > Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h:65
> > +    void didReceiveRedirectResponse(WebCore::ResourceResponse&&);
> 
> Do we want to just inform that a redirect happened, or will we in the future
> have a need for the service worker to be able to reject the redirect?

When fetch event respondWith is called, there is no way back.
A DocumentLoader may trigger another service worker fetch which will be treated as another fetch event.

> > Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:201
> > +        auto formData = WTFMove(m_formData);
> > +        didReceiveFormDataAndFinish(formData.releaseNonNull());
> 
> Could we just call m_formData.releaseNonNull() without WTFMove?
> 
> > Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h:86
> > +    RefPtr<WebCore::SharedBuffer> m_buffer;
> > +    RefPtr<FormData> m_formData;
> 
> Can these be a Variant, or could we have more than one of these?
> 
> > Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.h:88
> > +    Optional<ResourceError> m_error;
> 
> Making this a std::unique_ptr would save memory in the common case.

I updated the patch to make all of these a Variant with proper Ref<>, UniqueRef<>.
Comment 6 WebKit Commit Bot 2019-02-15 12:25:08 PST
Comment on attachment 362140 [details]
Patch for landing

Clearing flags on attachment: 362140

Committed r241603: <https://trac.webkit.org/changeset/241603>
Comment 7 WebKit Commit Bot 2019-02-15 12:25:09 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2019-02-15 12:26:56 PST
<rdar://problem/48120172>
Comment 9 youenn fablet 2019-02-15 12:42:36 PST
Reopening to attach new patch.
Comment 10 youenn fablet 2019-02-15 12:42:37 PST
Created attachment 362146 [details]
Patch
Comment 11 WebKit Commit Bot 2019-02-15 13:18:52 PST
Comment on attachment 362146 [details]
Patch

Clearing flags on attachment: 362146

Committed r241609: <https://trac.webkit.org/changeset/241609>
Comment 12 WebKit Commit Bot 2019-02-15 13:18:54 PST
All reviewed patches have been landed.  Closing bug.