OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 5 #ifndef CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
6 #define CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 6 #define CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include <map> | 10 #include <map> |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 static bool Read(const Message* m, void** iter, param_type* r); | 664 static bool Read(const Message* m, void** iter, param_type* r); |
665 static void Log(const param_type& p, std::wstring* l); | 665 static void Log(const param_type& p, std::wstring* l); |
666 }; | 666 }; |
667 | 667 |
668 #if defined(OS_POSIX) | 668 #if defined(OS_POSIX) |
669 | 669 |
670 template<> | 670 template<> |
671 struct ParamTraits<base::FileDescriptor> { | 671 struct ParamTraits<base::FileDescriptor> { |
672 typedef base::FileDescriptor param_type; | 672 typedef base::FileDescriptor param_type; |
673 static void Write(Message* m, const param_type& p) { | 673 static void Write(Message* m, const param_type& p) { |
674 if (p.auto_close) { | 674 if (!m->WriteFileDescriptor(p)) |
675 if (!m->descriptor_set()->AddAndAutoClose(p.fd)) | 675 NOTREACHED(); |
676 NOTREACHED(); | |
677 } else { | |
678 if (!m->descriptor_set()->Add(p.fd)) | |
679 NOTREACHED(); | |
680 } | |
681 } | 676 } |
682 static bool Read(const Message* m, void** iter, param_type* r) { | 677 static bool Read(const Message* m, void** iter, param_type* r) { |
683 r->auto_close = false; | 678 return m->ReadFileDescriptor(iter, r); |
684 r->fd = m->descriptor_set()->NextDescriptor(); | |
685 | |
686 // We always return true here because some of the IPC message logging | |
687 // functions want to parse the message multiple times. On the second and | |
688 // later attempts, the descriptor_set will be empty and so will return -1, | |
689 // however, failing to parse at log time is a fatal error. | |
690 return true; | |
691 } | 679 } |
692 static void Log(const param_type& p, std::wstring* l) { | 680 static void Log(const param_type& p, std::wstring* l) { |
693 if (p.auto_close) { | 681 if (p.auto_close) { |
694 l->append(L"FD(auto-close)"); | 682 l->append(StringPrintf(L"FD(%d auto-close)", p.fd)); |
695 } else { | 683 } else { |
696 l->append(L"FD"); | 684 l->append(StringPrintf(L"FD(%d)", p.fd)); |
697 } | 685 } |
698 } | 686 } |
699 }; | 687 }; |
700 | 688 |
701 #endif // defined(OS_POSIX) | 689 #endif // defined(OS_POSIX) |
702 | 690 |
703 template<> | 691 template<> |
704 struct ParamTraits<ThumbnailScore> { | 692 struct ParamTraits<ThumbnailScore> { |
705 typedef ThumbnailScore param_type; | 693 typedef ThumbnailScore param_type; |
706 static void Write(Message* m, const param_type& p) { | 694 static void Write(Message* m, const param_type& p) { |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 l->append(L"<FindInPageRequest>"); | 1365 l->append(L"<FindInPageRequest>"); |
1378 } | 1366 } |
1379 }; | 1367 }; |
1380 | 1368 |
1381 //----------------------------------------------------------------------------- | 1369 //----------------------------------------------------------------------------- |
1382 | 1370 |
1383 } // namespace IPC | 1371 } // namespace IPC |
1384 | 1372 |
1385 #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 1373 #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
1386 | 1374 |
OLD | NEW |