Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 1 | // 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 Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 8 | #include <zircon/types.h> |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 9 | |
| 10 | #include <string> |
| 11 | |
Ken Rockot | fd90763 | 2017-09-14 04:23:41 | [diff] [blame] | 12 | #include "ipc/ipc_message_support_export.h" |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 13 | #include "ipc/ipc_param_traits.h" |
| 14 | |
| 15 | namespace base { |
| 16 | class Pickle; |
| 17 | class PickleIterator; |
| 18 | } // namespace base |
| 19 | |
| 20 | namespace IPC { |
| 21 | |
Ken Rockot | fd90763 | 2017-09-14 04:23:41 | [diff] [blame] | 22 | class IPC_MESSAGE_SUPPORT_EXPORT HandleFuchsia { |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 23 | public: |
Scott Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 24 | // Default constructor makes an invalid zx_handle_t. |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 25 | HandleFuchsia(); |
Scott Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 26 | explicit HandleFuchsia(const zx_handle_t& handle); |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 27 | |
Scott Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 28 | zx_handle_t get_handle() const { return handle_; } |
| 29 | void set_handle(zx_handle_t handle) { handle_ = handle; } |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 30 | |
| 31 | private: |
Scott Graham | fe0e9f46 | 2017-09-18 21:25:04 | [diff] [blame] | 32 | zx_handle_t handle_; |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | template <> |
Ken Rockot | fd90763 | 2017-09-14 04:23:41 | [diff] [blame] | 36 | struct IPC_MESSAGE_SUPPORT_EXPORT ParamTraits<HandleFuchsia> { |
Scott Graham | 3eebff0 | 2017-06-30 01:07:10 | [diff] [blame] | 37 | 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_ |