Bug 175658

Summary: [Cache API] Add response body storage
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, beidson, buildbot, cdumez, cgarcia, commit-queue, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing none

Description youenn fablet 2017-08-16 23:19:01 PDT
[Cache API] Add response body storage
Comment 1 youenn fablet 2017-08-16 23:24:01 PDT
Created attachment 318332 [details]
Patch
Comment 2 youenn fablet 2017-08-17 09:50:42 PDT
Created attachment 318375 [details]
Patch
Comment 3 youenn fablet 2017-08-17 10:27:17 PDT
Created attachment 318377 [details]
Patch
Comment 4 youenn fablet 2017-08-17 11:15:02 PDT
Created attachment 318389 [details]
Patch
Comment 5 youenn fablet 2017-08-17 11:22:23 PDT
Created attachment 318390 [details]
Patch
Comment 6 Alex Christensen 2017-08-17 15:40:16 PDT
Comment on attachment 318390 [details]
Patch

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

> Source/WebCore/Modules/fetch/FetchResponse.h:109
> +    static void startFetching(ScriptExecutionContext&, FetchRequest&, std::optional<FetchPromise>&&, std::optional<EndOfLoad>&&);

I don't think it's elegant to change FetchResponse from a class that used to always resolve a promise when it's done to a class that either resolves a promise when it's done or calls a lambda.  I think instead we should make it a class that always calls a lambda when it's done and the lambda would resolve a promise in the cases where it should, or we should take a Variant<FetchPromise, EndOfLoadCallback> to make it clear that it does one or the other, then make better abstractions for what it is supposed to do when it's done.
Comment 7 youenn fablet 2017-08-17 18:37:47 PDT
> I don't think it's elegant to change FetchResponse from a class that used to
> always resolve a promise when it's done to a class that either resolves a
> promise when it's done or calls a lambda.  I think instead we should make it
> a class that always calls a lambda when it's done and the lambda would
> resolve a promise in the cases where it should, or we should take a
> Variant<FetchPromise, EndOfLoadCallback> to make it clear that it does one
> or the other, then make better abstractions for what it is supposed to do
> when it's done.

The two lambdas will be useful for the same fetch response in the future.
I will change the promise into a lambda and add a setter for EndOfLoadCallback.
Comment 8 youenn fablet 2017-08-18 09:52:42 PDT
Created attachment 318514 [details]
Patch
Comment 9 Alex Christensen 2017-08-18 10:48:30 PDT
Comment on attachment 318514 [details]
Patch

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

> Source/WebKit/Shared/WebCoreArgumentCoders.cpp:114
> +static void encodeSharedBuffer(Encoder& encoder, const SharedBuffer* buffer)

We're just moving this code to use it below?  We already kind of have this in SharedBufferDataReference.  This should be united with that, and maybe that should be cleaned up.
Comment 10 youenn fablet 2017-08-18 10:58:00 PDT
(In reply to Alex Christensen from comment #9)
> Comment on attachment 318514 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=318514&action=review
> 
> > Source/WebKit/Shared/WebCoreArgumentCoders.cpp:114
> > +static void encodeSharedBuffer(Encoder& encoder, const SharedBuffer* buffer)
> 
> We're just moving this code to use it below?  We already kind of have this
> in SharedBufferDataReference.  This should be united with that, and maybe
> that should be cleaned up.

Didn't know about SharedBufferDataReference.
Code is moved and refreshed a bit.
It also fixes a potential bug when trying to encode a SharedBuffer whose size is 0.
Comment 11 youenn fablet 2017-08-18 11:03:08 PDT
Comment on attachment 318514 [details]
Patch

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

> Source/WebKit/Shared/WebCoreArgumentCoders.cpp:367
> +        responseBody = buffer.releaseNonNull();

But then, we should only set responseBody if buffer is not null here...
Comment 12 youenn fablet 2017-08-18 11:08:26 PDT
Created attachment 318519 [details]
Patch for landing
Comment 13 Alex Christensen 2017-08-18 11:16:07 PDT
(In reply to youenn fablet from comment #10)
> Didn't know about SharedBufferDataReference.
We should probably get rid of it.
Comment 14 WebKit Commit Bot 2017-08-18 12:32:52 PDT
Comment on attachment 318519 [details]
Patch for landing

Clearing flags on attachment: 318519

Committed r220928: <http://trac.webkit.org/changeset/220928>
Comment 15 WebKit Commit Bot 2017-08-18 12:32:54 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 Radar WebKit Bug Importer 2017-08-18 12:33:40 PDT
<rdar://problem/33967936>