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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // compatibility with old builds. | 45 // compatibility with old builds. |
46 AutomationMsgStart = 0, | 46 AutomationMsgStart = 0, |
47 ViewMsgStart, | 47 ViewMsgStart, |
48 ViewHostMsgStart, | 48 ViewHostMsgStart, |
49 PluginProcessMsgStart, | 49 PluginProcessMsgStart, |
50 PluginProcessHostMsgStart, | 50 PluginProcessHostMsgStart, |
51 PluginMsgStart, | 51 PluginMsgStart, |
52 PluginHostMsgStart, | 52 PluginHostMsgStart, |
53 NPObjectMsgStart, | 53 NPObjectMsgStart, |
54 TestMsgStart, | 54 TestMsgStart, |
| 55 WorkerProcessMsgStart, |
| 56 WorkerProcessHostMsgStart, |
| 57 WorkerMsgStart, |
| 58 WorkerHostMsgStart, |
55 // NOTE: When you add a new message class, also update | 59 // NOTE: When you add a new message class, also update |
56 // IPCStatusView::IPCStatusView to ensure logging works. | 60 // IPCStatusView::IPCStatusView to ensure logging works. |
57 // NOTE: this enum is used by IPC_MESSAGE_MACRO to generate a unique message | 61 // NOTE: this enum is used by IPC_MESSAGE_MACRO to generate a unique message |
58 // id. Only 4 bits are used for the message type, so if this enum needs more | 62 // id. Only 4 bits are used for the message type, so if this enum needs more |
59 // than 16 entries, that code needs to be updated. | 63 // than 16 entries, that code needs to be updated. |
60 LastMsgIndex | 64 LastMsgIndex |
61 }; | 65 }; |
62 | 66 |
63 COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO); | 67 COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO); |
64 | 68 |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 ReadParam(m, iter, &r->dispatch) && | 886 ReadParam(m, iter, &r->dispatch) && |
883 ReadParam(m, iter, &r->params); | 887 ReadParam(m, iter, &r->params); |
884 r->type = static_cast<uint16>(type); | 888 r->type = static_cast<uint16>(type); |
885 return result; | 889 return result; |
886 } | 890 } |
887 static void Log(const param_type& p, std::wstring* l) { | 891 static void Log(const param_type& p, std::wstring* l) { |
888 // Doesn't make sense to implement this! | 892 // Doesn't make sense to implement this! |
889 } | 893 } |
890 }; | 894 }; |
891 | 895 |
| 896 |
| 897 template <> |
| 898 struct ParamTraits<webkit_glue::WebApplicationInfo> { |
| 899 typedef webkit_glue::WebApplicationInfo param_type; |
| 900 static void Write(Message* m, const param_type& p); |
| 901 static bool Read(const Message* m, void** iter, param_type* r); |
| 902 static void Log(const param_type& p, std::wstring* l); |
| 903 }; |
| 904 |
| 905 |
| 906 template <> |
| 907 struct ParamTraits<Message> { |
| 908 static void Write(Message* m, const Message& p) { |
| 909 m->WriteInt(p.size()); |
| 910 m->WriteData(reinterpret_cast<const char*>(p.data()), p.size()); |
| 911 } |
| 912 static bool Read(const Message* m, void** iter, Message* r) { |
| 913 int size; |
| 914 if (!m->ReadInt(iter, &size)) |
| 915 return false; |
| 916 const char* data; |
| 917 if (!m->ReadData(iter, &data, &size)) |
| 918 return false; |
| 919 *r = Message(data, size); |
| 920 return true; |
| 921 } |
| 922 static void Log(const Message& p, std::wstring* l) { |
| 923 l->append(L"<IPC::Message>"); |
| 924 } |
| 925 }; |
| 926 |
| 927 |
892 template <> | 928 template <> |
893 struct ParamTraits<Tuple0> { | 929 struct ParamTraits<Tuple0> { |
894 typedef Tuple0 param_type; | 930 typedef Tuple0 param_type; |
895 static void Write(Message* m, const param_type& p) { | 931 static void Write(Message* m, const param_type& p) { |
896 } | 932 } |
897 static bool Read(const Message* m, void** iter, param_type* r) { | 933 static bool Read(const Message* m, void** iter, param_type* r) { |
898 return true; | 934 return true; |
899 } | 935 } |
900 static void Log(const param_type& p, std::wstring* l) { | 936 static void Log(const param_type& p, std::wstring* l) { |
901 } | 937 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 LogParam(p.c, l); | 1074 LogParam(p.c, l); |
1039 l->append(L", "); | 1075 l->append(L", "); |
1040 LogParam(p.d, l); | 1076 LogParam(p.d, l); |
1041 l->append(L", "); | 1077 l->append(L", "); |
1042 LogParam(p.e, l); | 1078 LogParam(p.e, l); |
1043 l->append(L", "); | 1079 l->append(L", "); |
1044 LogParam(p.f, l); | 1080 LogParam(p.f, l); |
1045 } | 1081 } |
1046 }; | 1082 }; |
1047 | 1083 |
1048 template <> | |
1049 struct ParamTraits<webkit_glue::WebApplicationInfo> { | |
1050 typedef webkit_glue::WebApplicationInfo param_type; | |
1051 static void Write(Message* m, const param_type& p); | |
1052 static bool Read(const Message* m, void** iter, param_type* r); | |
1053 static void Log(const param_type& p, std::wstring* l); | |
1054 }; | |
1055 | |
1056 | 1084 |
1057 //----------------------------------------------------------------------------- | 1085 //----------------------------------------------------------------------------- |
1058 // Generic message subclasses | 1086 // Generic message subclasses |
1059 | 1087 |
1060 // Used for asynchronous messages. | 1088 // Used for asynchronous messages. |
1061 template <class ParamType> | 1089 template <class ParamType> |
1062 class MessageWithTuple : public Message { | 1090 class MessageWithTuple : public Message { |
1063 public: | 1091 public: |
1064 typedef ParamType Param; | 1092 typedef ParamType Param; |
1065 | 1093 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 l->append(L"<FindInPageRequest>"); | 1394 l->append(L"<FindInPageRequest>"); |
1367 } | 1395 } |
1368 }; | 1396 }; |
1369 | 1397 |
1370 //----------------------------------------------------------------------------- | 1398 //----------------------------------------------------------------------------- |
1371 | 1399 |
1372 } // namespace IPC | 1400 } // namespace IPC |
1373 | 1401 |
1374 #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 1402 #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
1375 | 1403 |
OLD | NEW |