New issue
Advanced search Search tips

Issue 831285 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

mojo::Dispatcher API is undocumented

Project Member Reported by mmenke@chromium.org, Apr 10 2018

Issue description

Most methods in mojo::Dispatcher have no documentation.  This should be fixed.

One example:

virtual MojoResult WriteData(const void* elements,
                             uint32_t* num_bytes,
                             MojoWriteDataFlags flags);

num_bytes is presumably both used as input and output (Should be documented).  Is this method guaranteed to write all data if MOJO_RESULT_OK is returned?
 

Comment 1 by roc...@chromium.org, Apr 10 2018

These methods are implementations of the public C API and their
specification is identical:
https://cs.chromium.org/chromium/src/mojo/public/c/system/

Comment 2 by roc...@chromium.org, Apr 10 2018

e.g. WriteData is an implementation of MojoWriteData:
https://cs.chromium.org/chromium/src/mojo/public/c/system/data_pipe.h?rcl=3fa650bf8b19336ebb3e6748296bb060df592442&l=171

There is no reason for anyone to use the internal Dispatcher APIs directly.

Comment 3 by mmenke@chromium.org, Apr 10 2018

Reviewing code which used DataPipeConsumerDispatcher/ DataPipeProducerDispatcher, that's not at all clear.

Comment 4 by roc...@chromium.org, Apr 10 2018

Again, nobody should be using these APIs directly. They are internal
details of Mojo. Can you point me at the CL?

Comment 5 by mmenke@chromium.org, Apr 10 2018

Sorry, I was digging into the top layers of Mojo code, since that information is not included in the ScopedDataPipeConsumerHandle docs, or the MojoWriteData docs...and ended at a location with no docs, which seemed rather surprising.

I've send a lot of code assume that all data was written, and wasn't sure if was correct or not.

Comment 6 by roc...@chromium.org, Apr 10 2018

Hmm. https://cs.chromium.org/chromium/src/mojo/public/c/system/data_pipe.h?rcl=6fcc593c5778cabefd4ea1eeaaacedb14dc8eba0&l=151 documents that on success, *num_bytes will contain the number of bytes actually written.

I suppose we should be more explicit in pointing out that this can be less than the input value.

Comment 7 by mmenke@chromium.org, Apr 10 2018

Hrm...  In that case, there seems to be a *lot* of broken consumer code.

https://cs.chromium.org/chromium/src/chrome/browser/extensions/chrome_url_request_util.cc?type=cs&l=230
https://cs.chromium.org/chromium/src/chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.cc?type=cs&l=47
https://cs.chromium.org/chromium/src/content/browser/devtools/devtools_url_loader_interceptor.cc?type=cs&l=904

Those are literally the first 3 non-test hits.  The third is at least kind enough to DCHECK on error, or if not all data is written, I guess?

Comment 8 by roc...@chromium.org, Apr 10 2018

It is safe to assume that if you created the pipe with a certain capacity,
and the pipe is still empty, a WriteData call which does not exceed that
capacity will always succeed. This is indeed not called out explicitly in
the documentation though.

Comment 9 by roc...@chromium.org, Apr 10 2018

Will always succeed *and all bytes will be written*, that is.
Cc: -roc...@chromium.org rockot@google.com

Sign in to add a comment