| Index: mojo/ipc/message/ipc_message_builder.h
|
| diff --git a/mojo/ipc/message/ipc_message_builder.h b/mojo/ipc/message/ipc_message_builder.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f55deb549a38d1bdf0f255f526e3bf1f3ba20488
|
| --- /dev/null
|
| +++ b/mojo/ipc/message/ipc_message_builder.h
|
| @@ -0,0 +1,67 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef MOJO_IPC_MESSAGE_IPC_MESSAGE_BUIDER_H_
|
| +#define MOJO_IPC_MESSAGE_IPC_MESSAGE_BUIDER_H_
|
| +
|
| +#include <stdint.h>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "mojo/ipc/core/ipc_handle.h"
|
| +#include "mojo/ipc/message/ipc_message.h"
|
| +
|
| +namespace mojo {
|
| +
|
| +class IPCMessageBuilder {
|
| + public:
|
| + IPCMessageBuilder();
|
| + ~IPCMessageBuilder();
|
| +
|
| + bool Initialize(uint32_t type);
|
| +
|
| + bool Append(uint16_t name, bool value);
|
| +
|
| + bool Append(uint16_t name, int8_t value);
|
| + bool Append(uint16_t name, int16_t value);
|
| + bool Append(uint16_t name, int32_t value);
|
| + bool Append(uint16_t name, int64_t value);
|
| +
|
| + bool Append(uint16_t name, uint8_t value);
|
| + bool Append(uint16_t name, uint16_t value);
|
| + bool Append(uint16_t name, uint32_t value);
|
| + bool Append(uint16_t name, uint64_t value);
|
| +
|
| + bool Append(uint16_t name, float value);
|
| + bool Append(uint16_t name, double value);
|
| +
|
| + bool Append(uint16_t name, const std::string& value);
|
| + bool Append(uint16_t name, const void* bytes, size_t num_bytes);
|
| +
|
| + template <typename C>
|
| + bool Append(uint16_t name, const C& container) {
|
| + return Append(name, container.data(), container.size());
|
| + }
|
| +
|
| + bool Append(uint16_t name, Handle handle);
|
| + bool Append(uint16_t name, const IPCMessage& message);
|
| +
|
| + bool Finish(IPCMessage* message);
|
| +
|
| + private:
|
| + bool AppendU32(uint16_t name, IPCMessageFieldType field_type, uint32_t value);
|
| + bool AppendU64(uint16_t name, IPCMessageFieldType field_type, uint64_t value);
|
| + bool AppendVariableLength(uint16_t name, IPCMessageFieldType field_type,
|
| + const void* bytes, size_t num_bytes);
|
| +
|
| + bool AppendHeader(uint16_t name, IPCMessageFieldType field_type);
|
| + bool AppendRawBytes(const void* bytes, size_t num_bytes);
|
| +
|
| + std::vector<uint8_t> data_;
|
| + std::vector<Handle> handles_;
|
| +};
|
| +
|
| +} // namespace mojo
|
| +
|
| +#endif // MOJO_IPC_IPC_MESSAGE_BUILDER_H_
|
|
|