Remove unnecessary fields from ipc::HandleAttachmentWin.
When we migrated to IPC-over-Mojo, we introduced a sender-process handle
duplication, to adapt between IPC's handle copying semantics and Mojo's
handle-passing semantics. This duplication removes the need to track
whether the HandleAttachmentWin owns the HANDLE.
Bug:
Change-Id: I3619c4034793365096416b65f9d8ac76fd2d5b99
Reviewed-on: https://chromium-review.googlesource.com/602829
Reviewed-by: Ken Rockot <[email protected]>
Commit-Queue: Wez <[email protected]>
Cr-Commit-Position: refs/heads/master@{#492840}
diff --git a/ipc/handle_attachment_win.cc b/ipc/handle_attachment_win.cc
index 9249a5a..6f6fc34 100644
--- a/ipc/handle_attachment_win.cc
+++ b/ipc/handle_attachment_win.cc
@@ -9,29 +9,21 @@
namespace IPC {
namespace internal {
-HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle,
- HandleWin::Permissions permissions)
- : handle_(INVALID_HANDLE_VALUE),
- permissions_(HandleWin::INVALID),
- owns_handle_(true) {
+HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle) {
HANDLE duplicated_handle;
BOOL result =
::DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(),
&duplicated_handle, 0, FALSE, DUPLICATE_SAME_ACCESS);
if (result) {
- handle_ = duplicated_handle;
- permissions_ = permissions;
+ handle_.Set(duplicated_handle);
}
}
HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle,
FromWire from_wire)
- : handle_(handle), permissions_(HandleWin::INVALID), owns_handle_(true) {}
+ : handle_(handle) {}
-HandleAttachmentWin::~HandleAttachmentWin() {
- if (handle_ != INVALID_HANDLE_VALUE && owns_handle_)
- ::CloseHandle(handle_);
-}
+HandleAttachmentWin::~HandleAttachmentWin() {}
MessageAttachment::Type HandleAttachmentWin::GetType() const {
return Type::WIN_HANDLE;