Mojo C++ bindings: Serialize handles during message allocation
This changes C++ bindings to collect handles during the message sizing
phase of serialization so that a single Message object can be allocated
prior to full serialization.
This reduces the cost of sending messages with attached handles. It also
fulfills a necessary precondition for C++ bindings supporting lazy
serialization, as it would not be possible to re-allocate a message
object (as we do now) once a deferred serialization operation has been
coerced by Mojo internals.
In order to support this a few changes to serialization semantics are
applied here:
- Handle and interface accessors on StructTraits must return lvalue
references as they will be called twice: once during sizing and
once during serialization.
- SetUpContext and TearDownContext are always called even for nullable
custom types which report themselves as null
- IsNull supports being called with context so that e.g. traits can
move or otherwise store handle and interface types in the context
object at context creation, and these objects may in turn need to be
used for nullability testing.
BUG=725321
R=yzshen@chromium.org
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I7056651222641220301e9adfce5028dc3501884f
Reviewed-on: https://chromium-review.googlesource.com/546957
Reviewed-by: Yuzhu Shen <yzshen@chromium.org>
Commit-Queue: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#482773}
CrOS-Libchrome-Original-Commit: ecf30db27d06ac0c6c61e24e811acfba32e34977
15 files changed