blob: 52c87d84e91dfba56d7f4f7e3b90436401395f35 [file] [log] [blame]
Scott Graham3eebff02017-06-30 01:07:101// Copyright 2017 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 IPC_HANDLE_FUCHSIA_H_
6#define IPC_HANDLE_FUCHSIA_H_
7
Scott Grahamfe0e9f462017-09-18 21:25:048#include <zircon/types.h>
Scott Graham3eebff02017-06-30 01:07:109
10#include <string>
11
Ken Rockotfd907632017-09-14 04:23:4112#include "ipc/ipc_message_support_export.h"
Scott Graham3eebff02017-06-30 01:07:1013#include "ipc/ipc_param_traits.h"
14
15namespace base {
16class Pickle;
17class PickleIterator;
18} // namespace base
19
20namespace IPC {
21
Ken Rockotfd907632017-09-14 04:23:4122class IPC_MESSAGE_SUPPORT_EXPORT HandleFuchsia {
Scott Graham3eebff02017-06-30 01:07:1023 public:
Scott Grahamfe0e9f462017-09-18 21:25:0424 // Default constructor makes an invalid zx_handle_t.
Scott Graham3eebff02017-06-30 01:07:1025 HandleFuchsia();
Scott Grahamfe0e9f462017-09-18 21:25:0426 explicit HandleFuchsia(const zx_handle_t& handle);
Scott Graham3eebff02017-06-30 01:07:1027
Scott Grahamfe0e9f462017-09-18 21:25:0428 zx_handle_t get_handle() const { return handle_; }
29 void set_handle(zx_handle_t handle) { handle_ = handle; }
Scott Graham3eebff02017-06-30 01:07:1030
31 private:
Scott Grahamfe0e9f462017-09-18 21:25:0432 zx_handle_t handle_;
Scott Graham3eebff02017-06-30 01:07:1033};
34
35template <>
Ken Rockotfd907632017-09-14 04:23:4136struct IPC_MESSAGE_SUPPORT_EXPORT ParamTraits<HandleFuchsia> {
Scott Graham3eebff02017-06-30 01:07:1037 typedef HandleFuchsia param_type;
38 static void Write(base::Pickle* m, const param_type& p);
39 static bool Read(const base::Pickle* m,
40 base::PickleIterator* iter,
41 param_type* p);
42 static void Log(const param_type& p, std::string* l);
43};
44
45} // namespace IPC
46
47#endif // IPC_HANDLE_FUCHSIA_H_