- add sources.
[platform/framework/web/crosswalk.git] / src / mojo / public / bindings / lib / message_builder.h
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.
4
5 #ifndef MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_BUILDER_H_
6 #define MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_BUILDER_H_
7
8 #include <stdint.h>
9
10 #include "mojo/public/bindings/lib/buffer.h"
11
12 namespace mojo {
13 struct MessageData;
14
15 // Used to construct a MessageData object.
16 class MessageBuilder {
17  public:
18   MessageBuilder(uint32_t message_name, size_t payload_size);
19   ~MessageBuilder();
20
21   Buffer* buffer() { return &buf_; }
22
23   // Call Finish when done making allocations in |buffer()|. A heap-allocated
24   // MessageData object will be returned. When no longer needed, use |free()|
25   // to release the MessageData object's memory.
26   MessageData* Finish();
27
28  private:
29   FixedBuffer buf_;
30
31   MOJO_DISALLOW_COPY_AND_ASSIGN(MessageBuilder);
32 };
33
34 }  // namespace mojo
35
36 #endif  // MOJO_PUBLIC_BINDINGS_LIB_MESSAGE_BUILDER_H_