Add ICU message format support
[chromium-blink-merge.git] / ipc / handle_attachment_win.h
blobe164cc08d89cca8d2042c88bc7456bd770473306
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_
8 #include <stdint.h>
10 #include "base/process/process_handle.h"
11 #include "ipc/brokerable_attachment.h"
12 #include "ipc/ipc_export.h"
14 namespace IPC {
15 namespace internal {
17 // This class represents a Windows HANDLE attached to a Chrome IPC message.
18 class IPC_EXPORT HandleAttachmentWin : public BrokerableAttachment {
19 public:
20 // The wire format for this handle.
21 struct IPC_EXPORT WireFormat {
22 // The HANDLE that is intended for duplication, or the HANDLE that has been
23 // duplicated, depending on context.
24 // The type is int32_t instead of HANDLE because HANDLE gets typedefed to
25 // void*, whose size varies between 32 and 64-bit processes. Using a
26 // int32_t means that 64-bit processes will need to perform both up-casting
27 // and down-casting. This is performed using the appropriate Windows apis.
28 // A value of 0 is equivalent to an invalid handle.
29 int32_t handle;
30 // The id of the destination process that the handle is duplicated into.
31 base::ProcessId destination_process;
32 AttachmentId attachment_id;
35 explicit HandleAttachmentWin(const HANDLE& handle);
36 explicit HandleAttachmentWin(const WireFormat& wire_format);
37 explicit HandleAttachmentWin(const BrokerableAttachment::AttachmentId& id);
39 BrokerableType GetBrokerableType() const override;
40 void PopulateWithAttachment(const BrokerableAttachment* attachment) override;
42 // Returns the wire format of this attachment.
43 WireFormat GetWireFormat(const base::ProcessId& destination) const;
45 HANDLE get_handle() const { return handle_; }
47 private:
48 ~HandleAttachmentWin() override;
49 HANDLE handle_;
52 } // namespace internal
53 } // namespace IPC
55 #endif // IPC_HANDLE_ATTACHMENT_WIN_H_