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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // compatibility with old builds. | 47 // compatibility with old builds. |
48 AutomationMsgStart = 0, | 48 AutomationMsgStart = 0, |
49 ViewMsgStart, | 49 ViewMsgStart, |
50 ViewHostMsgStart, | 50 ViewHostMsgStart, |
51 PluginProcessMsgStart, | 51 PluginProcessMsgStart, |
52 PluginProcessHostMsgStart, | 52 PluginProcessHostMsgStart, |
53 PluginMsgStart, | 53 PluginMsgStart, |
54 PluginHostMsgStart, | 54 PluginHostMsgStart, |
55 NPObjectMsgStart, | 55 NPObjectMsgStart, |
56 TestMsgStart, | 56 TestMsgStart, |
| 57 DevToolsAgentMsgStart, |
| 58 DevToolsClientMsgStart, |
57 // NOTE: When you add a new message class, also update | 59 // NOTE: When you add a new message class, also update |
58 // IPCStatusView::IPCStatusView to ensure logging works. | 60 // IPCStatusView::IPCStatusView to ensure logging works. |
59 // 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 |
60 // 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 |
61 // than 16 entries, that code needs to be updated. | 63 // than 16 entries, that code needs to be updated. |
62 LastMsgIndex | 64 LastMsgIndex |
63 }; | 65 }; |
64 | 66 |
65 COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO); | 67 COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO); |
66 | 68 |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 ReadParam(m, iter, &r->params); | 887 ReadParam(m, iter, &r->params); |
886 r->type = static_cast<uint16>(type); | 888 r->type = static_cast<uint16>(type); |
887 return result; | 889 return result; |
888 } | 890 } |
889 static void Log(const param_type& p, std::wstring* l) { | 891 static void Log(const param_type& p, std::wstring* l) { |
890 // Doesn't make sense to implement this! | 892 // Doesn't make sense to implement this! |
891 } | 893 } |
892 }; | 894 }; |
893 | 895 |
894 template <> | 896 template <> |
| 897 struct ParamTraits<Message> { |
| 898 static void Write(Message* m, const Message& p) { |
| 899 m->WriteInt(p.size()); |
| 900 m->WriteData(reinterpret_cast<const char*>(p.data()), p.size()); |
| 901 } |
| 902 static bool Read(const Message* m, void** iter, Message* r) { |
| 903 int size; |
| 904 if (!m->ReadInt(iter, &size)) |
| 905 return false; |
| 906 const char* data; |
| 907 if (!m->ReadData(iter, &data, &size)) |
| 908 return false; |
| 909 *r = Message(data, size); |
| 910 return true; |
| 911 } |
| 912 static void Log(const Message& p, std::wstring* l) { |
| 913 l->append(L"<IPC::Message>"); |
| 914 } |
| 915 }; |
| 916 |
| 917 template <> |
895 struct ParamTraits<Tuple0> { | 918 struct ParamTraits<Tuple0> { |
896 typedef Tuple0 param_type; | 919 typedef Tuple0 param_type; |
897 static void Write(Message* m, const param_type& p) { | 920 static void Write(Message* m, const param_type& p) { |
898 } | 921 } |
899 static bool Read(const Message* m, void** iter, param_type* r) { | 922 static bool Read(const Message* m, void** iter, param_type* r) { |
900 return true; | 923 return true; |
901 } | 924 } |
902 static void Log(const param_type& p, std::wstring* l) { | 925 static void Log(const param_type& p, std::wstring* l) { |
903 } | 926 } |
904 }; | 927 }; |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 l->append(L"<FindInPageRequest>"); | 1440 l->append(L"<FindInPageRequest>"); |
1418 } | 1441 } |
1419 }; | 1442 }; |
1420 | 1443 |
1421 //----------------------------------------------------------------------------- | 1444 //----------------------------------------------------------------------------- |
1422 | 1445 |
1423 } // namespace IPC | 1446 } // namespace IPC |
1424 | 1447 |
1425 #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 1448 #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
1426 | 1449 |
OLD | NEW |