mojo::Dispatcher API is undocumented |
||
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?
,
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.
,
Apr 10 2018
Reviewing code which used DataPipeConsumerDispatcher/ DataPipeProducerDispatcher, that's not at all clear.
,
Apr 10 2018
Again, nobody should be using these APIs directly. They are internal details of Mojo. Can you point me at the CL?
,
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.
,
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.
,
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?
,
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.
,
Apr 10 2018
Will always succeed *and all bytes will be written*, that is.
,
Oct 17
|
||
►
Sign in to add a comment |
||
Comment 1 by roc...@chromium.org
, Apr 10 2018