handle_attachment_win.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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.
  4. #ifndef IPC_HANDLE_ATTACHMENT_WIN_H_
  5. #define IPC_HANDLE_ATTACHMENT_WIN_H_
  6. #include <stdint.h>
  7. #include "base/win/scoped_handle.h"
  8. #include "ipc/handle_win.h"
  9. #include "ipc/ipc_message_attachment.h"
  10. #include "ipc/ipc_message_support_export.h"
  11. namespace IPC {
  12. namespace internal {
  13. // This class represents a Windows HANDLE attached to a Chrome IPC message.
  14. class IPC_MESSAGE_SUPPORT_EXPORT HandleAttachmentWin
  15. : public MessageAttachment {
  16. public:
  17. // This constructor makes a copy of |handle| and takes ownership of the
  18. // result. Should only be called by the sender of a Chrome IPC message.
  19. explicit HandleAttachmentWin(const HANDLE& handle);
  20. enum FromWire {
  21. FROM_WIRE,
  22. };
  23. // This constructor takes ownership of |handle|. Should only be called by the
  24. // receiver of a Chrome IPC message.
  25. HandleAttachmentWin(const HANDLE& handle, FromWire from_wire);
  26. // MessageAttachment interface.
  27. Type GetType() const override;
  28. HANDLE Take() { return handle_.Take(); }
  29. private:
  30. ~HandleAttachmentWin() override;
  31. base::win::ScopedHandle handle_;
  32. };
  33. } // namespace internal
  34. } // namespace IPC
  35. #endif // IPC_HANDLE_ATTACHMENT_WIN_H_