1 // Copyright 2013 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_CPP_BINDINGS_LIB_MESSAGE_BUILDER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_BUILDER_H_
10 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h"
11 #include "mojo/public/cpp/bindings/lib/message_internal.h"
18 class MessageBuilder
{
20 MessageBuilder(uint32_t name
, size_t payload_size
);
23 Buffer
* buffer() { return &buf_
; }
25 // Call Finish when done making allocations in |buffer()|. Upon return,
26 // |message| will contain the message data, and |buffer()| will no longer be
27 // valid to reference.
28 void Finish(Message
* message
);
31 explicit MessageBuilder(size_t size
);
34 MOJO_DISALLOW_COPY_AND_ASSIGN(MessageBuilder
);
37 class MessageWithRequestIDBuilder
: public MessageBuilder
{
39 MessageWithRequestIDBuilder(uint32_t name
, size_t payload_size
,
40 uint32_t flags
, uint64_t request_id
);
43 class RequestMessageBuilder
: public MessageWithRequestIDBuilder
{
45 RequestMessageBuilder(uint32_t name
, size_t payload_size
)
46 : MessageWithRequestIDBuilder(name
, payload_size
, kMessageExpectsResponse
,
51 class ResponseMessageBuilder
: public MessageWithRequestIDBuilder
{
53 ResponseMessageBuilder(uint32_t name
, size_t payload_size
,
55 : MessageWithRequestIDBuilder(name
, payload_size
, kMessageIsResponse
,
60 } // namespace internal
63 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MESSAGE_BUILDER_H_