Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: ipc/attachment_broker_unprivileged_win.cc

Issue 1256993003: ipc: Create AttachmentBrokerPrivileged and AttachmentBrokerUnprivileged. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_ipc_message_feature
Patch Set: Rebase. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/attachment_broker_win.h" 5 #include "ipc/attachment_broker_unprivileged_win.h"
6 6
7 #include "base/process/process.h" 7 #include "base/process/process.h"
8 #include "ipc/attachment_broker_messages.h" 8 #include "ipc/attachment_broker_messages.h"
9 #include "ipc/brokerable_attachment.h" 9 #include "ipc/brokerable_attachment.h"
10 #include "ipc/handle_attachment_win.h" 10 #include "ipc/handle_attachment_win.h"
11 #include "ipc/ipc_sender.h" 11 #include "ipc/ipc_sender.h"
12 12
13 namespace IPC { 13 namespace IPC {
14 14
15 AttachmentBrokerWin::AttachmentBrokerWin() { 15 AttachmentBrokerUnprivilegedWin::AttachmentBrokerUnprivilegedWin() {}
16 }
17 16
18 AttachmentBrokerWin::~AttachmentBrokerWin() { 17 AttachmentBrokerUnprivilegedWin::~AttachmentBrokerUnprivilegedWin() {}
19 }
20 18
21 bool AttachmentBrokerWin::SendAttachmentToProcess( 19 bool AttachmentBrokerUnprivilegedWin::SendAttachmentToProcess(
22 const BrokerableAttachment* attachment, 20 const BrokerableAttachment* attachment,
23 base::ProcessId destination_process) { 21 base::ProcessId destination_process) {
24 switch (attachment->GetBrokerableType()) { 22 switch (attachment->GetBrokerableType()) {
25 case BrokerableAttachment::WIN_HANDLE: 23 case BrokerableAttachment::WIN_HANDLE:
26 const internal::HandleAttachmentWin* handle_attachment = 24 const internal::HandleAttachmentWin* handle_attachment =
27 static_cast<const internal::HandleAttachmentWin*>(attachment); 25 static_cast<const internal::HandleAttachmentWin*>(attachment);
28 internal::HandleAttachmentWin::WireFormat format = 26 internal::HandleAttachmentWin::WireFormat format =
29 handle_attachment->GetWireFormat(destination_process); 27 handle_attachment->GetWireFormat(destination_process);
30 return sender_->Send(new AttachmentBrokerMsg_DuplicateWinHandle(format)); 28 return get_sender()->Send(
29 new AttachmentBrokerMsg_DuplicateWinHandle(format));
31 } 30 }
32 return false; 31 return false;
33 } 32 }
34 33
35 bool AttachmentBrokerWin::OnMessageReceived(const Message& msg) { 34 bool AttachmentBrokerUnprivilegedWin::OnMessageReceived(const Message& msg) {
36 bool handled = true; 35 bool handled = true;
37 IPC_BEGIN_MESSAGE_MAP(AttachmentBrokerWin, msg) 36 IPC_BEGIN_MESSAGE_MAP(AttachmentBrokerUnprivilegedWin, msg)
38 IPC_MESSAGE_HANDLER(AttachmentBrokerMsg_WinHandleHasBeenDuplicated, 37 IPC_MESSAGE_HANDLER(AttachmentBrokerMsg_WinHandleHasBeenDuplicated,
39 OnWinHandleHasBeenDuplicated) 38 OnWinHandleHasBeenDuplicated)
40 IPC_MESSAGE_UNHANDLED(handled = false) 39 IPC_MESSAGE_UNHANDLED(handled = false)
41 IPC_END_MESSAGE_MAP() 40 IPC_END_MESSAGE_MAP()
42 return handled; 41 return handled;
43 } 42 }
44 43
45 void AttachmentBrokerWin::OnWinHandleHasBeenDuplicated( 44 void AttachmentBrokerUnprivilegedWin::OnWinHandleHasBeenDuplicated(
46 const IPC::internal::HandleAttachmentWin::WireFormat& wire_format) { 45 const IPC::internal::HandleAttachmentWin::WireFormat& wire_format) {
47 // The IPC message was intended for a different process. Ignore it. 46 // The IPC message was intended for a different process. Ignore it.
48 if (wire_format.destination_process != base::Process::Current().Pid()) 47 if (wire_format.destination_process != base::Process::Current().Pid())
49 return; 48 return;
50 49
51 scoped_refptr<BrokerableAttachment> attachment( 50 scoped_refptr<BrokerableAttachment> attachment(
52 new IPC::internal::HandleAttachmentWin(wire_format)); 51 new IPC::internal::HandleAttachmentWin(wire_format));
53 HandleReceivedAttachment(attachment); 52 HandleReceivedAttachment(attachment);
54 } 53 }
55 54
56 } // namespace IPC 55 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698