Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: mojo/ipc/message/ipc_message_builder.h

Issue 23629032: mojo: MessageBuilder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add support for a string field type. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 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_IPC_MESSAGE_IPC_MESSAGE_BUIDER_H_
6 #define MOJO_IPC_MESSAGE_IPC_MESSAGE_BUIDER_H_
7
8 #include <stdint.h>
9 #include <string>
10 #include <vector>
11
12 #include "mojo/ipc/core/ipc_handle.h"
13 #include "mojo/ipc/message/ipc_message.h"
14
15 namespace mojo {
16
17 class IPCMessageBuilder {
18 public:
19 IPCMessageBuilder();
20 ~IPCMessageBuilder();
21
22 bool Initialize(uint32_t type);
23
24 bool Append(uint16_t name, bool value);
25
26 bool Append(uint16_t name, int8_t value);
27 bool Append(uint16_t name, int16_t value);
28 bool Append(uint16_t name, int32_t value);
29 bool Append(uint16_t name, int64_t value);
30
31 bool Append(uint16_t name, uint8_t value);
32 bool Append(uint16_t name, uint16_t value);
33 bool Append(uint16_t name, uint32_t value);
34 bool Append(uint16_t name, uint64_t value);
35
36 bool Append(uint16_t name, float value);
37 bool Append(uint16_t name, double value);
38
39 bool Append(uint16_t name, const std::string& value);
40 bool Append(uint16_t name, const void* bytes, size_t num_bytes);
41
42 template <typename C>
43 bool Append(uint16_t name, const C& container) {
44 return Append(name, container.data(), container.size());
45 }
46
47 bool Append(uint16_t name, Handle handle);
48 bool Append(uint16_t name, const IPCMessage& message);
49
50 bool Finish(IPCMessage* message);
51
52 private:
53 bool AppendU32(uint16_t name, IPCMessageFieldType field_type, uint32_t value);
54 bool AppendU64(uint16_t name, IPCMessageFieldType field_type, uint64_t value);
55 bool AppendVariableLength(uint16_t name, IPCMessageFieldType field_type,
56 const void* bytes, size_t num_bytes);
57
58 bool AppendHeader(uint16_t name, IPCMessageFieldType field_type);
59 bool AppendRawBytes(const void* bytes, size_t num_bytes);
60
61 std::vector<uint8_t> data_;
62 std::vector<Handle> handles_;
63 };
64
65 } // namespace mojo
66
67 #endif // MOJO_IPC_IPC_MESSAGE_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698