blob: 61db9065cc6626ed8510bf4790395d097ad436df [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_ATTACHMENT_FUCHSIA_H_
6#define IPC_HANDLE_ATTACHMENT_FUCHSIA_H_
7
8#include <stdint.h>
9
Scott Grahamfe0e9f462017-09-18 21:25:0410#include "base/fuchsia/scoped_zx_handle.h"
Scott Graham3eebff02017-06-30 01:07:1011#include "ipc/handle_fuchsia.h"
Scott Graham3eebff02017-06-30 01:07:1012#include "ipc/ipc_message_attachment.h"
Ken Rockotfd907632017-09-14 04:23:4113#include "ipc/ipc_message_support_export.h"
Scott Graham3eebff02017-06-30 01:07:1014
15namespace IPC {
16namespace internal {
17
Scott Grahamfe0e9f462017-09-18 21:25:0418// This class represents a Fuchsia zx_handle_t attached to a Chrome IPC message.
Ken Rockotfd907632017-09-14 04:23:4119class IPC_MESSAGE_SUPPORT_EXPORT HandleAttachmentFuchsia
20 : public MessageAttachment {
Scott Graham3eebff02017-06-30 01:07:1021 public:
22 // This constructor makes a copy of |handle| and takes ownership of the
23 // result. Should only be called by the sender of a Chrome IPC message.
Scott Grahamfe0e9f462017-09-18 21:25:0424 explicit HandleAttachmentFuchsia(const zx_handle_t& handle);
Scott Graham3eebff02017-06-30 01:07:1025
Scott Graham3eebff02017-06-30 01:07:1026 // This constructor takes ownership of |handle|. Should only be called by the
27 // receiver of a Chrome IPC message.
Scott Grahamfe0e9f462017-09-18 21:25:0428 explicit HandleAttachmentFuchsia(base::ScopedZxHandle handle);
Scott Graham3eebff02017-06-30 01:07:1029
30 Type GetType() const override;
31
Scott Grahamfe0e9f462017-09-18 21:25:0432 zx_handle_t Take() { return handle_.release(); }
Scott Graham3eebff02017-06-30 01:07:1033
34 private:
35 ~HandleAttachmentFuchsia() override;
Scott Graham3eebff02017-06-30 01:07:1036
Scott Grahamfe0e9f462017-09-18 21:25:0437 base::ScopedZxHandle handle_;
Scott Graham3eebff02017-06-30 01:07:1038};
39
40} // namespace internal
41} // namespace IPC
42
43#endif // IPC_HANDLE_ATTACHMENT_FUCHSIA_H_