network/sctp: Refactor DataChannel
Categories
(Core :: WebRTC, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox121 | --- | fixed |
People
(Reporter: boivie, Assigned: boivie)
Details
Attachments
(4 files, 1 obsolete file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36
Steps to reproduce:
network/sctp/datachannel would benefit from some refactoring wrt code style.
| Assignee | ||
Comment 1•2 years ago
|
||
So I created this bug to have as a reference for some refactoring that I think would be good to do in the data channel files. If you think this is fine, please assign it to me. I'm also on chat - thanks
Comment 2•2 years ago
|
||
Can you give some examples of the types of changes you're suggesting? In changeset: 448947:6f3709b38781 (Nov 30 2018) we reformatted the existing code according to our style guidelines (based on google style), and we have automatic reformatting to current style guidelines typically done in our workflow/tools.
| Assignee | ||
Comment 3•2 years ago
|
||
Some ideas that come to mind:
- Using type safe enum class instead of enum (https://abseil.io/tips/86)
- Use of const (https://abseil.io/tips/109)
- Replacing typedefs with using (from style guide)
... but honestly, I hope to fix a few bugs in this domain and I generally prefer to refactor the code a bit as I learn it.
Comment 4•2 years ago
|
||
Those sound like reasonable changes, though certainly not required. We'd accept/review patches doing that, thanks!
Updated•2 years ago
|
| Assignee | ||
Comment 5•2 years ago
|
||
There are two states; One for the entire data channel connection, which is
an internal property (now called just "state") indicating the state of the
SCTP connection setup.
The other state is the per-data channel state, indicating if it's opening, open
or closing. This is called "readyState" in the RTCDataChannel API, and that
(somewhat odd) name is kept in the underlying C++ representation.
This commit changes from using a C style enum to a C++ enum class which adds
type safety. Some minor code style cleanup was done as well as code was
refactored.
| Assignee | ||
Comment 6•2 years ago
|
||
This commit changes from using a C style enum to a C++ enum class which adds
type safety. This is just a refactoring commit with no changes in behavior.
Depends on D192066
| Assignee | ||
Comment 7•2 years ago
|
||
This commit changes from using a C style enum to a C++ enum class which adds
type safety. This is just a refactoring commit with no changes in behavior.
Depends on D192068
| Assignee | ||
Comment 8•2 years ago
|
||
This commit changes from using a C style enum to a C++ enum class which adds
type safety. This is just a refactoring commit with no changes in behavior.
This avoids an (potentially unsafe) untyped downcast from PeerConnection.idl
types to what's used in DataChannel.h.
Depends on D192069
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Comment 9•2 years ago
|
||
Comment 10•2 years ago
|
||
I see one DataChannel-related failure in there, but I think this is probably pre-existing. Retriggering and making a baseline push to check:
https://treeherder.mozilla.org/jobs?repo=try&revision=7ffcaa81ce1de277d488952df34ee513e0d0644f
| Assignee | ||
Comment 11•2 years ago
|
||
Including, but not limited to:
- Following the style guide wrt declaration order.
- Use const whenever it makes sense.
- Move members to be private where possible (e.g. mLock was previously public,
which it didn't have to be). - Fix most compiler warnings.
These kind of changes are rarely complete - there is always something that was
missed. It's still a step in the right direction.
Updated•2 years ago
|
Comment 12•2 years ago
|
||
Comment on attachment 9361586 [details]
Bug 1859759: Misc c++ style fixes
Revision D192563 was moved to bug 1862740. Setting attachment 9361586 [details] to obsolete.
Comment 13•2 years ago
|
||
Comment 14•2 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/77c6af541a02
https://hg.mozilla.org/mozilla-central/rev/1516f20cdd30
https://hg.mozilla.org/mozilla-central/rev/8f33fd78d7ac
https://hg.mozilla.org/mozilla-central/rev/0d91ef074019
Description
•