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 #include "ipc/handle_attachment_win.h"
12 HandleAttachmentWin::HandleAttachmentWin(const HANDLE
& handle
)
16 HandleAttachmentWin::HandleAttachmentWin(const WireFormat
& wire_format
)
17 : BrokerableAttachment(wire_format
.attachment_id
, false),
18 handle_(LongToHandle(wire_format
.handle
)) {}
20 HandleAttachmentWin::HandleAttachmentWin(
21 const BrokerableAttachment::AttachmentId
& id
)
22 : BrokerableAttachment(id
, true), handle_(INVALID_HANDLE_VALUE
) {}
24 HandleAttachmentWin::~HandleAttachmentWin() {
27 HandleAttachmentWin::BrokerableType
HandleAttachmentWin::GetBrokerableType()
32 void HandleAttachmentWin::PopulateWithAttachment(
33 const BrokerableAttachment
* attachment
) {
34 DCHECK(NeedsBrokering());
35 DCHECK(!attachment
->NeedsBrokering());
36 DCHECK(GetIdentifier() == attachment
->GetIdentifier());
37 DCHECK_EQ(GetBrokerableType(), attachment
->GetBrokerableType());
39 const HandleAttachmentWin
* handle_attachment
=
40 static_cast<const HandleAttachmentWin
*>(attachment
);
41 handle_
= handle_attachment
->handle_
;
42 SetNeedsBrokering(false);
45 HandleAttachmentWin::WireFormat
HandleAttachmentWin::GetWireFormat(
46 const base::ProcessId
& destination
) const {
48 format
.handle
= HandleToLong(handle_
);
49 format
.attachment_id
= GetIdentifier();
50 format
.destination_process
= destination
;
54 } // namespace internal