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/mach_port_mac.h" | 5 #include "ipc/mach_port_mac.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "ipc/mach_port_attachment_mac.h" | 10 #include "ipc/mach_port_attachment_mac.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // static | 28 // static |
29 bool ParamTraits<MachPortMac>::Read(const base::Pickle* m, | 29 bool ParamTraits<MachPortMac>::Read(const base::Pickle* m, |
30 base::PickleIterator* iter, | 30 base::PickleIterator* iter, |
31 param_type* r) { | 31 param_type* r) { |
32 scoped_refptr<base::Pickle::Attachment> base_attachment; | 32 scoped_refptr<base::Pickle::Attachment> base_attachment; |
33 if (!m->ReadAttachment(iter, &base_attachment)) | 33 if (!m->ReadAttachment(iter, &base_attachment)) |
34 return false; | 34 return false; |
35 MessageAttachment* attachment = | 35 MessageAttachment* attachment = |
36 static_cast<MessageAttachment*>(base_attachment.get()); | 36 static_cast<MessageAttachment*>(base_attachment.get()); |
37 if (attachment->GetType() != MessageAttachment::TYPE_BROKERABLE_ATTACHMENT) | 37 if (attachment->GetType() != MessageAttachment::Type::MACH_PORT) |
38 return false; | 38 return false; |
39 BrokerableAttachment* brokerable_attachment = | |
40 static_cast<BrokerableAttachment*>(attachment); | |
41 if (brokerable_attachment->GetBrokerableType() != | |
42 BrokerableAttachment::MACH_PORT) { | |
43 return false; | |
44 } | |
45 IPC::internal::MachPortAttachmentMac* mach_port_attachment = | 39 IPC::internal::MachPortAttachmentMac* mach_port_attachment = |
46 static_cast<IPC::internal::MachPortAttachmentMac*>(brokerable_attachment); | 40 static_cast<IPC::internal::MachPortAttachmentMac*>(attachment); |
47 r->set_mach_port(mach_port_attachment->get_mach_port()); | 41 r->set_mach_port(mach_port_attachment->get_mach_port()); |
48 mach_port_attachment->reset_mach_port_ownership(); | 42 mach_port_attachment->reset_mach_port_ownership(); |
49 return true; | 43 return true; |
50 } | 44 } |
51 | 45 |
52 // static | 46 // static |
53 void ParamTraits<MachPortMac>::Log(const param_type& p, std::string* l) { | 47 void ParamTraits<MachPortMac>::Log(const param_type& p, std::string* l) { |
54 l->append(base::StringPrintf("mach port: 0x%X", p.get_mach_port())); | 48 l->append(base::StringPrintf("mach port: 0x%X", p.get_mach_port())); |
55 } | 49 } |
56 | 50 |
57 } // namespace IPC | 51 } // namespace IPC |
OLD | NEW |