blob: 730afc829947b7874bf20b37889aa7bee21e164f [file] [log] [blame]
erikchen151b2f92015-06-16 20:20:511// Copyright 2015 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_WIN_H_
6#define IPC_HANDLE_ATTACHMENT_WIN_H_
7
erikcheneece6c32015-07-07 22:13:118#include <stdint.h>
9
Wez51eaaad2017-08-09 05:51:3810#include "base/win/scoped_handle.h"
erikchen959039d2015-08-11 21:17:4711#include "ipc/handle_win.h"
sammc6ed3efb2016-11-23 03:17:3512#include "ipc/ipc_message_attachment.h"
Ken Rockotfd907632017-09-14 04:23:4113#include "ipc/ipc_message_support_export.h"
erikchen151b2f92015-06-16 20:20:5114
15namespace IPC {
16namespace internal {
17
18// This class represents a Windows HANDLE attached to a Chrome IPC message.
Ken Rockotfd907632017-09-14 04:23:4119class IPC_MESSAGE_SUPPORT_EXPORT HandleAttachmentWin
20 : public MessageAttachment {
erikcheneece6c32015-07-07 22:13:1121 public:
erikchen17b34832015-12-04 21:20:1222 // 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.
Wez51eaaad2017-08-09 05:51:3824 explicit HandleAttachmentWin(const HANDLE& handle);
erikchen17b34832015-12-04 21:20:1225
sammc57ed9f982016-03-10 06:28:3526 enum FromWire {
27 FROM_WIRE,
28 };
29 // This constructor takes ownership of |handle|. Should only be called by the
30 // receiver of a Chrome IPC message.
31 HandleAttachmentWin(const HANDLE& handle, FromWire from_wire);
32
Wez51eaaad2017-08-09 05:51:3833 // MessageAttachment interface.
sammc6ed3efb2016-11-23 03:17:3534 Type GetType() const override;
erikcheneece6c32015-07-07 22:13:1135
Wez51eaaad2017-08-09 05:51:3836 HANDLE Take() { return handle_.Take(); }
erikchen17b34832015-12-04 21:20:1237
erikchen151b2f92015-06-16 20:20:5138 private:
erikcheneece6c32015-07-07 22:13:1139 ~HandleAttachmentWin() override;
erikchen17b34832015-12-04 21:20:1240
Wez51eaaad2017-08-09 05:51:3841 base::win::ScopedHandle handle_;
erikchen151b2f92015-06-16 20:20:5142};
43
44} // namespace internal
45} // namespace IPC
46
47#endif // IPC_HANDLE_ATTACHMENT_WIN_H_