OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ipc_message_utils.h" | 5 #include "ipc/ipc_message_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } | 407 } |
408 | 408 |
409 void ParamTraits<int>::Log(const param_type& p, std::string* l) { | 409 void ParamTraits<int>::Log(const param_type& p, std::string* l) { |
410 l->append(base::IntToString(p)); | 410 l->append(base::IntToString(p)); |
411 } | 411 } |
412 | 412 |
413 void ParamTraits<unsigned int>::Log(const param_type& p, std::string* l) { | 413 void ParamTraits<unsigned int>::Log(const param_type& p, std::string* l) { |
414 l->append(base::UintToString(p)); | 414 l->append(base::UintToString(p)); |
415 } | 415 } |
416 | 416 |
| 417 #if defined(OS_WIN) || defined(ARCH_CPU_ARM64) || defined(OS_LINUX) |
417 void ParamTraits<long>::Log(const param_type& p, std::string* l) { | 418 void ParamTraits<long>::Log(const param_type& p, std::string* l) { |
418 l->append(base::Int64ToString(static_cast<int64_t>(p))); | 419 l->append(base::Int64ToString(static_cast<int64_t>(p))); |
419 } | 420 } |
420 | 421 |
421 void ParamTraits<unsigned long>::Log(const param_type& p, std::string* l) { | 422 void ParamTraits<unsigned long>::Log(const param_type& p, std::string* l) { |
422 l->append(base::Uint64ToString(static_cast<uint64_t>(p))); | 423 l->append(base::Uint64ToString(static_cast<uint64_t>(p))); |
423 } | 424 } |
| 425 #endif |
424 | 426 |
425 void ParamTraits<long long>::Log(const param_type& p, std::string* l) { | 427 void ParamTraits<long long>::Log(const param_type& p, std::string* l) { |
426 l->append(base::Int64ToString(static_cast<int64_t>(p))); | 428 l->append(base::Int64ToString(static_cast<int64_t>(p))); |
427 } | 429 } |
428 | 430 |
429 void ParamTraits<unsigned long long>::Log(const param_type& p, std::string* l) { | 431 void ParamTraits<unsigned long long>::Log(const param_type& p, std::string* l) { |
430 l->append(base::Uint64ToString(p)); | 432 l->append(base::Uint64ToString(p)); |
431 } | 433 } |
432 | 434 |
433 void ParamTraits<float>::Log(const param_type& p, std::string* l) { | 435 void ParamTraits<float>::Log(const param_type& p, std::string* l) { |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 switch (p.GetType()) { | 685 switch (p.GetType()) { |
684 case base::SharedMemoryHandle::POSIX: | 686 case base::SharedMemoryHandle::POSIX: |
685 ParamTraits<base::FileDescriptor>::Write(m, p.GetFileDescriptor()); | 687 ParamTraits<base::FileDescriptor>::Write(m, p.GetFileDescriptor()); |
686 break; | 688 break; |
687 case base::SharedMemoryHandle::MACH: | 689 case base::SharedMemoryHandle::MACH: |
688 MachPortMac mach_port_mac(p.GetMemoryObject()); | 690 MachPortMac mach_port_mac(p.GetMemoryObject()); |
689 ParamTraits<MachPortMac>::Write(m, mach_port_mac); | 691 ParamTraits<MachPortMac>::Write(m, mach_port_mac); |
690 size_t size = 0; | 692 size_t size = 0; |
691 bool result = p.GetSize(&size); | 693 bool result = p.GetSize(&size); |
692 DCHECK(result); | 694 DCHECK(result); |
693 ParamTraits<size_t>::Write(m, size); | 695 ParamTraits<uint32_t>::Write(m, static_cast<uint32_t>(size)); |
694 | 696 |
695 // If the caller intended to pass ownership to the IPC stack, release a | 697 // If the caller intended to pass ownership to the IPC stack, release a |
696 // reference. | 698 // reference. |
697 if (p.OwnershipPassesToIPC()) | 699 if (p.OwnershipPassesToIPC()) |
698 p.Close(); | 700 p.Close(); |
699 | 701 |
700 break; | 702 break; |
701 } | 703 } |
702 } | 704 } |
703 | 705 |
(...skipping 27 matching lines...) Expand all Loading... |
731 | 733 |
732 *r = base::SharedMemoryHandle(file_descriptor.fd, | 734 *r = base::SharedMemoryHandle(file_descriptor.fd, |
733 file_descriptor.auto_close); | 735 file_descriptor.auto_close); |
734 return true; | 736 return true; |
735 } | 737 } |
736 case base::SharedMemoryHandle::MACH: { | 738 case base::SharedMemoryHandle::MACH: { |
737 MachPortMac mach_port_mac; | 739 MachPortMac mach_port_mac; |
738 if (!ParamTraits<MachPortMac>::Read(m, iter, &mach_port_mac)) | 740 if (!ParamTraits<MachPortMac>::Read(m, iter, &mach_port_mac)) |
739 return false; | 741 return false; |
740 | 742 |
741 size_t size; | 743 uint32_t size; |
742 if (!ParamTraits<size_t>::Read(m, iter, &size)) | 744 if (!ParamTraits<uint32_t>::Read(m, iter, &size)) |
743 return false; | 745 return false; |
744 | 746 |
745 *r = base::SharedMemoryHandle(mach_port_mac.get_mach_port(), size, | 747 *r = base::SharedMemoryHandle(mach_port_mac.get_mach_port(), |
| 748 static_cast<size_t>(size), |
746 base::GetCurrentProcId()); | 749 base::GetCurrentProcId()); |
747 return true; | 750 return true; |
748 } | 751 } |
749 } | 752 } |
750 } | 753 } |
751 | 754 |
752 void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p, | 755 void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p, |
753 std::string* l) { | 756 std::string* l) { |
754 switch (p.GetType()) { | 757 switch (p.GetType()) { |
755 case base::SharedMemoryHandle::POSIX: | 758 case base::SharedMemoryHandle::POSIX: |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 return result; | 1215 return result; |
1213 } | 1216 } |
1214 | 1217 |
1215 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { | 1218 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { |
1216 l->append("<MSG>"); | 1219 l->append("<MSG>"); |
1217 } | 1220 } |
1218 | 1221 |
1219 #endif // OS_WIN | 1222 #endif // OS_WIN |
1220 | 1223 |
1221 } // namespace IPC | 1224 } // namespace IPC |
OLD | NEW |