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/mac/mach_logging.h" |
8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
10 #include "ipc/mach_port_attachment_mac.h" | 11 #include "ipc/mach_port_attachment_mac.h" |
11 | 12 |
12 namespace IPC { | 13 namespace IPC { |
13 | 14 |
14 // static | 15 MachPortMac::MachPortMac(const mach_port_t& mach_port) : mach_port_(mach_port) { |
| 16 if (mach_port != MACH_PORT_NULL) { |
| 17 kern_return_t kr = mach_port_mod_refs(mach_task_self(), mach_port, |
| 18 MACH_PORT_RIGHT_SEND, 1); |
| 19 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr) |
| 20 << "MachPortMac mach_port_mod_refs"; |
| 21 } |
| 22 } |
| 23 |
| 24 // static |
15 void ParamTraits<MachPortMac>::Write(Message* m, const param_type& p) { | 25 void ParamTraits<MachPortMac>::Write(Message* m, const param_type& p) { |
16 if (!m->WriteAttachment( | 26 if (!m->WriteAttachment( |
17 new IPC::internal::MachPortAttachmentMac(p.get_mach_port()))) { | 27 new IPC::internal::MachPortAttachmentMac(p.get_mach_port()))) { |
18 NOTREACHED(); | 28 NOTREACHED(); |
19 } | 29 } |
20 } | 30 } |
21 | 31 |
22 // static | 32 // static |
23 bool ParamTraits<MachPortMac>::Read(const Message* m, | 33 bool ParamTraits<MachPortMac>::Read(const Message* m, |
24 base::PickleIterator* iter, | 34 base::PickleIterator* iter, |
(...skipping 14 matching lines...) Expand all Loading... |
39 r->set_mach_port(mach_port_attachment->get_mach_port()); | 49 r->set_mach_port(mach_port_attachment->get_mach_port()); |
40 return true; | 50 return true; |
41 } | 51 } |
42 | 52 |
43 // static | 53 // static |
44 void ParamTraits<MachPortMac>::Log(const param_type& p, std::string* l) { | 54 void ParamTraits<MachPortMac>::Log(const param_type& p, std::string* l) { |
45 l->append(base::StringPrintf("mach port: 0x%X", p.get_mach_port())); | 55 l->append(base::StringPrintf("mach port: 0x%X", p.get_mach_port())); |
46 } | 56 } |
47 | 57 |
48 } // namespace IPC | 58 } // namespace IPC |
OLD | NEW |