1 // 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.
5 #ifndef IPC_HANDLE_ATTACHMENT_WIN_H_
6 #define IPC_HANDLE_ATTACHMENT_WIN_H_
10 #include "base/process/process_handle.h"
11 #include "ipc/brokerable_attachment.h"
12 #include "ipc/handle_win.h"
13 #include "ipc/ipc_export.h"
18 // This class represents a Windows HANDLE attached to a Chrome IPC message.
19 class IPC_EXPORT HandleAttachmentWin
: public BrokerableAttachment
{
21 // The wire format for this handle.
22 struct IPC_EXPORT WireFormat
{
23 // The HANDLE that is intended for duplication, or the HANDLE that has been
24 // duplicated, depending on context.
25 // The type is int32_t instead of HANDLE because HANDLE gets typedefed to
26 // void*, whose size varies between 32 and 64-bit processes. Using a
27 // int32_t means that 64-bit processes will need to perform both up-casting
28 // and down-casting. This is performed using the appropriate Windows apis.
29 // A value of 0 is equivalent to an invalid handle.
31 // The id of the destination process that the handle is duplicated into.
32 base::ProcessId destination_process
;
33 // The permissions to use when duplicating the handle.
34 HandleWin::Permissions permissions
;
35 AttachmentId attachment_id
;
38 HandleAttachmentWin(const HANDLE
& handle
, HandleWin::Permissions permissions
);
39 explicit HandleAttachmentWin(const WireFormat
& wire_format
);
40 explicit HandleAttachmentWin(const BrokerableAttachment::AttachmentId
& id
);
42 BrokerableType
GetBrokerableType() const override
;
44 // Returns the wire format of this attachment.
45 WireFormat
GetWireFormat(const base::ProcessId
& destination
) const;
47 HANDLE
get_handle() const { return handle_
; }
50 ~HandleAttachmentWin() override
;
52 HandleWin::Permissions permissions_
;
55 } // namespace internal
58 #endif // IPC_HANDLE_ATTACHMENT_WIN_H_