summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-16 21:29:33 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-16 21:29:33 +0000
commite44d13473dd9d81a8d3e1d26f2024be4e4a7c503 (patch)
tree4a66307f49ed83f6de7faba305cd6355a649b355 /ipc
parent51f81dae305d1bdfda139b18be3632f8fbf4959f (diff)
downloadchromium_src-e44d13473dd9d81a8d3e1d26f2024be4e4a7c503.zip
chromium_src-e44d13473dd9d81a8d3e1d26f2024be4e4a7c503.tar.gz
chromium_src-e44d13473dd9d81a8d3e1d26f2024be4e4a7c503.tar.bz2
Remove IPC_BEGIN_MESSAGE_MAP_EX macro since r270839 made all bad IPCs kill their child processes.
R=avi@chromium.org Review URL: https://codereview.chromium.org/292443004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc_fuzzing_tests.cc65
-rw-r--r--ipc/ipc_message_macros.h39
-rw-r--r--ipc/ipc_message_unittest.cc3
3 files changed, 9 insertions, 98 deletions
diff --git a/ipc/ipc_fuzzing_tests.cc b/ipc/ipc_fuzzing_tests.cc
index 3d2d497..1ed9acd 100644
--- a/ipc/ipc_fuzzing_tests.cc
+++ b/ipc/ipc_fuzzing_tests.cc
@@ -345,69 +345,4 @@ TEST_F(IPCFuzzingTest, MsgBadPayloadArgs) {
DestroyChannel();
}
-// This class is for testing the IPC_BEGIN_MESSAGE_MAP_EX macros.
-class ServerMacroExTest {
- public:
- ServerMacroExTest() : unhandled_msgs_(0) {
- }
-
- virtual ~ServerMacroExTest() {
- }
-
- virtual bool OnMessageReceived(const IPC::Message& msg) {
- bool msg_is_ok = false;
- IPC_BEGIN_MESSAGE_MAP_EX(ServerMacroExTest, msg, msg_is_ok)
- IPC_MESSAGE_HANDLER(MsgClassIS, OnMsgClassISMessage)
- IPC_MESSAGE_HANDLER(MsgClassSI, OnMsgClassSIMessage)
- IPC_MESSAGE_UNHANDLED(++unhandled_msgs_)
- IPC_END_MESSAGE_MAP_EX()
- return msg_is_ok;
- }
-
- int unhandled_msgs() const {
- return unhandled_msgs_;
- }
-
- private:
- void OnMsgClassISMessage(int value, const std::wstring& text) {
- }
- void OnMsgClassSIMessage(const std::wstring& text, int value) {
- }
-
- int unhandled_msgs_;
-
- DISALLOW_COPY_AND_ASSIGN(ServerMacroExTest);
-};
-
-TEST_F(IPCFuzzingTest, MsgMapExMacro) {
- IPC::Message* msg = NULL;
- ServerMacroExTest server;
-
- // Test the regular messages.
- msg = new MsgClassIS(3, L"text3");
- EXPECT_TRUE(server.OnMessageReceived(*msg));
- delete msg;
- msg = new MsgClassSI(L"text2", 2);
- EXPECT_TRUE(server.OnMessageReceived(*msg));
- delete msg;
-
-#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
- // Test a bad message.
- msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassSI::ID,
- IPC::Message::PRIORITY_NORMAL);
- msg->WriteInt(2);
- EXPECT_FALSE(server.OnMessageReceived(*msg));
- delete msg;
-
- msg = new IPC::Message(MSG_ROUTING_CONTROL, MsgClassIS::ID,
- IPC::Message::PRIORITY_NORMAL);
- msg->WriteInt(0x64);
- msg->WriteInt(0x32);
- EXPECT_FALSE(server.OnMessageReceived(*msg));
- delete msg;
-
- EXPECT_EQ(0, server.unhandled_msgs());
-#endif
-}
-
} // namespace
diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h
index 5bc1ad4..38aa740 100644
--- a/ipc/ipc_message_macros.h
+++ b/ipc/ipc_message_macros.h
@@ -876,40 +876,25 @@
#define IPC_MESSAGE_ID_CLASS(id) ((id) >> 16)
#define IPC_MESSAGE_ID_LINE(id) ((id) & 0xffff)
-// Message crackers and handlers.
-// Prefer to use the IPC_BEGIN_MESSAGE_MAP_EX to the older macros since they
-// allow you to detect when a message could not be de-serialized. Usage:
+// Message crackers and handlers. Usage:
//
// bool MyClass::OnMessageReceived(const IPC::Message& msg) {
// bool handled = true;
-// bool msg_is_good = false;
-// IPC_BEGIN_MESSAGE_MAP_EX(MyClass, msg, msg_is_good)
+// IPC_BEGIN_MESSAGE_MAP(MyClass, msg)
// IPC_MESSAGE_HANDLER(MsgClassOne, OnMsgClassOne)
// ...more handlers here ...
// IPC_MESSAGE_HANDLER(MsgClassTen, OnMsgClassTen)
// IPC_MESSAGE_UNHANDLED(handled = false)
-// IPC_END_MESSAGE_MAP_EX()
-// if (!msg_is_good) {
-// // Signal error here or terminate offending process.
-// }
+// IPC_END_MESSAGE_MAP()
// return handled;
// }
-#define IPC_BEGIN_MESSAGE_MAP_EX(class_name, msg, msg_is_ok) \
- { \
- typedef class_name _IpcMessageHandlerClass; \
- void* param__ = NULL; \
- const IPC::Message& ipc_message__ = msg; \
- bool& msg_is_ok__ = msg_is_ok; \
- switch (ipc_message__.type()) {
-
#define IPC_BEGIN_MESSAGE_MAP(class_name, msg) \
{ \
typedef class_name _IpcMessageHandlerClass; \
void* param__ = NULL; \
const IPC::Message& ipc_message__ = msg; \
- bool msg_is_ok__ = true; \
switch (ipc_message__.type()) {
// gcc gives the following error now when using decltype so type typeof there:
@@ -920,20 +905,18 @@
#define IPC_DECLTYPE typeof
#endif
-#define IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(class_name, msg, msg_is_ok, param) \
+#define IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(class_name, msg, param) \
{ \
typedef class_name _IpcMessageHandlerClass; \
IPC_DECLTYPE(param) param__ = param; \
const IPC::Message& ipc_message__ = msg; \
- bool& msg_is_ok__ = msg_is_ok; \
switch (ipc_message__.type()) {
#define IPC_MESSAGE_FORWARD(msg_class, obj, member_func) \
case msg_class::ID: { \
TRACK_RUN_IN_IPC_HANDLER(member_func); \
- msg_is_ok__ = msg_class::Dispatch(&ipc_message__, obj, this, \
- param__, &member_func); \
- if (!msg_is_ok__) \
+ if (!msg_class::Dispatch(&ipc_message__, obj, this, param__, \
+ &member_func)) \
ipc_message__.set_dispatch_error(); \
} \
break;
@@ -944,9 +927,8 @@
#define IPC_MESSAGE_FORWARD_DELAY_REPLY(msg_class, obj, member_func) \
case msg_class::ID: { \
TRACK_RUN_IN_IPC_HANDLER(member_func); \
- msg_is_ok__ = msg_class::DispatchDelayReply(&ipc_message__, obj, \
- param__, &member_func); \
- if (!msg_is_ok__) \
+ if (!msg_class::DispatchDelayReply(&ipc_message__, obj, param__, \
+ &member_func)) \
ipc_message__.set_dispatch_error(); \
} \
break;
@@ -984,11 +966,6 @@
#define IPC_END_MESSAGE_MAP() \
} \
- DCHECK(msg_is_ok__); \
-}
-
-#define IPC_END_MESSAGE_MAP_EX() \
- } \
}
// This corresponds to an enum value from IPCMessageStart.
diff --git a/ipc/ipc_message_unittest.cc b/ipc/ipc_message_unittest.cc
index 50f4a7b..5b3a78d 100644
--- a/ipc/ipc_message_unittest.cc
+++ b/ipc/ipc_message_unittest.cc
@@ -88,10 +88,9 @@ class IPCMessageParameterTest : public testing::Test {
IPCMessageParameterTest() : extra_param_("extra_param"), called_(false) {}
bool OnMessageReceived(const IPC::Message& message) {
- bool msg_is_ok = true;
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(IPCMessageParameterTest, message,
- msg_is_ok, &extra_param_)
+ &extra_param_)
IPC_MESSAGE_HANDLER(TestMsgClassEmpty, OnEmpty)
IPC_MESSAGE_HANDLER(TestMsgClassI, OnInt)
//IPC_MESSAGE_HANDLER(TestMsgClassIS, OnSync)