blob: 3ee9f43683ac2af39706681fab38f92c3e21e262 [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"
erikchen151b2f92015-06-16 20:20:5112#include "ipc/ipc_export.h"
sammc6ed3efb2016-11-23 03:17:3513#include "ipc/ipc_message_attachment.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.
sammc6ed3efb2016-11-23 03:17:3519class IPC_EXPORT HandleAttachmentWin : public MessageAttachment {
erikcheneece6c32015-07-07 22:13:1120 public:
erikchen17b34832015-12-04 21:20:1221 // This constructor makes a copy of |handle| and takes ownership of the
22 // result. Should only be called by the sender of a Chrome IPC message.
Wez51eaaad2017-08-09 05:51:3823 explicit HandleAttachmentWin(const HANDLE& handle);
erikchen17b34832015-12-04 21:20:1224
sammc57ed9f982016-03-10 06:28:3525 enum FromWire {
26 FROM_WIRE,
27 };
28 // This constructor takes ownership of |handle|. Should only be called by the
29 // receiver of a Chrome IPC message.
30 HandleAttachmentWin(const HANDLE& handle, FromWire from_wire);
31
Wez51eaaad2017-08-09 05:51:3832 // MessageAttachment interface.
sammc6ed3efb2016-11-23 03:17:3533 Type GetType() const override;
erikcheneece6c32015-07-07 22:13:1134
Wez51eaaad2017-08-09 05:51:3835 HANDLE Take() { return handle_.Take(); }
erikchen17b34832015-12-04 21:20:1236
erikchen151b2f92015-06-16 20:20:5137 private:
erikcheneece6c32015-07-07 22:13:1138 ~HandleAttachmentWin() override;
erikchen17b34832015-12-04 21:20:1239
Wez51eaaad2017-08-09 05:51:3840 base::win::ScopedHandle handle_;
erikchen151b2f92015-06-16 20:20:5141};
42
43} // namespace internal
44} // namespace IPC
45
46#endif // IPC_HANDLE_ATTACHMENT_WIN_H_