| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 IPC_IPC_MESSAGE_UTILS_H_ | 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_ |
| 6 #define IPC_IPC_MESSAGE_UTILS_H_ | 6 #define IPC_IPC_MESSAGE_UTILS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
| 16 #include "base/string16.h" | 16 #include "base/string16.h" |
| 17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/tuple.h" | 19 #include "base/tuple.h" |
| 20 #include "ipc/ipc_param_traits.h" | 20 #include "ipc/ipc_param_traits.h" |
| 21 #include "ipc/ipc_sync_message.h" | 21 #include "ipc/ipc_sync_message.h" |
| 22 | 22 |
| 23 #if defined(USE_AURA) | |
| 24 #include "ui/gfx/native_widget_types.h" | |
| 25 #endif | |
| 26 | |
| 27 #if defined(COMPILER_GCC) | 23 #if defined(COMPILER_GCC) |
| 28 // GCC "helpfully" tries to inline template methods in release mode. Except we | 24 // GCC "helpfully" tries to inline template methods in release mode. Except we |
| 29 // want the majority of the template junk being expanded once in the | 25 // want the majority of the template junk being expanded once in the |
| 30 // implementation file (and only provide the definitions in | 26 // implementation file (and only provide the definitions in |
| 31 // ipc_message_utils_impl.h in those files) and exported, instead of expanded | 27 // ipc_message_utils_impl.h in those files) and exported, instead of expanded |
| 32 // at every call site. Special note: GCC happily accepts the attribute before | 28 // at every call site. Special note: GCC happily accepts the attribute before |
| 33 // the method declaration, but only acts on it if it is after. | 29 // the method declaration, but only acts on it if it is after. |
| 34 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40500 | 30 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40500 |
| 35 // Starting in gcc 4.5, the noinline no longer implies the concept covered by | 31 // Starting in gcc 4.5, the noinline no longer implies the concept covered by |
| 36 // the introduced noclone attribute, which will create specialized versions of | 32 // the introduced noclone attribute, which will create specialized versions of |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 } | 652 } |
| 657 static bool Read(const Message* m, void** iter, param_type* r) { | 653 static bool Read(const Message* m, void** iter, param_type* r) { |
| 658 DCHECK_EQ(sizeof(param_type), sizeof(uint32)); | 654 DCHECK_EQ(sizeof(param_type), sizeof(uint32)); |
| 659 return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); | 655 return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); |
| 660 } | 656 } |
| 661 static void Log(const param_type& p, std::string* l) { | 657 static void Log(const param_type& p, std::string* l) { |
| 662 l->append(StringPrintf("0x%X", p)); | 658 l->append(StringPrintf("0x%X", p)); |
| 663 } | 659 } |
| 664 }; | 660 }; |
| 665 | 661 |
| 666 #if defined(USE_AURA) | |
| 667 // TODO(beng): Figure out why this is needed, fix that issue and remove | |
| 668 // this. Brett and I were unable to figure out why, but he | |
| 669 // thought this should be harmless. | |
| 670 template <> | 662 template <> |
| 671 struct ParamTraits<gfx::PluginWindowHandle> { | 663 struct ParamTraits<HCURSOR> { |
| 672 typedef gfx::PluginWindowHandle param_type; | 664 typedef HCURSOR param_type; |
| 673 static void Write(Message* m, const param_type& p) { | 665 static void Write(Message* m, const param_type& p) { |
| 674 m->WriteUInt32(reinterpret_cast<uint32>(p)); | 666 m->WriteUInt32(reinterpret_cast<uint32>(p)); |
| 675 } | 667 } |
| 676 static bool Read(const Message* m, void** iter, param_type* r) { | 668 static bool Read(const Message* m, void** iter, param_type* r) { |
| 677 DCHECK_EQ(sizeof(param_type), sizeof(uint32)); | 669 DCHECK_EQ(sizeof(param_type), sizeof(uint32)); |
| 678 return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); | 670 return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); |
| 679 } | 671 } |
| 680 static void Log(const param_type& p, std::string* l) { | 672 static void Log(const param_type& p, std::string* l) { |
| 681 l->append(StringPrintf("0x%X", p)); | 673 l->append(StringPrintf("0x%X", p)); |
| 682 } | 674 } |
| 683 }; | 675 }; |
| 684 #endif | |
| 685 | 676 |
| 686 template <> | 677 template <> |
| 687 struct ParamTraits<HACCEL> { | 678 struct ParamTraits<HACCEL> { |
| 688 typedef HACCEL param_type; | 679 typedef HACCEL param_type; |
| 689 static void Write(Message* m, const param_type& p) { | 680 static void Write(Message* m, const param_type& p) { |
| 690 m->WriteUInt32(reinterpret_cast<uint32>(p)); | 681 m->WriteUInt32(reinterpret_cast<uint32>(p)); |
| 691 } | 682 } |
| 692 static bool Read(const Message* m, void** iter, param_type* r) { | 683 static bool Read(const Message* m, void** iter, param_type* r) { |
| 693 DCHECK_EQ(sizeof(param_type), sizeof(uint32)); | 684 DCHECK_EQ(sizeof(param_type), sizeof(uint32)); |
| 694 return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); | 685 return m->ReadUInt32(iter, reinterpret_cast<uint32*>(r)); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 ReplyParam p(a, b, c, d, e); | 1103 ReplyParam p(a, b, c, d, e); |
| 1113 WriteParam(reply, p); | 1104 WriteParam(reply, p); |
| 1114 } | 1105 } |
| 1115 }; | 1106 }; |
| 1116 | 1107 |
| 1117 //----------------------------------------------------------------------------- | 1108 //----------------------------------------------------------------------------- |
| 1118 | 1109 |
| 1119 } // namespace IPC | 1110 } // namespace IPC |
| 1120 | 1111 |
| 1121 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1112 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
| OLD | NEW |