summaryrefslogtreecommitdiffstats
path: root/ipc/sync_socket_unittest.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-26 21:27:30 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-26 21:27:30 +0000
commit1d4ecf498386569dfb438f7536b573213bbcaaba (patch)
tree2f05a90aa931e14aac6f9acee38ba471b5e55ea4 /ipc/sync_socket_unittest.cc
parent80f6c7266b94973ce98e96ff743507a750dd7ae0 (diff)
downloadchromium_src-1d4ecf498386569dfb438f7536b573213bbcaaba.zip
chromium_src-1d4ecf498386569dfb438f7536b573213bbcaaba.tar.gz
chromium_src-1d4ecf498386569dfb438f7536b573213bbcaaba.tar.bz2
Add support for exporting IPC messages from component DLLs.
This removes MessageWithTuple and MessageWithReply since it is not easy to export a class that inherits from a template specialization. The functionality of those classes are split now between new classes, MessageSchema and SyncMessageSchema, and being declared inline via macros. The key point is that we want to avoid inlining the constructor and Read functions for messages. That avoids code bloat since those functions contain all of the parameter serialization and deserialization code. Those are the functions that we really want to have contained with component DLLs. To export IPC messages from a DLL, it is necessary to #define IPC_MESSAGE_EXPORT above message declarations. You can see this in action here: http://codereview.chromium.org/7687005/diff/41012/ppapi/proxy/ppapi_messages.h Review URL: http://codereview.chromium.org/7768001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98491 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/sync_socket_unittest.cc')
-rw-r--r--ipc/sync_socket_unittest.cc83
1 files changed, 19 insertions, 64 deletions
diff --git a/ipc/sync_socket_unittest.cc b/ipc/sync_socket_unittest.cc
index 1a4ae13..79cf6c3 100644
--- a/ipc/sync_socket_unittest.cc
+++ b/ipc/sync_socket_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,12 +10,7 @@
#include "base/message_loop.h"
#include "base/process_util.h"
-#include "build/build_config.h"
-#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
-#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_message_utils.h"
-#include "ipc/ipc_message_utils_impl.h"
#include "ipc/ipc_tests.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
@@ -24,74 +19,34 @@
#include "base/file_descriptor_posix.h"
#endif
-enum IPCMessageIds {
- UNUSED_IPC_TYPE,
- SERVER_FIRST_IPC_TYPE, // SetHandle message sent to server.
- SERVER_SECOND_IPC_TYPE, // Shutdown message sent to server.
- CLIENT_FIRST_IPC_TYPE // Response message sent to client.
-};
+// IPC messages for testing ---------------------------------------------------
-namespace {
-const char kHelloString[] = "Hello, SyncSocket Client";
-const size_t kHelloStringLength = arraysize(kHelloString);
-} // namespace
+#define IPC_MESSAGE_IMPL
+#include "ipc/ipc_message_macros.h"
+
+#define IPC_MESSAGE_START TestMsgStart
-// Message class to pass a base::SyncSocket::Handle to another process.
-// This is not as easy as it sounds, because of the differences in transferring
+// Message class to pass a base::SyncSocket::Handle to another process. This
+// is not as easy as it sounds, because of the differences in transferring
// Windows HANDLEs versus posix file descriptors.
#if defined(OS_WIN)
-class MsgClassSetHandle
- : public IPC::MessageWithTuple< Tuple1<base::SyncSocket::Handle> > {
- public:
- enum { ID = SERVER_FIRST_IPC_TYPE };
- explicit MsgClassSetHandle(const base::SyncSocket::Handle arg1)
- : IPC::MessageWithTuple< Tuple1<base::SyncSocket::Handle> >(
- MSG_ROUTING_CONTROL, ID, MakeRefTuple(arg1)) {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MsgClassSetHandle);
-};
+IPC_MESSAGE_CONTROL1(MsgClassSetHandle, base::SyncSocket::Handle)
#elif defined(OS_POSIX)
-class MsgClassSetHandle
- : public IPC::MessageWithTuple< Tuple1<base::FileDescriptor> > {
- public:
- enum { ID = SERVER_FIRST_IPC_TYPE };
- explicit MsgClassSetHandle(const base::FileDescriptor& arg1)
- : IPC::MessageWithTuple< Tuple1<base::FileDescriptor> >(
- MSG_ROUTING_CONTROL, ID, MakeRefTuple(arg1)) {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MsgClassSetHandle);
-};
-#else
-# error "What platform?"
-#endif // defined(OS_WIN)
+IPC_MESSAGE_CONTROL1(MsgClassSetHandle, base::FileDescriptor)
+#endif
// Message class to pass a response to the server.
-class MsgClassResponse
- : public IPC::MessageWithTuple< Tuple1<std::string> > {
- public:
- enum { ID = CLIENT_FIRST_IPC_TYPE };
- explicit MsgClassResponse(const std::string& arg1)
- : IPC::MessageWithTuple< Tuple1<std::string> >(
- MSG_ROUTING_CONTROL, ID, MakeRefTuple(arg1)) {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MsgClassResponse);
-};
+IPC_MESSAGE_CONTROL1(MsgClassResponse, std::string)
// Message class to tell the server to shut down.
-class MsgClassShutdown
- : public IPC::MessageWithTuple< Tuple0 > {
- public:
- enum { ID = SERVER_SECOND_IPC_TYPE };
- MsgClassShutdown()
- : IPC::MessageWithTuple< Tuple0 >(
- MSG_ROUTING_CONTROL, ID, MakeTuple()) {}
+IPC_MESSAGE_CONTROL0(MsgClassShutdown)
- private:
- DISALLOW_COPY_AND_ASSIGN(MsgClassShutdown);
-};
+// ----------------------------------------------------------------------------
+
+namespace {
+const char kHelloString[] = "Hello, SyncSocket Client";
+const size_t kHelloStringLength = arraysize(kHelloString);
+} // namespace
// The SyncSocket server listener class processes two sorts of
// messages from the client.