Before this change, calling buffered_amount only included what was buffered on top of what was already buffered in the SCTP socket. With the defaults, the SCTP socket can buffer up to 2MB of data (that is not put on the wire) before the additional external bufferering in SctpDataChannel will be used. The buffering that I am working on removing completely. Until it's removed completely, to avoid the issue reported in crbug.com/41221056, include the bytes buffered in the SCTP socket to what is returned when calling RTCDataChannel::buffered_amount. This means that when this value is zero, it can be safe to know that all bytes have been sent, but not necessarily acknowledged. And calling close will not discard any messages. This is a stopgap solution, but as functional as the proper solution that removes all additional buffering. Follow-up CLs will merely improve this solution. Bug: chromium:41221056 Change-Id: I06edd52188d3bf13a17827381a15a4730722685a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/342520 Commit-Queue: Victor Boivie <boivie@webrtc.org> Reviewed-by: Florent Castelli <orphis@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41898}
How to write code in the api/ directory
Mostly, just follow the regular style guide, but:
- Note that
api/code is not exempt from the “.hand.ccfiles come in pairs” rule, so if you declare something inapi/path/to/foo.h, it should be defined inapi/path/to/foo.cc. - Headers in
api/should, if possible, not#includeheaders outsideapi/. It’s not always possible to avoid this, but be aware that it adds to a small mountain of technical debt that we’re trying to shrink. .ccfiles inapi/, on the other hand, are free to#includeheaders outsideapi/.- Avoid structs in api, prefer classes.
The preferred way for api/ code to access non-api/ code is to call
it from a .cc file, so that users of our API headers won’t transitively
#include non-public headers.
For headers in api/ that need to refer to non-public types, forward
declarations are often a lesser evil than including non-public header files. The
usual rules still apply, though.
.cc files in api/ should preferably be kept reasonably small. If a
substantial implementation is needed, consider putting it with our non-public
code, and just call it from the api/ .cc file.
Avoid defining api with structs as it makes harder for the api to evolve. Your struct may gain invariant, or change how it represents data. Evolving struct from the api is particular challenging as it is designed to be used in other code bases and thus needs to be updated independetly from its usage. Class with accessors and setters makes such migration safer. See Google C++ style guide for more.
If you need to evolve existent struct in api, prefer first to convert it into a class.