1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MOJO_PUBLIC_BINDINGS_MESSAGE_H_
6 #define MOJO_PUBLIC_BINDINGS_MESSAGE_H_
10 #include "mojo/public/system/core_cpp.h"
16 struct MessageHeader {
20 MOJO_COMPILE_ASSERT(sizeof(MessageHeader) == 8, bad_sizeof_MessageHeader);
26 MOJO_COMPILE_ASSERT(sizeof(MessageData) == 9, bad_sizeof_MessageData);
30 // Message is a holder for the data and handles to be sent over a MessagePipe.
31 // Message owns its data and handles, but a consumer of Message is free to
32 // manipulate the data and handles members.
38 void Swap(Message* other);
40 MessageData* data; // Heap-allocated using malloc.
41 // TODO(davemoore): Turn these into ScopedHandles and fix bindings generation.
42 std::vector<Handle> handles;
45 MOJO_DISALLOW_COPY_AND_ASSIGN(Message);
48 class MessageReceiver {
50 // The receiver may mutate the given message or take ownership of its
51 // |message->data| member by setting it to NULL. Returns true if the message
52 // was accepted and false otherwise, indicating that the message was invalid
54 virtual bool Accept(Message* message) = 0;
59 #endif // MOJO_PUBLIC_BINDINGS_MESSAGE_H_