diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-21 16:04:50 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-21 16:04:50 +0000 |
commit | 7de8404f117520baf2d45cf248c5450fecbb051f (patch) | |
tree | d59b102f318edc94c06e44201696578ebc05a966 | |
parent | 0c6601903f547785adadfbed4856b4fc039d5599 (diff) | |
download | chromium_src-7de8404f117520baf2d45cf248c5450fecbb051f.zip chromium_src-7de8404f117520baf2d45cf248c5450fecbb051f.tar.gz chromium_src-7de8404f117520baf2d45cf248c5450fecbb051f.tar.bz2 |
Make IPC_MESSAGE_EXPORT more robust.
Currently, files that want to export ipc messages currently do
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
at the top, and files that don't want to export ipc messages just do nothing. This is problematic if a cc file does
#include "exported_messages.h"
#include "not_exported_messages.h"
because the second header file picks up the #define from the first file and declares all its messages as exported. In other translation units, where not_exported_messages.h is #included without another header above it, the messages will get default visibility – so the same class ends up with different visibilities in different translation units.
Instead, let ipc_message_macros.h #undef IPC_MESSAGE_EXPORT outside of the include guard, so that all files that don't set the define see it as defined to nothing. (Idea from jam@)
Also disable about:ipc in the component build, since ipc logging adds a dependency from chrome on all ipc message classes, so they would all have to be exported.
BUG=90078
TEST=No linker errors about IPC messages when doing components build on mac. (Other linker errors remain for now.)
TBR=brettw
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=122689
Review URL: http://codereview.chromium.org/9425006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122828 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/common/intents_messages.h | 5 | ||||
-rw-r--r-- | content/common/media/audio_messages.h | 3 | ||||
-rw-r--r-- | content/common/media/media_stream_messages.h | 3 | ||||
-rw-r--r-- | content/common/media/video_capture_messages.h | 5 | ||||
-rw-r--r-- | content/common/p2p_messages.h | 5 | ||||
-rw-r--r-- | content/common/socket_stream_messages.h | 5 | ||||
-rw-r--r-- | content/common/utility_messages.h | 5 | ||||
-rw-r--r-- | ipc/ipc_message.h | 7 | ||||
-rw-r--r-- | ipc/ipc_message_macros.h | 15 |
9 files changed, 40 insertions, 13 deletions
diff --git a/content/common/intents_messages.h b/content/common/intents_messages.h index 160a502..c18eb07 100644 --- a/content/common/intents_messages.h +++ b/content/common/intents_messages.h @@ -1,15 +1,18 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // Message definition file, included multiple times, hence no include guard. +#include "content/common/content_export.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_utils.h" #include "ipc/param_traits_macros.h" #include "webkit/glue/web_intent_data.h" #include "webkit/glue/web_intent_reply_data.h" +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START IntentsMsgStart IPC_ENUM_TRAITS(webkit_glue::WebIntentReplyType) diff --git a/content/common/media/audio_messages.h b/content/common/media/audio_messages.h index 43ab347..eb61248 100644 --- a/content/common/media/audio_messages.h +++ b/content/common/media/audio_messages.h @@ -8,11 +8,14 @@ #include "base/basictypes.h" #include "base/shared_memory.h" #include "base/sync_socket.h" +#include "content/common/content_export.h" #include "content/common/media/audio_stream_state.h" #include "ipc/ipc_message_macros.h" #include "media/audio/audio_buffers_state.h" #include "media/audio/audio_parameters.h" +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START AudioMsgStart IPC_ENUM_TRAITS(AudioStreamState) diff --git a/content/common/media/media_stream_messages.h b/content/common/media/media_stream_messages.h index a58e097..75cd1ce 100644 --- a/content/common/media/media_stream_messages.h +++ b/content/common/media/media_stream_messages.h @@ -7,9 +7,12 @@ #include <string> +#include "content/common/content_export.h" #include "content/common/media/media_stream_options.h" #include "ipc/ipc_message_macros.h" +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START MediaStreamMsgStart IPC_ENUM_TRAITS(media_stream::MediaStreamType) diff --git a/content/common/media/video_capture_messages.h b/content/common/media/video_capture_messages.h index 855a7ad..b6748dc 100644 --- a/content/common/media/video_capture_messages.h +++ b/content/common/media/video_capture_messages.h @@ -1,13 +1,16 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. #include "base/shared_memory.h" +#include "content/common/content_export.h" #include "content/common/media/video_capture.h" #include "content/public/common/common_param_traits.h" #include "ipc/ipc_message_macros.h" #include "media/video/capture/video_capture_types.h" +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START VideoCaptureMsgStart IPC_ENUM_TRAITS(video_capture::State) diff --git a/content/common/p2p_messages.h b/content/common/p2p_messages.h index c2593bd..7c847a5 100644 --- a/content/common/p2p_messages.h +++ b/content/common/p2p_messages.h @@ -1,15 +1,18 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // IPC messages for the P2P Transport API. // Multiply-included message file, hence no include guard. +#include "content/common/content_export.h" #include "content/common/p2p_sockets.h" #include "ipc/ipc_message_macros.h" #include "net/base/ip_endpoint.h" #include "net/base/net_util.h" +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START P2PMsgStart IPC_ENUM_TRAITS(content::P2PSocketType) diff --git a/content/common/socket_stream_messages.h b/content/common/socket_stream_messages.h index 50d5ce8..bb599c4 100644 --- a/content/common/socket_stream_messages.h +++ b/content/common/socket_stream_messages.h @@ -1,14 +1,17 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. // Multiply-included message file, hence no include guard. #include <vector> +#include "content/common/content_export.h" #include "googleurl/src/gurl.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_param_traits.h" +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START SocketStreamMsgStart // Web Sockets messages sent from the renderer to the browser. diff --git a/content/common/utility_messages.h b/content/common/utility_messages.h index 6972a55..c336352 100644 --- a/content/common/utility_messages.h +++ b/content/common/utility_messages.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -8,6 +8,7 @@ #include <vector> #include "base/basictypes.h" +#include "content/common/content_export.h" #include "content/common/indexed_db/indexed_db_key.h" #include "content/common/indexed_db/indexed_db_param_traits.h" #include "content/public/common/common_param_traits.h" @@ -15,6 +16,8 @@ #include "ipc/ipc_message_macros.h" #include "webkit/plugins/webplugininfo.h" +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_START UtilityMsgStart //------------------------------------------------------------------------------ diff --git a/ipc/ipc_message.h b/ipc/ipc_message.h index b978cf2..b630432 100644 --- a/ipc/ipc_message.h +++ b/ipc/ipc_message.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -12,7 +12,10 @@ #include "base/pickle.h" #include "ipc/ipc_export.h" -#ifndef NDEBUG +// Ipc logging adds a dependency from the 'chrome' target on all ipc message +// classes. In a component build, this would require exporting all message +// classes, so don't support ipc logging in the components build. +#if !defined(NDEBUG) && !defined(COMPONENT_BUILD) #define IPC_MESSAGE_LOG_ENABLED #endif diff --git a/ipc/ipc_message_macros.h b/ipc/ipc_message_macros.h index 783108e..f37c05b 100644 --- a/ipc/ipc_message_macros.h +++ b/ipc/ipc_message_macros.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -173,6 +173,14 @@ // ViewHostMsg_SyncMessageName::WriteReplyParams(reply_msg, out1, out2); // Send(reply_msg); +// Files that want to export their ipc messages should do +// #undef IPC_MESSAGE_EXPORT +// #define IPC_MESSAGE_EXPORT VISIBILITY_MACRO +// after including this header, but before using any of the macros below. +// (This needs to be before the include guard.) +#undef IPC_MESSAGE_EXPORT +#define IPC_MESSAGE_EXPORT + #ifndef IPC_IPC_MESSAGE_MACROS_H_ #define IPC_IPC_MESSAGE_MACROS_H_ @@ -184,11 +192,6 @@ #include "ipc/ipc_message_utils_impl.h" #endif -// Override this to force message classes to be exported. -#ifndef IPC_MESSAGE_EXPORT -#define IPC_MESSAGE_EXPORT -#endif - // Macros for defining structs. May be subsequently redefined. #define IPC_STRUCT_BEGIN(struct_name) \ IPC_STRUCT_BEGIN_WITH_PARENT(struct_name, IPC::NoParams) |