blob: 2ff6b53927d2c341a5e38e292343c1d5ab1585f3 [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
8#include <magenta/types.h>
9
10#include <string>
11
12#include "ipc/ipc_export.h"
13#include "ipc/ipc_param_traits.h"
14
15namespace base {
16class Pickle;
17class PickleIterator;
18} // namespace base
19
20namespace IPC {
21
22class IPC_EXPORT HandleFuchsia {
23 public:
24 enum Permissions {
25 // A placeholder value to be used by the receiving IPC channel, since the
26 // permissions information is only used by the broker process.
27 INVALID,
28 // The new mx_handle_t will have the same permissions as the old
29 // mx_handle_t.
30 DUPLICATE,
31 // The new mx_handle_t will have file read and write permissions.
32 FILE_READ_WRITE,
33 MAX_PERMISSIONS = FILE_READ_WRITE
34 };
35
36 // Default constructor makes an invalid mx_handle_t.
37 HandleFuchsia();
38 HandleFuchsia(const mx_handle_t& handle, Permissions permissions);
39
40 mx_handle_t get_handle() const { return handle_; }
41 void set_handle(mx_handle_t handle) { handle_ = handle; }
42 Permissions get_permissions() const { return permissions_; }
43
44 private:
45 mx_handle_t handle_;
46 Permissions permissions_;
47};
48
49template <>
50struct IPC_EXPORT ParamTraits<HandleFuchsia> {
51 typedef HandleFuchsia param_type;
52 static void Write(base::Pickle* m, const param_type& p);
53 static bool Read(const base::Pickle* m,
54 base::PickleIterator* iter,
55 param_type* p);
56 static void Log(const param_type& p, std::string* l);
57};
58
59} // namespace IPC
60
61#endif // IPC_HANDLE_FUCHSIA_H_