Currently, the DevTools protocol has a string data type, but not a data type for binary blobs. This means that clients of the protocol must base64 encode binary blobs into string fields of requests and decode base64 binary blobs from string fields of responses.
I'd like to introduce a new data type, "binary", which makes it so that the base64 encoding for the JSON wire format will be taken care of in the generated code / protocol layer, as opposed to within the clients of the protocol or the handlers for the protocol.
A WIP PR is available here:
https://chromium-review.googlesource.com/c/chromium/src/+/1244719
Roughly:
- The format (.pdl) files for the protocol specification need to support this new data type, binary.
- Code generation (templates and code generator need to be updated accordingly).
- In each of the code locations, the appropriate routine for base64 encoding / decoding needs to be invoked. This will get done by adding a couple of static encode / decode routines to StringUtil, which is already referenced by the generated code for string conversions, json parsing, etc.
- In a last step, once the support for the binary type exists, fields that are currently base64 encoded strings can be migrated. Thus far this works well for string fields that are always base64 encoded. The wire format doesn't change, the Javascript access doesn't change, but the C++ access will then just use std::vector<uint8_t> and let the protocol layer handle the encoding / decoding. This means that handlers are slightly shorter and no longer reference base64 libraries, and C++ client code needs to be updated.
Comment 1 by bugdroid1@chromium.org
, Oct 15