| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ipc/handle_attachment_win.h" | 5 #include "ipc/handle_attachment_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 namespace IPC { | 9 namespace IPC { |
| 10 namespace internal { | 10 namespace internal { |
| 11 | 11 |
| 12 HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle) | 12 HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle, |
| 13 : handle_(handle) { | 13 HandleWin::Permissions permissions) |
| 14 } | 14 : handle_(handle), permissions_(permissions) {} |
| 15 | 15 |
| 16 HandleAttachmentWin::HandleAttachmentWin(const WireFormat& wire_format) | 16 HandleAttachmentWin::HandleAttachmentWin(const WireFormat& wire_format) |
| 17 : BrokerableAttachment(wire_format.attachment_id, false), | 17 : BrokerableAttachment(wire_format.attachment_id, false), |
| 18 handle_(LongToHandle(wire_format.handle)) {} | 18 handle_(LongToHandle(wire_format.handle)), |
| 19 permissions_(wire_format.permissions) {} |
| 19 | 20 |
| 20 HandleAttachmentWin::HandleAttachmentWin( | 21 HandleAttachmentWin::HandleAttachmentWin( |
| 21 const BrokerableAttachment::AttachmentId& id) | 22 const BrokerableAttachment::AttachmentId& id) |
| 22 : BrokerableAttachment(id, true), handle_(INVALID_HANDLE_VALUE) {} | 23 : BrokerableAttachment(id, true), |
| 24 handle_(INVALID_HANDLE_VALUE), |
| 25 permissions_(HandleWin::INVALID) {} |
| 23 | 26 |
| 24 HandleAttachmentWin::~HandleAttachmentWin() { | 27 HandleAttachmentWin::~HandleAttachmentWin() { |
| 25 } | 28 } |
| 26 | 29 |
| 27 HandleAttachmentWin::BrokerableType HandleAttachmentWin::GetBrokerableType() | 30 HandleAttachmentWin::BrokerableType HandleAttachmentWin::GetBrokerableType() |
| 28 const { | 31 const { |
| 29 return WIN_HANDLE; | 32 return WIN_HANDLE; |
| 30 } | 33 } |
| 31 | 34 |
| 32 void HandleAttachmentWin::PopulateWithAttachment( | 35 void HandleAttachmentWin::PopulateWithAttachment( |
| 33 const BrokerableAttachment* attachment) { | 36 const BrokerableAttachment* attachment) { |
| 34 DCHECK(NeedsBrokering()); | 37 DCHECK(NeedsBrokering()); |
| 35 DCHECK(!attachment->NeedsBrokering()); | 38 DCHECK(!attachment->NeedsBrokering()); |
| 36 DCHECK(GetIdentifier() == attachment->GetIdentifier()); | 39 DCHECK(GetIdentifier() == attachment->GetIdentifier()); |
| 37 DCHECK_EQ(GetBrokerableType(), attachment->GetBrokerableType()); | 40 DCHECK_EQ(GetBrokerableType(), attachment->GetBrokerableType()); |
| 38 | 41 |
| 39 const HandleAttachmentWin* handle_attachment = | 42 const HandleAttachmentWin* handle_attachment = |
| 40 static_cast<const HandleAttachmentWin*>(attachment); | 43 static_cast<const HandleAttachmentWin*>(attachment); |
| 41 handle_ = handle_attachment->handle_; | 44 handle_ = handle_attachment->handle_; |
| 42 SetNeedsBrokering(false); | 45 SetNeedsBrokering(false); |
| 43 } | 46 } |
| 44 | 47 |
| 45 HandleAttachmentWin::WireFormat HandleAttachmentWin::GetWireFormat( | 48 HandleAttachmentWin::WireFormat HandleAttachmentWin::GetWireFormat( |
| 46 const base::ProcessId& destination) const { | 49 const base::ProcessId& destination) const { |
| 47 WireFormat format; | 50 WireFormat format; |
| 48 format.handle = HandleToLong(handle_); | 51 format.handle = HandleToLong(handle_); |
| 49 format.attachment_id = GetIdentifier(); | 52 format.attachment_id = GetIdentifier(); |
| 50 format.destination_process = destination; | 53 format.destination_process = destination; |
| 54 format.permissions = permissions_; |
| 51 return format; | 55 return format; |
| 52 } | 56 } |
| 53 | 57 |
| 54 } // namespace internal | 58 } // namespace internal |
| 55 } // namespace IPC | 59 } // namespace IPC |
| OLD | NEW |