Closed Bug 1809408 Opened 2 years ago Closed 2 years ago

Do not expose stream-internal algorithms; implement separate exposed functions if needed

Categories

(Core :: DOM: Streams, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
111 Branch
Tracking Status
firefox111 --- fixed

People

(Reporter: saschanaz, Assigned: saschanaz)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

For example, ReadableStreamClose does not correspond to https://streams.spec.whatwg.org/#readablestream-close but it's way too easy to be confused.

Yeah... this is a recurring challenge; the 'un-named' spec operations which overlap with clearly defined 'internal' methods.

For anyone following, ReadableStreamClose instead corresponds to the same named 'internal' method.

Having said that, making sure we obey the spec invariant a bit earlier "The following algorithms must only be used on ReadableStream instances initialized via the above set up or set up with byte reading support algorithms (not, e.g., on web-developer-created instances):" is also important.

Depends on: 1809673

I'm planning to move all the internal things to internal.h and exclude that header from moz.build. (The actual implementations are okay to be in the current files.)

Depends on: 1809895
Depends on: 1810152
Depends on: 1810759
Depends on: 1812315

I don't think I like this approach. All functions declarations in one file, unrelated to the implementation, seems like a step backwards to me. Maybe we should consider introducing an internal namespace?

Sounds like an option. That will still expose things, but at least people will see it's for internal things. Also less destructive in terms of VCS as moving things means harder to track history. I'll try that.

Attachment #9313981 - Attachment description: Bug 1809408 - Part 1: Move ReadableStream internal algorithms to a separate header r=evilpie → Bug 1809408 - Part 1: Move ReadableStream internal algorithms to internal namespace r=evilpie
Attachment #9314057 - Attachment description: Bug 1809408 - Part 2: Move WritableStream internal algorithms to a separate header r=evilpie → Bug 1809408 - Part 2: Move WritableStream internal algorithms to internal namespace r=evilpie
Attachment #9314228 - Attachment description: Bug 1809408 - Part 3: Move TransformStream internal algorithms to a separate header r=evilpie → Bug 1809408 - Part 3: Move TransformStream internal algorithms to internal namespace r=evilpie

Patches are up, but TBH I have a mixed feeling with this approach because it now contaminates code with namespace streams_internal here and there, and needlessly still exposing the namespace in the header. I don't think it's any bad to have internal functions in one internal header as IMO what's more important is where the impls are. Do you like the new ones better?

(I don't care too much as long as we can hide internal things, though. The new approach has less diffs, so that's also a thing... 🤔)

Flags: needinfo?(evilpies)

I don't think it's terrible, the only thing that is annoying is the namespaces in the cpp files. Maybe we should actually consider moving some of these internal standalone functions to the corresponding classes. I did that a bit more while doing the WritableStream implementation and feels like better C++ to me.

Flags: needinfo?(evilpies)

I think it's a little better; we could put it in the C++ classes, though it's less clear on the restrictions that streams_internal (what do you think about re-naming that to streams::internal, which feels less like a stylistic outlier. )

(In reply to Matthew Gaudet (he/him) [:mgaudet] from comment #10)

I think it's a little better; we could put it in the C++ classes, though it's less clear on the restrictions that streams_internal (what do you think about re-naming that to streams::internal, which feels less like a stylistic outlier. )

Not sure I like it as dom::streams then would be a namespace whose sole member would be dom::streams::internal. That said, maybe it's better to rename it to _abstract at least, to match what the spec is saying.

(I'm copying the style of namespace bindings_detail)

Pushed by krosylight@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7bc810a8e68a Part 1: Move ReadableStream internal algorithms to internal namespace r=mgaudet https://hg.mozilla.org/integration/autoland/rev/38da95750e3f Part 2: Move WritableStream internal algorithms to internal namespace r=mgaudet https://hg.mozilla.org/integration/autoland/rev/7b9ab840dcf1 Part 3: Move TransformStream internal algorithms to internal namespace r=mgaudet
Pushed by krosylight@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b147225a5685 Part 1: Move ReadableStream internal algorithms to internal namespace r=mgaudet https://hg.mozilla.org/integration/autoland/rev/7ecf3a7d6acb Part 2: Move WritableStream internal algorithms to internal namespace r=mgaudet https://hg.mozilla.org/integration/autoland/rev/3b3901fa30fc Part 3: Move TransformStream internal algorithms to internal namespace r=mgaudet
Flags: needinfo?(krosylight)
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 111 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: