Bug 1713148 - Part 1: Expose UserMessageEvent to WillBeRoutedExternally, r=handyman

This is used because, unlike in Mojo, we cannot get from the IPC::Message
object to its enclosing UserMessageEvent object to attach more ports to it, and
this extra parameter makes that easy to do.

Differential Revision: https://phabricator.services.mozilla.com/D116668
This commit is contained in:
Nika Layzell 2021-06-21 21:53:12 +00:00
parent 96dd5437ae
commit 0bfe790a38
3 changed files with 9 additions and 3 deletions

View File

@ -171,7 +171,7 @@ void UserMessageEvent::ReservePorts(size_t num_ports) {
bool UserMessageEvent::NotifyWillBeRoutedExternally() {
DCHECK(message_);
return message_->WillBeRoutedExternally();
return message_->WillBeRoutedExternally(*this);
}
// static

View File

@ -12,7 +12,7 @@ UserMessage::UserMessage(const TypeInfo* type_info) : type_info_(type_info) {}
UserMessage::~UserMessage() = default;
bool UserMessage::WillBeRoutedExternally() { return true; }
bool UserMessage::WillBeRoutedExternally(UserMessageEvent&) { return true; }
size_t UserMessage::GetSizeIfSerialized() const { return 0; }

View File

@ -11,6 +11,8 @@ namespace mojo {
namespace core {
namespace ports {
class UserMessageEvent;
// Base type to use for any embedder-defined user message implementation. This
// class is intentionally empty.
//
@ -36,10 +38,14 @@ class UserMessage {
// Invoked immediately before the system asks the embedder to forward this
// message to an external node.
//
// The UserMessageEvent is passed in to allow ports and other such values to
// be attached to the message before it is sent externally, in case late
// serialization is performed.
//
// Returns |true| if the message is OK to route externally, or |false|
// otherwise. Returning |false| implies an unrecoverable condition, and the
// message event will be destroyed without further routing.
virtual bool WillBeRoutedExternally();
virtual bool WillBeRoutedExternally(UserMessageEvent& event);
// Returns the size in bytes of this message iff it's serialized. Zero
// otherwise.