[tracing] Invoke NACK MemoryDumpManager callback if tracing is disabled
[chromium-blink-merge.git] / ipc / attachment_broker_win.cc
blob89d193c7326bc13e73c774ae9e4346daa9192518
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/attachment_broker_win.h"
7 #include "base/process/process.h"
8 #include "ipc/attachment_broker_messages.h"
9 #include "ipc/brokerable_attachment.h"
10 #include "ipc/handle_attachment_win.h"
11 #include "ipc/ipc_sender.h"
13 namespace IPC {
15 AttachmentBrokerWin::AttachmentBrokerWin() {
18 AttachmentBrokerWin::~AttachmentBrokerWin() {
21 void AttachmentBrokerWin::OnReceiveDuplicatedHandle(
22 HANDLE,
23 BrokerableAttachment::AttachmentId id) {
24 // TODO(erikchen): Implement me. http://crbug.com/493414
27 bool AttachmentBrokerWin::SendAttachmentToProcess(
28 const BrokerableAttachment* attachment,
29 base::ProcessId destination_process) {
30 switch (attachment->GetBrokerableType()) {
31 case BrokerableAttachment::WIN_HANDLE:
32 const internal::HandleAttachmentWin* handle_attachment =
33 static_cast<const internal::HandleAttachmentWin*>(attachment);
34 internal::HandleAttachmentWin::WireFormat format =
35 handle_attachment->GetWireFormat(destination_process);
36 return sender_->Send(
37 new AttachmentBrokerMsg_DuplicateWinHandle(format));
39 return false;
42 bool AttachmentBrokerWin::GetAttachmentWithId(
43 BrokerableAttachment::AttachmentId id,
44 BrokerableAttachment* attachment) {
45 // TODO(erikchen): Implement me. http://crbug.com/493414
46 return false;
49 bool AttachmentBrokerWin::OnMessageReceived(const Message& msg) {
50 bool handled = true;
51 IPC_BEGIN_MESSAGE_MAP(AttachmentBrokerWin, msg)
52 IPC_MESSAGE_HANDLER(AttachmentBrokerMsg_WinHandleHasBeenDuplicated,
53 OnWinHandleHasBeenDuplicated)
54 IPC_MESSAGE_UNHANDLED(handled = false)
55 IPC_END_MESSAGE_MAP()
56 return handled;
59 void AttachmentBrokerWin::OnWinHandleHasBeenDuplicated(
60 const IPC::internal::HandleAttachmentWin::WireFormat& wire_format) {
61 // The IPC message was intended for a different process. Ignore it.
62 if (wire_format.destination_process != base::Process::Current().Pid())
63 return;
65 scoped_refptr<BrokerableAttachment> attachment(
66 new IPC::internal::HandleAttachmentWin(wire_format));
67 attachments_.push_back(attachment);
70 } // namespace IPC