Revert of Add logging to profile downloader to diagnose Android FR issue. (patchset...
[chromium-blink-merge.git] / ipc / handle_attachment_win.cc
blob50e3e6dab24310c5bba54d5f44cfa42cb436630e
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"
7 #include <windows.h>
9 namespace IPC {
10 namespace internal {
12 HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle,
13 HandleWin::Permissions permissions)
14 : handle_(handle), permissions_(permissions) {}
16 HandleAttachmentWin::HandleAttachmentWin(const WireFormat& wire_format)
17 : BrokerableAttachment(wire_format.attachment_id, false),
18 handle_(LongToHandle(wire_format.handle)),
19 permissions_(wire_format.permissions) {}
21 HandleAttachmentWin::HandleAttachmentWin(
22 const BrokerableAttachment::AttachmentId& id)
23 : BrokerableAttachment(id, true),
24 handle_(INVALID_HANDLE_VALUE),
25 permissions_(HandleWin::INVALID) {}
27 HandleAttachmentWin::~HandleAttachmentWin() {
30 HandleAttachmentWin::BrokerableType HandleAttachmentWin::GetBrokerableType()
31 const {
32 return WIN_HANDLE;
35 void HandleAttachmentWin::PopulateWithAttachment(
36 const BrokerableAttachment* attachment) {
37 DCHECK(NeedsBrokering());
38 DCHECK(!attachment->NeedsBrokering());
39 DCHECK(GetIdentifier() == attachment->GetIdentifier());
40 DCHECK_EQ(GetBrokerableType(), attachment->GetBrokerableType());
42 const HandleAttachmentWin* handle_attachment =
43 static_cast<const HandleAttachmentWin*>(attachment);
44 handle_ = handle_attachment->handle_;
45 SetNeedsBrokering(false);
48 HandleAttachmentWin::WireFormat HandleAttachmentWin::GetWireFormat(
49 const base::ProcessId& destination) const {
50 WireFormat format;
51 format.handle = HandleToLong(handle_);
52 format.attachment_id = GetIdentifier();
53 format.destination_process = destination;
54 format.permissions = permissions_;
55 return format;
58 } // namespace internal
59 } // namespace IPC