1 // Copyright 2015 The Chromium Authors 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 8 #include <stdint.h> 9 10 #include "base/win/scoped_handle.h" 11 #include "ipc/handle_win.h" 12 #include "ipc/ipc_message_attachment.h" 13 #include "ipc/ipc_message_support_export.h" 14 15 namespace IPC { 16 namespace internal { 17 18 // This class represents a Windows HANDLE attached to a Chrome IPC message. 19 class IPC_MESSAGE_SUPPORT_EXPORT HandleAttachmentWin 20 : public MessageAttachment { 21 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. 24 explicit HandleAttachmentWin(const HANDLE& handle); 25 26 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 33 // MessageAttachment interface. 34 Type GetType() const override; 35 Take()36 HANDLE Take() { return handle_.Take(); } 37 38 private: 39 ~HandleAttachmentWin() override; 40 41 base::win::ScopedHandle handle_; 42 }; 43 44 } // namespace internal 45 } // namespace IPC 46 47 #endif // IPC_HANDLE_ATTACHMENT_WIN_H_ 48