| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 // This header is meant to be included in multiple passes, hence no traditional | 5 // In your XXX_messages.h file, before defining any messages do: |
| 6 // header guard. | |
| 7 // | |
| 8 // In your XXX_messages_internal.h file, before defining any messages do: | |
| 9 // #define IPC_MESSAGE_START XMsgStart | 6 // #define IPC_MESSAGE_START XMsgStart |
| 10 // XMstStart value is from the IPCMessageStart enum in ipc_message_utils.h, and | 7 // XMstStart value is from the IPCMessageStart enum in ipc_message_utils.h, and |
| 11 // needs to be unique for each different file. | 8 // needs to be unique for each different file. |
| 12 // In your XXX_messages.cc file, after all the includes for param types: | 9 // In your XXX_messages.cc file, after all the includes for param types: |
| 13 // #define IPC_MESSAGE_IMPL | 10 // #define IPC_MESSAGE_IMPL |
| 14 // #include "X_messages.h" | 11 // #include "X_messages.h" |
| 15 // | 12 // |
| 16 // "Sync" messages are just synchronous calls, the Send() call doesn't return | 13 // "Sync" messages are just synchronous calls, the Send() call doesn't return |
| 17 // until a reply comes back. Input parameters are first (const TYPE&), and | 14 // until a reply comes back. Input parameters are first (const TYPE&), and |
| 18 // To declare a sync message, use the IPC_SYNC_ macros. The numbers at the | 15 // To declare a sync message, use the IPC_SYNC_ macros. The numbers at the |
| (...skipping 12 matching lines...) Expand all Loading... |
| 31 // IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncMessageName, | 28 // IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncMessageName, |
| 32 // OnSyncMessageName) | 29 // OnSyncMessageName) |
| 33 // | 30 // |
| 34 // The handler function will look like: | 31 // The handler function will look like: |
| 35 // void OnSyncMessageName(const type1& in1, IPC::Message* reply_msg); | 32 // void OnSyncMessageName(const type1& in1, IPC::Message* reply_msg); |
| 36 // | 33 // |
| 37 // Receiver stashes the IPC::Message* pointer, and when it's ready, it does: | 34 // Receiver stashes the IPC::Message* pointer, and when it's ready, it does: |
| 38 // ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2); | 35 // ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2); |
| 39 // Send(reply_msg); | 36 // Send(reply_msg); |
| 40 | 37 |
| 38 #ifndef IPC_IPC_MESSAGE_MACROS_H_ |
| 39 #define IPC_IPC_MESSAGE_MACROS_H_ |
| 40 // Can use #pragma once all XXX_messages.h files clean up IPC_MESSAGE_START |
| 41 |
| 41 #include "ipc/ipc_message_utils.h" | 42 #include "ipc/ipc_message_utils.h" |
| 42 | 43 #include "ipc/ipc_param_traits_macros.h" |
| 43 // In case a file includes several X_messages.h files, we don't want to get | |
| 44 // errors because each X_messages_internal.h file will define this. | |
| 45 #undef IPC_MESSAGE_START | |
| 46 | 44 |
| 47 #if defined(IPC_MESSAGE_IMPL) | 45 #if defined(IPC_MESSAGE_IMPL) |
| 48 #include "ipc/ipc_message_impl_macros.h" | 46 #include "ipc/ipc_message_impl_macros.h" |
| 49 #elif defined(IPC_MESSAGE_MACROS_LOG_ENABLED) | 47 #elif defined(IPC_MESSAGE_MACROS_LOG_ENABLED) |
| 50 | 48 |
| 51 #ifndef IPC_LOG_TABLE_CREATED | 49 #ifndef IPC_LOG_TABLE_CREATED |
| 52 #define IPC_LOG_TABLE_CREATED | 50 #define IPC_LOG_TABLE_CREATED |
| 53 | 51 |
| 54 #include "base/hash_tables.h" | 52 #include "base/hash_tables.h" |
| 55 | 53 |
| 56 typedef void (*LogFunction)(std::string* name, | 54 typedef void (*LogFunction)(std::string* name, |
| 57 const IPC::Message* msg, | 55 const IPC::Message* msg, |
| 58 std::string* params); | 56 std::string* params); |
| 59 | 57 |
| 60 typedef base::hash_map<uint32, LogFunction > LogFunctionMap; | 58 typedef base::hash_map<uint32, LogFunction > LogFunctionMap; |
| 61 LogFunctionMap g_log_function_mapping; | 59 LogFunctionMap g_log_function_mapping; |
| 62 | 60 |
| 63 #endif | 61 #endif // IPC_LOG_TABLE_CREATED |
| 64 | 62 |
| 65 | 63 |
| 66 #define IPC_MESSAGE_LOG(msg_class) \ | 64 #define IPC_MESSAGE_LOG(msg_class) \ |
| 67 class LoggerRegisterHelper##msg_class { \ | 65 class LoggerRegisterHelper##msg_class { \ |
| 68 public: \ | 66 public: \ |
| 69 LoggerRegisterHelper##msg_class() { \ | 67 LoggerRegisterHelper##msg_class() { \ |
| 70 g_log_function_mapping[msg_class::ID] = msg_class::Log; \ | 68 g_log_function_mapping[msg_class::ID] = msg_class::Log; \ |
| 71 } \ | 69 } \ |
| 72 }; \ | 70 }; \ |
| 73 LoggerRegisterHelper##msg_class g_LoggerRegisterHelper##msg_class; | 71 LoggerRegisterHelper##msg_class g_LoggerRegisterHelper##msg_class; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 271 |
| 274 #define IPC_SYNC_MESSAGE_ROUTED5_2_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out) \ | 272 #define IPC_SYNC_MESSAGE_ROUTED5_2_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out) \ |
| 275 IPC_MESSAGE_LOG(msg_class) | 273 IPC_MESSAGE_LOG(msg_class) |
| 276 | 274 |
| 277 #define IPC_SYNC_MESSAGE_ROUTED5_3_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out, type3_out) \ | 275 #define IPC_SYNC_MESSAGE_ROUTED5_3_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out, type3_out) \ |
| 278 IPC_MESSAGE_LOG(msg_class) | 276 IPC_MESSAGE_LOG(msg_class) |
| 279 | 277 |
| 280 #define IPC_SYNC_MESSAGE_ROUTED5_4_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out, type3_out, type4_out) \ | 278 #define IPC_SYNC_MESSAGE_ROUTED5_4_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out, type3_out, type4_out) \ |
| 281 IPC_MESSAGE_LOG(msg_class) | 279 IPC_MESSAGE_LOG(msg_class) |
| 282 | 280 |
| 283 #else | 281 #else // defined(IPC_MESSAGE_MACROS_LOG_ENABLED) |
| 284 | 282 |
| 285 #define IPC_MESSAGE_CONTROL0_EXTRA(msg_class) | 283 #define IPC_MESSAGE_CONTROL0_EXTRA(msg_class) |
| 286 #define IPC_MESSAGE_CONTROL1_EXTRA(msg_class, type1) | 284 #define IPC_MESSAGE_CONTROL1_EXTRA(msg_class, type1) |
| 287 #define IPC_MESSAGE_CONTROL2_EXTRA(msg_class, type1, type2) | 285 #define IPC_MESSAGE_CONTROL2_EXTRA(msg_class, type1, type2) |
| 288 #define IPC_MESSAGE_CONTROL3_EXTRA(msg_class, type1, type2, type3) | 286 #define IPC_MESSAGE_CONTROL3_EXTRA(msg_class, type1, type2, type3) |
| 289 #define IPC_MESSAGE_CONTROL4_EXTRA(msg_class, type1, type2, type3, type4) | 287 #define IPC_MESSAGE_CONTROL4_EXTRA(msg_class, type1, type2, type3, type4) |
| 290 #define IPC_MESSAGE_CONTROL5_EXTRA(msg_class, type1, type2, type3, type4, type5) | 288 #define IPC_MESSAGE_CONTROL5_EXTRA(msg_class, type1, type2, type3, type4, type5) |
| 291 #define IPC_MESSAGE_ROUTED0_EXTRA(msg_class) | 289 #define IPC_MESSAGE_ROUTED0_EXTRA(msg_class) |
| 292 #define IPC_MESSAGE_ROUTED1_EXTRA(msg_class, type1) | 290 #define IPC_MESSAGE_ROUTED1_EXTRA(msg_class, type1) |
| 293 #define IPC_MESSAGE_ROUTED2_EXTRA(msg_class, type1, type2) | 291 #define IPC_MESSAGE_ROUTED2_EXTRA(msg_class, type1, type2) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 #define IPC_SYNC_MESSAGE_ROUTED4_1_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type1_out) | 343 #define IPC_SYNC_MESSAGE_ROUTED4_1_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type1_out) |
| 346 #define IPC_SYNC_MESSAGE_ROUTED4_2_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type1_out, type2_out) | 344 #define IPC_SYNC_MESSAGE_ROUTED4_2_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type1_out, type2_out) |
| 347 #define IPC_SYNC_MESSAGE_ROUTED4_3_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type1_out, type2_out, type3_out) | 345 #define IPC_SYNC_MESSAGE_ROUTED4_3_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type1_out, type2_out, type3_out) |
| 348 #define IPC_SYNC_MESSAGE_ROUTED4_4_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type1_out, type2_out, type3_out, type4_out) | 346 #define IPC_SYNC_MESSAGE_ROUTED4_4_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type1_out, type2_out, type3_out, type4_out) |
| 349 #define IPC_SYNC_MESSAGE_ROUTED5_0_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in) | 347 #define IPC_SYNC_MESSAGE_ROUTED5_0_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in) |
| 350 #define IPC_SYNC_MESSAGE_ROUTED5_1_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out) | 348 #define IPC_SYNC_MESSAGE_ROUTED5_1_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out) |
| 351 #define IPC_SYNC_MESSAGE_ROUTED5_2_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out) | 349 #define IPC_SYNC_MESSAGE_ROUTED5_2_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out) |
| 352 #define IPC_SYNC_MESSAGE_ROUTED5_3_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out, type3_out) | 350 #define IPC_SYNC_MESSAGE_ROUTED5_3_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out, type3_out) |
| 353 #define IPC_SYNC_MESSAGE_ROUTED5_4_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out, type4_out) | 351 #define IPC_SYNC_MESSAGE_ROUTED5_4_EXTRA(msg_class, type1_in, type2_in, type3_in
, type4_in, type5_in, type1_out, type2_out, type4_out) |
| 354 | 352 |
| 355 #endif | 353 #endif // defined(IPC_MESSAGE_MACROS_LOG_ENABLED) |
| 354 |
| 355 // Force IPC message guard convention single-include semantics. |
| 356 #define IPC_MESSAGE_REINCLUDE 0 |
| 357 |
| 358 // Macros for defining structures. May be subsequently redefined. |
| 359 #define IPC_STRUCT_BEGIN(struct_name) \ |
| 360 struct struct_name : IPC::NoParams { \ |
| 361 struct_name(); \ |
| 362 ~struct_name(); |
| 363 #define IPC_STRUCT_MEMBER(type, name) type name; |
| 364 #define IPC_STRUCT_END(struct_name) \ |
| 365 }; \ |
| 366 IPC_STRUCT_TRAITS_BEGIN(struct_name) \ |
| 367 IPC_STRUCT_TRAITS_END(struct_name) |
| 368 |
| 369 // Macros for defining enums. May be subsequently redefined. |
| 370 #define IPC_ENUM_BEGIN(enum_name) enum enum_name { |
| 371 #define IPC_ENUM_VALUE(name) name, |
| 372 #define IPC_ENUM_END(enum_name) \ |
| 373 }; \ |
| 374 IPC_ENUM_TRAITS_BEGIN(enum_name) \ |
| 375 IPC_ENUM_TRAITS_END(enum_name) |
| 356 | 376 |
| 357 // Note: we currently use __LINE__ to give unique IDs to messages within a file. | 377 // Note: we currently use __LINE__ to give unique IDs to messages within a file. |
| 358 // They're globally unique since each file defines its own IPC_MESSAGE_START. | 378 // They're globally unique since each file defines its own IPC_MESSAGE_START. |
| 359 // Ideally, we wouldn't use line numbers, but instead use the __COUNTER__ macro, | 379 // Ideally, we wouldn't use line numbers, but instead use the __COUNTER__ macro, |
| 360 // but it needs gcc 4.3 and xcode doesn't use it yet. When that happens, switch | 380 // but it needs gcc 4.3 and xcode doesn't use it yet. When that happens, switch |
| 361 // to it. | 381 // to it. |
| 362 | 382 |
| 363 #define IPC_MESSAGE_CONTROL0(msg_class) \ | 383 #define IPC_MESSAGE_CONTROL0(msg_class) \ |
| 364 class msg_class : public IPC::Message { \ | 384 class msg_class : public IPC::Message { \ |
| 365 public: \ | 385 public: \ |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 } \ | 1256 } \ |
| 1237 } | 1257 } |
| 1238 | 1258 |
| 1239 #define IPC_END_MESSAGE_MAP_EX() \ | 1259 #define IPC_END_MESSAGE_MAP_EX() \ |
| 1240 } \ | 1260 } \ |
| 1241 } | 1261 } |
| 1242 | 1262 |
| 1243 // This corresponds to an enum value from IPCMessageStart. | 1263 // This corresponds to an enum value from IPCMessageStart. |
| 1244 #define IPC_MESSAGE_CLASS(message) \ | 1264 #define IPC_MESSAGE_CLASS(message) \ |
| 1245 message.type() >> 16 | 1265 message.type() >> 16 |
| 1266 |
| 1267 #endif // IPC_IPC_MESSAGE_MACROS_H_ |
| 1268 |
| 1269 |
| 1270 // Clean up IPC_MESSAGE_START in this unguarded section. |
| 1271 #undef IPC_MESSAGE_START |
| OLD | NEW |