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 "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/nullable_string16.h" | 10 #include "base/nullable_string16.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "ipc/ipc_channel_handle.h" | 15 #include "ipc/ipc_channel_handle.h" |
16 | 16 |
17 #if defined(OS_POSIX) | 17 #if defined(OS_POSIX) |
18 #include "ipc/file_descriptor_set_posix.h" | 18 #include "ipc/file_descriptor_set_posix.h" |
| 19 #elif defined(OS_WIN) |
| 20 #include <tchar.h> |
19 #endif | 21 #endif |
20 | 22 |
21 namespace IPC { | 23 namespace IPC { |
22 | 24 |
23 namespace { | 25 namespace { |
24 | 26 |
25 const int kMaxRecursionDepth = 100; | 27 const int kMaxRecursionDepth = 100; |
26 | 28 |
27 template<typename CharType> | 29 template<typename CharType> |
28 void LogBytes(const std::vector<CharType>& data, std::string* out) { | 30 void LogBytes(const std::vector<CharType>& data, std::string* out) { |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 } | 801 } |
800 | 802 |
801 void ParamTraits<LOGFONT>::Write(Message* m, const param_type& p) { | 803 void ParamTraits<LOGFONT>::Write(Message* m, const param_type& p) { |
802 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(LOGFONT)); | 804 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(LOGFONT)); |
803 } | 805 } |
804 | 806 |
805 bool ParamTraits<LOGFONT>::Read(const Message* m, PickleIterator* iter, | 807 bool ParamTraits<LOGFONT>::Read(const Message* m, PickleIterator* iter, |
806 param_type* r) { | 808 param_type* r) { |
807 const char *data; | 809 const char *data; |
808 int data_size = 0; | 810 int data_size = 0; |
809 bool result = m->ReadData(iter, &data, &data_size); | 811 if (m->ReadData(iter, &data, &data_size) && data_size == sizeof(LOGFONT)) { |
810 if (result && data_size == sizeof(LOGFONT)) { | 812 const LOGFONT *font = reinterpret_cast<LOGFONT*>(const_cast<char*>(data)); |
811 memcpy(r, data, sizeof(LOGFONT)); | 813 if (_tcsnlen(font->lfFaceName, LF_FACESIZE) < LF_FACESIZE) { |
812 } else { | 814 memcpy(r, data, sizeof(LOGFONT)); |
813 result = false; | 815 return true; |
814 NOTREACHED(); | 816 } |
815 } | 817 } |
816 | 818 |
817 return result; | 819 NOTREACHED(); |
| 820 return false; |
818 } | 821 } |
819 | 822 |
820 void ParamTraits<LOGFONT>::Log(const param_type& p, std::string* l) { | 823 void ParamTraits<LOGFONT>::Log(const param_type& p, std::string* l) { |
821 l->append(StringPrintf("<LOGFONT>")); | 824 l->append(StringPrintf("<LOGFONT>")); |
822 } | 825 } |
823 | 826 |
824 void ParamTraits<MSG>::Write(Message* m, const param_type& p) { | 827 void ParamTraits<MSG>::Write(Message* m, const param_type& p) { |
825 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(MSG)); | 828 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(MSG)); |
826 } | 829 } |
827 | 830 |
(...skipping 12 matching lines...) Expand all Loading... |
840 return result; | 843 return result; |
841 } | 844 } |
842 | 845 |
843 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { | 846 void ParamTraits<MSG>::Log(const param_type& p, std::string* l) { |
844 l->append("<MSG>"); | 847 l->append("<MSG>"); |
845 } | 848 } |
846 | 849 |
847 #endif // OS_WIN | 850 #endif // OS_WIN |
848 | 851 |
849 } // namespace IPC | 852 } // namespace IPC |
OLD | NEW |