Bug 145262

Summary: [Streams API] Implement pulling of a source by a ReadableStream
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, calvaris, commit-queue
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 145210    
Bug Blocks: 138967    
Attachments:
Description Flags
Patch
none
Rebasing
none
Fixed typo
none
Patch for landing none

Description youenn fablet 2015-05-21 05:18:16 PDT
At start time or after reading some data, a ReadableStream may want to pull data from its source until a limit.
This mechanism should be implemented.
Comment 1 youenn fablet 2015-06-09 01:16:50 PDT
Created attachment 254556 [details]
Patch
Comment 2 youenn fablet 2015-06-09 01:58:21 PDT
Created attachment 254557 [details]
Rebasing
Comment 3 youenn fablet 2015-06-09 07:59:33 PDT
Created attachment 254569 [details]
Fixed typo
Comment 4 Darin Adler 2015-06-09 09:49:45 PDT
Comment on attachment 254569 [details]
Fixed typo

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

> Source/WebCore/bindings/js/ReadableJSStream.cpp:108
> +    ExecState& exec= *globalObject()->globalExec();

Missing space here before before the "=" sign. Also, lately I have been thinking we should start using “state” as the name for this rather then “exec”.

> Source/WebCore/bindings/js/ReadableJSStream.cpp:153
> +bool ReadableJSStream::checkForException(JSC::ExecState& exec)

I don’t think the name for this is exactly right; this does more than just “check for” an exception. It moves the exception from the execution state to the stream object. It’s a lot like “store error” in fact. I think maybe the storeError that doesn’t take an argument should just do this if there’s an exception in the exception state.

I also think the idea of having this function do the hadException boolean check is so great. If the caller needs to distinguish that case, I think checking hadException at the call site makes no sense.
Comment 5 youenn fablet 2015-06-09 10:15:49 PDT
Comment on attachment 254569 [details]
Fixed typo

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

>> Source/WebCore/bindings/js/ReadableJSStream.cpp:108
>> +    ExecState& exec= *globalObject()->globalExec();
> 
> Missing space here before before the "=" sign. Also, lately I have been thinking we should start using “state” as the name for this rather then “exec”.

OK

>> Source/WebCore/bindings/js/ReadableJSStream.cpp:153
>> +bool ReadableJSStream::checkForException(JSC::ExecState& exec)
> 
> I don’t think the name for this is exactly right; this does more than just “check for” an exception. It moves the exception from the execution state to the stream object. It’s a lot like “store error” in fact. I think maybe the storeError that doesn’t take an argument should just do this if there’s an exception in the exception state.
> 
> I also think the idea of having this function do the hadException boolean check is so great. If the caller needs to distinguish that case, I think checking hadException at the call site makes no sense.

Initially, I did a first version doing everything in storeError().
The issue is that storeError() will always store an error, even if none is provided, in case of "controller.error()" for instance.
We would need to do twice a exec.hadException() check if doing everything in storeError().

I plan to rewrite this using "void ReadableJSStream::storeException(ExecState&)" in lieu of checkForException.
Please let me know if you have any better idea.
Comment 6 youenn fablet 2015-06-09 12:44:10 PDT
Created attachment 254590 [details]
Patch for landing
Comment 7 WebKit Commit Bot 2015-06-10 01:11:00 PDT
Comment on attachment 254590 [details]
Patch for landing

Clearing flags on attachment: 254590

Committed r185406: <http://trac.webkit.org/changeset/185406>
Comment 8 WebKit Commit Bot 2015-06-10 01:11:05 PDT
All reviewed patches have been landed.  Closing bug.