Bug 146643 - [Streams API] Remove ReadableStreamReader.read() custom binding
Summary: [Streams API] Remove ReadableStreamReader.read() custom binding
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords:
: 146405 (view as bug list)
Depends on:
Blocks: 146315
  Show dependency treegraph
 
Reported: 2015-07-06 10:06 PDT by youenn fablet
Modified: 2015-07-07 01:01 PDT (History)
3 users (show)

See Also:


Attachments
Patch (16.21 KB, patch)
2015-07-06 11:00 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (17.43 KB, patch)
2015-07-07 00:00 PDT, 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 2015-07-06 10:06:09 PDT
We should remove the custom binding and migrate read() to using DOMPromise dedicated to iterators.
Comment 1 youenn fablet 2015-07-06 11:00:50 PDT
Created attachment 256222 [details]
Patch
Comment 2 WebKit Commit Bot 2015-07-06 11:03:58 PDT
Attachment 256222 [details] did not pass style-queue:


ERROR: Source/WebCore/bindings/js/JSDOMPromise.h:117:  Should be indented on a separate line, with the colon or comma first on that line.  [whitespace/indent] [4]
Total errors found: 1 in 10 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Darin Adler 2015-07-06 20:22:23 PDT
Comment on attachment 256222 [details]
Patch

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

> Source/WebCore/bindings/js/JSDOMBinding.h:413
> +inline JSC::JSValue toJSIterator(JSC::ExecState* state, JSDOMGlobalObject*, JSC::JSValue value)
> +{
> +    return createIteratorResultObject(state, value, false);
> +}
> +
> +template<typename T> inline JSC::JSValue toJSIterator(JSC::ExecState* state, JSDOMGlobalObject* globalObject, const T& value)
> +{
> +    return createIteratorResultObject(state, toJS(state, globalObject, value), false);
> +}
> +
> +inline JSC::JSValue toJSIteratorEnd(JSC::ExecState* state)
> +{
> +    return createIteratorResultObject(state, JSC::jsUndefined(), true);
> +}

I suggest having all these new functions take references rather than pointers.

> Source/WebCore/bindings/js/JSDOMPromise.h:49
> +    JSDOMGlobalObject* globalObject() const { return m_globalObject.get(); } 

If this can never be null, then I suggest returning a reference, not a pointer.

> Source/WebCore/bindings/js/JSDOMPromise.h:117
> +    DOMPromiseIteratorWithCallback(DeferredWrapper&& wrapper) : m_wrapper(WTF::move(wrapper)) { }

Please consider marking this explicit.

> Source/WebCore/bindings/js/JSDOMPromise.h:131
> +    DOMPromiseIteratorWithCallback(DOMPromiseIteratorWithCallback&& promise)
> +        : m_wrapper(WTF::move(promise.m_wrapper))
> +        , m_resolveCallback(WTF::move(promise.m_resolveCallback))
> +        , m_resolveEndCallback(WTF::move(promise.m_resolveEndCallback))
> +        , m_rejectCallback(WTF::move(promise.m_rejectCallback)) { }

This should be generated automatically by the compiler as long as you don’t explicitly define it. Could you try omitting it?

> Source/WebCore/bindings/js/JSDOMPromise.h:283
> +    ASSERT(m_wrapper);

Seems overkill to assert this here, since m_wrapper.value() will also assert it.

> Source/WebCore/bindings/js/JSDOMPromise.h:284
> +    JSDOMGlobalObject* globalObject = m_wrapper.value().globalObject();

Should use a reference here since this can never be null. Also might want to use auto& instead of JSDOMGlobalObject&.

> Source/WebCore/bindings/js/JSDOMPromise.h:295
> +    ASSERT(m_wrapper);

Seems overkill to assert this here, since m_wrapper.value() will also assert it.

> Source/WebCore/bindings/js/JSDOMPromise.h:306
> +    ASSERT(m_wrapper);

Seems overkill to assert this here, since m_wrapper.value() will also assert it.
Comment 4 youenn fablet 2015-07-06 23:59:23 PDT
(In reply to comment #3)
> Comment on attachment 256222 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=256222&action=review

Thanks for the review.

> 
> > Source/WebCore/bindings/js/JSDOMBinding.h:413
> > +inline JSC::JSValue toJSIterator(JSC::ExecState* state, JSDOMGlobalObject*, JSC::JSValue value)
> > +{
> > +    return createIteratorResultObject(state, value, false);
> > +}
> > +
> > +template<typename T> inline JSC::JSValue toJSIterator(JSC::ExecState* state, JSDOMGlobalObject* globalObject, const T& value)
> > +{
> > +    return createIteratorResultObject(state, toJS(state, globalObject, value), false);
> > +}
> > +
> > +inline JSC::JSValue toJSIteratorEnd(JSC::ExecState* state)
> > +{
> > +    return createIteratorResultObject(state, JSC::jsUndefined(), true);
> > +}
> 
> I suggest having all these new functions take references rather than
> pointers.

OK. I was not sure of doing that given the other functions in the same file but I will try to stick with this rule.

> > Source/WebCore/bindings/js/JSDOMPromise.h:49
> > +    JSDOMGlobalObject* globalObject() const { return m_globalObject.get(); } 
> 
> If this can never be null, then I suggest returning a reference, not a
> pointer.

It can be null in theory, but in practice, this method should never be called if it is null. I will do the change, adding an ASSERT within the getter.

> 
> > Source/WebCore/bindings/js/JSDOMPromise.h:117
> > +    DOMPromiseIteratorWithCallback(DeferredWrapper&& wrapper) : m_wrapper(WTF::move(wrapper)) { }
> 
> Please consider marking this explicit.

We cannot do that as we use implicit conversion from DeferredWrapper (created in generated binding) to DOMPromiseXXX in DOM classes.

> 
> > Source/WebCore/bindings/js/JSDOMPromise.h:131
> > +    DOMPromiseIteratorWithCallback(DOMPromiseIteratorWithCallback&& promise)
> > +        : m_wrapper(WTF::move(promise.m_wrapper))
> > +        , m_resolveCallback(WTF::move(promise.m_resolveCallback))
> > +        , m_resolveEndCallback(WTF::move(promise.m_resolveEndCallback))
> > +        , m_rejectCallback(WTF::move(promise.m_rejectCallback)) { }
> 
> This should be generated automatically by the compiler as long as you don’t
> explicitly define it. Could you try omitting it?

Tried and it is working. I will do the same for DOMPromiseWithCallback.

> > Source/WebCore/bindings/js/JSDOMPromise.h:283
> > +    ASSERT(m_wrapper);
> 
> Seems overkill to assert this here, since m_wrapper.value() will also assert
> it.

OK
Comment 5 youenn fablet 2015-07-07 00:00:59 PDT
Created attachment 256283 [details]
Patch for landing
Comment 6 youenn fablet 2015-07-07 00:04:27 PDT
*** Bug 146405 has been marked as a duplicate of this bug. ***
Comment 7 WebKit Commit Bot 2015-07-07 01:01:26 PDT
Comment on attachment 256283 [details]
Patch for landing

Clearing flags on attachment: 256283

Committed r186414: <http://trac.webkit.org/changeset/186414>
Comment 8 WebKit Commit Bot 2015-07-07 01:01:48 PDT
All reviewed patches have been landed.  Closing bug.