| 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 17 matching lines...) Expand all Loading... |
| 28 #include "ipc/ipc_platform_file_attachment_posix.h" | 28 #include "ipc/ipc_platform_file_attachment_posix.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 #if defined(OS_MACOSX) && !defined(OS_IOS) | 31 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 32 #include "ipc/mach_port_mac.h" | 32 #include "ipc/mach_port_mac.h" |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 36 #include <tchar.h> | 36 #include <tchar.h> |
| 37 #include "ipc/handle_win.h" | 37 #include "ipc/handle_win.h" |
| 38 #include "ipc/ipc_platform_file.h" |
| 38 #endif | 39 #endif |
| 39 | 40 |
| 40 namespace IPC { | 41 namespace IPC { |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 const int kMaxRecursionDepth = 200; | 45 const int kMaxRecursionDepth = 200; |
| 45 | 46 |
| 46 template<typename CharType> | 47 template<typename CharType> |
| 47 void LogBytes(const std::vector<CharType>& data, std::string* out) { | 48 void LogBytes(const std::vector<CharType>& data, std::string* out) { |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p, | 836 void ParamTraits<base::SharedMemoryHandle>::Log(const param_type& p, |
| 836 std::string* l) { | 837 std::string* l) { |
| 837 if (p.OwnershipPassesToIPC()) { | 838 if (p.OwnershipPassesToIPC()) { |
| 838 l->append(base::StringPrintf("FD(%d auto-close)", p.GetHandle())); | 839 l->append(base::StringPrintf("FD(%d auto-close)", p.GetHandle())); |
| 839 } else { | 840 } else { |
| 840 l->append(base::StringPrintf("FD(%d)", p.GetHandle())); | 841 l->append(base::StringPrintf("FD(%d)", p.GetHandle())); |
| 841 } | 842 } |
| 842 } | 843 } |
| 843 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 844 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 844 | 845 |
| 846 #if defined(OS_WIN) |
| 847 void ParamTraits<PlatformFileForTransit>::GetSize(base::PickleSizer* s, |
| 848 const param_type& p) { |
| 849 GetParamSize(s, p.IsValid()); |
| 850 if (p.IsValid()) |
| 851 GetParamSize(s, p.GetHandle()); |
| 852 } |
| 853 |
| 854 void ParamTraits<PlatformFileForTransit>::Write(base::Pickle* m, |
| 855 const param_type& p) { |
| 856 m->WriteBool(p.IsValid()); |
| 857 if (p.IsValid()) { |
| 858 HandleWin handle_win(p.GetHandle(), HandleWin::DUPLICATE); |
| 859 ParamTraits<HandleWin>::Write(m, handle_win); |
| 860 ::CloseHandle(p.GetHandle()); |
| 861 } |
| 862 } |
| 863 |
| 864 bool ParamTraits<PlatformFileForTransit>::Read(const base::Pickle* m, |
| 865 base::PickleIterator* iter, |
| 866 param_type* r) { |
| 867 bool is_valid; |
| 868 if (!iter->ReadBool(&is_valid)) |
| 869 return false; |
| 870 if (!is_valid) { |
| 871 *r = PlatformFileForTransit(); |
| 872 return true; |
| 873 } |
| 874 |
| 875 HandleWin handle_win; |
| 876 if (!ParamTraits<HandleWin>::Read(m, iter, &handle_win)) |
| 877 return false; |
| 878 *r = PlatformFileForTransit(handle_win.get_handle()); |
| 879 return true; |
| 880 } |
| 881 |
| 882 void ParamTraits<PlatformFileForTransit>::Log(const param_type& p, |
| 883 std::string* l) { |
| 884 LogParam(p.GetHandle(), l); |
| 885 } |
| 886 #endif // defined(OS_WIN) |
| 887 |
| 845 void ParamTraits<base::FilePath>::GetSize(base::PickleSizer* sizer, | 888 void ParamTraits<base::FilePath>::GetSize(base::PickleSizer* sizer, |
| 846 const param_type& p) { | 889 const param_type& p) { |
| 847 p.GetSizeForPickle(sizer); | 890 p.GetSizeForPickle(sizer); |
| 848 } | 891 } |
| 849 | 892 |
| 850 void ParamTraits<base::FilePath>::Write(base::Pickle* m, const param_type& p) { | 893 void ParamTraits<base::FilePath>::Write(base::Pickle* m, const param_type& p) { |
| 851 p.WriteToPickle(m); | 894 p.WriteToPickle(m); |
| 852 } | 895 } |
| 853 | 896 |
| 854 bool ParamTraits<base::FilePath>::Read(const base::Pickle* m, | 897 bool ParamTraits<base::FilePath>::Read(const base::Pickle* m, |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 return result; | 1331 return result; |
| 1289 } | 1332 } |
| 1290 | 1333 |
| 1291 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { | 1334 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { |
| 1292 l->append("<MSG>"); | 1335 l->append("<MSG>"); |
| 1293 } | 1336 } |
| 1294 | 1337 |
| 1295 #endif // OS_WIN | 1338 #endif // OS_WIN |
| 1296 | 1339 |
| 1297 } // namespace IPC | 1340 } // namespace IPC |
| OLD | NEW |