Bug 194651 - Make ServiceWorkerClientFetch closer to WebResourceLoader
Summary: Make ServiceWorkerClientFetch closer to WebResourceLoader
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Service Workers (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks: 194716
  Show dependency treegraph
 
Reported: 2019-02-14 07:53 PST by youenn fablet
Modified: 2019-02-15 13:18 PST (History)
4 users (show)

See Also:


Attachments
Patch (51.29 KB, patch)
2019-02-14 08:33 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (50.42 KB, patch)
2019-02-14 15:02 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (50.61 KB, patch)
2019-02-15 11:54 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (1.25 KB, patch)
2019-02-15 12:42 PST, 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 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.