From 041528ae6e6abe67ac2f5c14cd4991b8e181ecf2 Mon Sep 17 00:00:00 2001 From: davidsz Date: Fri, 12 May 2017 02:19:23 -0700 Subject: [PATCH] Reland "Add enable_ipc_logging build argument" It caused a build flake due to incorrect dependents on //ipc and it was reverted. Fixes committed in order to fix these: - https://codereview.chromium.org/2767193005 - https://codereview.chromium.org/2852273002 > Implement a build option to enable the IPC logging system > in release builds. It's useful to save time and resources when > debugging IPC communication (e.g. in automated testing > environments). > > It also turns IPC_MESSAGE_LOG_ENABLED macro to a build flag. BUG= Review-Url: https://codereview.chromium.org/2847003005 Cr-Commit-Position: refs/heads/master@{#471255} --- chrome/common/logging_chrome.cc | 5 +++-- chrome/service/service_ipc_server.cc | 4 ++-- content/browser/browser_ipc_logging.cc | 4 ++-- .../renderer_host/render_process_host_impl.cc | 2 +- content/child/child_thread_impl.cc | 10 +++++----- content/child/child_thread_impl.h | 4 ++-- content/common/child_process_host_impl.cc | 6 +++--- content/common/child_process_messages.h | 3 ++- content/common/content_ipc_logging.cc | 10 ++++------ content/public/browser/browser_ipc_logging.h | 4 ++-- content/public/common/content_ipc_logging.h | 4 +--- content/shell/app/shell_main_delegate.cc | 6 +++--- ipc/BUILD.gn | 13 +++++++++++++ ipc/ipc_channel_nacl.cc | 4 ++-- ipc/ipc_channel_proxy.cc | 10 +++++----- ipc/ipc_channel_reader.cc | 4 ++-- ipc/ipc_logging.cc | 6 +++--- ipc/ipc_logging.h | 10 +++++----- ipc/ipc_message.cc | 6 +++--- ipc/ipc_message.h | 9 +++------ ipc/ipc_message_utils.h | 2 +- ipc/ipc_sync_channel.cc | 2 +- ppapi/nacl_irt/irt_ppapi.cc | 4 ---- 23 files changed, 68 insertions(+), 64 deletions(-) diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index 6a5d7f88ee0674..4e2df8c8efdf47 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc @@ -8,13 +8,13 @@ // IPC_MESSAGE_LOG_ENABLED. We need to use it to define // IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the // ViewMsgLog et al. functions. -#include "ipc/ipc_message.h" +#include "ipc/ipc_features.h" // On Windows, the about:ipc dialog shows IPCs; on POSIX, we hook up a // logger in this file. (We implement about:ipc on Mac but implement // the loggers here anyway). We need to do this real early to be sure // IPC_MESSAGE_MACROS_LOG_ENABLED doesn't get undefined. -#if defined(OS_POSIX) && defined(IPC_MESSAGE_LOG_ENABLED) +#if defined(OS_POSIX) && BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) #define IPC_MESSAGE_MACROS_LOG_ENABLED #include "content/public/common/content_ipc_logging.h" #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \ @@ -33,6 +33,7 @@ #include // NOLINT #include "base/base_switches.h" +#include "base/bind.h" #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/debug/debugger.h" diff --git a/chrome/service/service_ipc_server.cc b/chrome/service/service_ipc_server.cc index b8e81ea3838f3b..9514bd803f17a3 100644 --- a/chrome/service/service_ipc_server.cc +++ b/chrome/service/service_ipc_server.cc @@ -24,7 +24,7 @@ ServiceIPCServer::ServiceIPCServer( } bool ServiceIPCServer::Init() { -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) IPC::Logging::GetInstance()->SetIPCSender(this); #endif CreateChannel(); @@ -41,7 +41,7 @@ void ServiceIPCServer::CreateChannel() { } ServiceIPCServer::~ServiceIPCServer() { -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) IPC::Logging::GetInstance()->SetIPCSender(NULL); #endif } diff --git a/content/browser/browser_ipc_logging.cc b/content/browser/browser_ipc_logging.cc index 7e7f05e1b70a5b..ad323632980ebb 100644 --- a/content/browser/browser_ipc_logging.cc +++ b/content/browser/browser_ipc_logging.cc @@ -13,7 +13,7 @@ namespace content { -#if defined(IPC_MESSAGE_LOG_ENABLED) +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) void EnableIPCLoggingForChildProcesses(bool enabled) { DCHECK_CURRENTLY_ON(BrowserThread::IO); @@ -46,6 +46,6 @@ void EnableIPCLogging(bool enable) { i.GetCurrentValue()->Send(new ChildProcessMsg_SetIPCLoggingEnabled(enable)); } -#endif // IPC_MESSAGE_LOG_ENABLED +#endif // BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) } // namespace content diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 5dd6c0749f4c1c..b6f34a59bde12a 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -2210,7 +2210,7 @@ void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { observer.RenderProcessReady(this); } -#if defined(IPC_MESSAGE_LOG_ENABLED) +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) Send(new ChildProcessMsg_SetIPCLoggingEnabled( IPC::Logging::GetInstance()->Enabled())); #endif diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc index 7968a5a03d1943..7bb4984c7fd974 100644 --- a/content/child/child_thread_impl.cc +++ b/content/child/child_thread_impl.cc @@ -420,7 +420,7 @@ void ChildThreadImpl::Init(const Options& options) { g_lazy_tls.Pointer()->Set(this); on_channel_error_called_ = false; message_loop_ = base::MessageLoop::current(); -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) // We must make sure to instantiate the IPC Logger *before* we create the // channel, otherwise we can get a callback on the IO thread which creates // the logger, and the logger does not like being created on the IO thread. @@ -430,7 +430,7 @@ void ChildThreadImpl::Init(const Options& options) { channel_ = IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), ChildProcess::current()->GetShutDownEvent()); -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) if (!IsInBrowserProcess()) IPC::Logging::GetInstance()->SetIPCSender(this); #endif @@ -565,7 +565,7 @@ void ChildThreadImpl::Init(const Options& options) { } ChildThreadImpl::~ChildThreadImpl() { -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) IPC::Logging::GetInstance()->SetIPCSender(NULL); #endif @@ -691,7 +691,7 @@ bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ChildThreadImpl, msg) IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) -#if defined(IPC_MESSAGE_LOG_ENABLED) +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, OnSetIPCLoggingEnabled) #endif @@ -758,7 +758,7 @@ void ChildThreadImpl::OnShutdown() { base::MessageLoop::current()->QuitWhenIdle(); } -#if defined(IPC_MESSAGE_LOG_ENABLED) +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) void ChildThreadImpl::OnSetIPCLoggingEnabled(bool enable) { if (enable) IPC::Logging::GetInstance()->Enable(); diff --git a/content/child/child_thread_impl.h b/content/child/child_thread_impl.h index bbd8457f206658..e9883a2d747c59 100644 --- a/content/child/child_thread_impl.h +++ b/content/child/child_thread_impl.h @@ -22,7 +22,7 @@ #include "content/common/content_export.h" #include "content/public/child/child_thread.h" #include "ipc/ipc.mojom.h" -#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. +#include "ipc/ipc_features.h" // For BUILDFLAG(IPC_MESSAGE_LOG_ENABLED). #include "ipc/ipc_platform_file.h" #include "ipc/message_router.h" #include "mojo/public/cpp/bindings/associated_binding.h" @@ -219,7 +219,7 @@ class CONTENT_EXPORT ChildThreadImpl void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); void OnGetChildProfilerData(int sequence_number, int current_profiling_phase); void OnProfilingPhaseCompleted(int profiling_phase); -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) void OnSetIPCLoggingEnabled(bool enable); #endif diff --git a/content/common/child_process_host_impl.cc b/content/common/child_process_host_impl.cc index 0b19388a1740d2..f04743b9516b76 100644 --- a/content/common/child_process_host_impl.cc +++ b/content/common/child_process_host_impl.cc @@ -157,7 +157,7 @@ bool ChildProcessHostImpl::InitChannel() { delegate_->OnChannelInitialized(channel_.get()); // Make sure these messages get sent first. -#if defined(IPC_MESSAGE_LOG_ENABLED) +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) bool enabled = IPC::Logging::GetInstance()->Enabled(); Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled)); #endif @@ -213,7 +213,7 @@ uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( } bool ChildProcessHostImpl::OnMessageReceived(const IPC::Message& msg) { -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) IPC::Logging* logger = IPC::Logging::GetInstance(); if (msg.type() == IPC_LOGGING_ID) { logger->OnReceivedLoggingMessage(msg); @@ -244,7 +244,7 @@ bool ChildProcessHostImpl::OnMessageReceived(const IPC::Message& msg) { handled = delegate_->OnMessageReceived(msg); } -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) if (logger->Enabled()) logger->OnPostDispatchMessage(msg); #endif diff --git a/content/common/child_process_messages.h b/content/common/child_process_messages.h index 8c7151c567dddc..ea71aa7696000e 100644 --- a/content/common/child_process_messages.h +++ b/content/common/child_process_messages.h @@ -20,6 +20,7 @@ #include "gpu/command_buffer/common/sync_token.h" #include "gpu/ipc/common/gpu_param_traits_macros.h" #include "ipc/ipc_channel_handle.h" +#include "ipc/ipc_features.h" #include "ipc/ipc_message_macros.h" #include "ipc/ipc_platform_file.h" #include "ui/gfx/gpu_memory_buffer.h" @@ -91,7 +92,7 @@ IPC_ENUM_TRAITS_MAX_VALUE(base::ThreadPriority, // process that it's safe to shutdown. IPC_MESSAGE_CONTROL0(ChildProcessMsg_Shutdown) -#if defined(IPC_MESSAGE_LOG_ENABLED) +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) // Tell the child process to begin or end IPC message logging. IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetIPCLoggingEnabled, bool /* on or off */) diff --git a/content/common/content_ipc_logging.cc b/content/common/content_ipc_logging.cc index 2012f07c3ac667..50788e358bcb57 100644 --- a/content/common/content_ipc_logging.cc +++ b/content/common/content_ipc_logging.cc @@ -2,19 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. - #include -#if defined(IPC_MESSAGE_LOG_ENABLED) +#include "ipc/ipc_features.h" + +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) #define IPC_MESSAGE_MACROS_LOG_ENABLED #include "content/public/common/content_ipc_logging.h" #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \ content::RegisterIPCLogger(msg_id, logger) #include "content/common/all_messages.h" -#endif -#if defined(IPC_MESSAGE_LOG_ENABLED) #include "base/containers/hash_tables.h" #include "base/lazy_instance.h" @@ -36,4 +34,4 @@ void RegisterIPCLogger(uint32_t msg_id, LogFunction logger) { } // content -#endif +#endif // BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) diff --git a/content/public/browser/browser_ipc_logging.h b/content/public/browser/browser_ipc_logging.h index f05af129f6b115..bcbd0b171ad2c3 100644 --- a/content/public/browser/browser_ipc_logging.h +++ b/content/public/browser/browser_ipc_logging.h @@ -6,11 +6,11 @@ #define CONTENT_PUBLIC_BROWSER_BROWSER_IPC_LOGGING_H_ #include "content/common/content_export.h" -#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. +#include "ipc/ipc_features.h" namespace content { -#if defined(IPC_MESSAGE_LOG_ENABLED) +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) // Enable or disable IPC logging for the browser, all processes // derived from ChildProcess (plugin etc), and all diff --git a/content/public/common/content_ipc_logging.h b/content/public/common/content_ipc_logging.h index 4508428a8b3901..e92d672ad734e7 100644 --- a/content/public/common/content_ipc_logging.h +++ b/content/public/common/content_ipc_logging.h @@ -5,8 +5,6 @@ #ifndef CONTENT_PUBLIC_COMMON_CONTENT_IPC_LOGGING_H_ #define CONTENT_PUBLIC_COMMON_CONTENT_IPC_LOGGING_H_ -#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. - #include #include "content/common/content_export.h" @@ -14,7 +12,7 @@ namespace content { -#if defined(IPC_MESSAGE_LOG_ENABLED) +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) // Register a logger for the given IPC message. Use // diff --git a/content/shell/app/shell_main_delegate.cc b/content/shell/app/shell_main_delegate.cc index 18406d3837cb53..55740b36585567 100644 --- a/content/shell/app/shell_main_delegate.cc +++ b/content/shell/app/shell_main_delegate.cc @@ -12,6 +12,7 @@ #include "base/lazy_instance.h" #include "base/logging.h" #include "base/path_service.h" +#include "base/trace_event/trace_log.h" #include "build/build_config.h" #include "cc/base/switches.h" #include "content/common/content_constants_internal.h" @@ -34,6 +35,7 @@ #include "content/shell/renderer/shell_content_renderer_client.h" #include "content/shell/utility/shell_content_utility_client.h" #include "gpu/config/gpu_switches.h" +#include "ipc/ipc_features.h" #include "media/base/media_switches.h" #include "media/base/mime_util.h" #include "net/cookies/cookie_monster.h" @@ -45,9 +47,7 @@ #include "ui/gl/gl_implementation.h" #include "ui/gl/gl_switches.h" -#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. - -#if defined(IPC_MESSAGE_LOG_ENABLED) +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) #define IPC_MESSAGE_MACROS_LOG_ENABLED #include "content/public/common/content_ipc_logging.h" #define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \ diff --git a/ipc/BUILD.gn b/ipc/BUILD.gn index 5d023828a1e596..95f35f38d80a22 100644 --- a/ipc/BUILD.gn +++ b/ipc/BUILD.gn @@ -2,11 +2,23 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//build/buildflag_header.gni") import("//build/config/nacl/config.gni") import("//mojo/public/tools/bindings/mojom.gni") import("//testing/test.gni") import("//tools/ipc_fuzzer/ipc_fuzzer.gni") +declare_args() { + # Enabling debug builds automatically sets enable_ipc_logging to true. + enable_ipc_logging = is_debug +} + +buildflag_header("ipc_features") { + header = "ipc_features.h" + + flags = [ "IPC_MESSAGE_LOG_ENABLED=$enable_ipc_logging" ] +} + component("ipc") { sources = [ "export_template.h", @@ -96,6 +108,7 @@ component("ipc") { defines = [ "IPC_IMPLEMENTATION" ] public_deps = [ + ":ipc_features", ":mojom", ":param_traits", "//mojo/public/cpp/bindings", diff --git a/ipc/ipc_channel_nacl.cc b/ipc/ipc_channel_nacl.cc index 17b680ed37afcd..b95f8cb5453f74 100644 --- a/ipc/ipc_channel_nacl.cc +++ b/ipc/ipc_channel_nacl.cc @@ -199,9 +199,9 @@ bool ChannelNacl::Send(Message* message) { << " with type " << message->type(); std::unique_ptr message_ptr(message); -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) Logging::GetInstance()->OnSendMessage(message_ptr.get()); -#endif // IPC_MESSAGE_LOG_ENABLED +#endif // BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"), "ChannelNacl::Send", diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc index ef1c0b2272511d..1c3de84cdd1e5f 100644 --- a/ipc/ipc_channel_proxy.cc +++ b/ipc/ipc_channel_proxy.cc @@ -78,7 +78,7 @@ void ChannelProxy::Context::CreateChannel( bool ChannelProxy::Context::TryFilters(const Message& message) { DCHECK(message_filter_router_); -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) Logging* logger = Logging::GetInstance(); if (logger->Enabled()) logger->OnPreDispatchMessage(message); @@ -89,7 +89,7 @@ bool ChannelProxy::Context::TryFilters(const Message& message) { listener_task_runner_->PostTask( FROM_HERE, base::Bind(&Context::OnDispatchBadMessage, this, message)); } -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) if (logger->Enabled()) logger->OnPostDispatchMessage(message); #endif @@ -315,7 +315,7 @@ void ChannelProxy::Context::OnDispatchMessage(const Message& message) { OnDispatchConnected(); -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) Logging* logger = Logging::GetInstance(); if (message.type() == IPC_LOGGING_ID) { logger->OnReceivedLoggingMessage(message); @@ -330,7 +330,7 @@ void ChannelProxy::Context::OnDispatchMessage(const Message& message) { if (message.dispatch_error()) listener_->OnBadMessageReceived(message); -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) if (logger->Enabled()) logger->OnPostDispatchMessage(message); #endif @@ -530,7 +530,7 @@ bool ChannelProxy::Send(Message* message) { message = outgoing_message_filter()->Rewrite(message); #endif -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) Logging::GetInstance()->OnSendMessage(message); #endif diff --git a/ipc/ipc_channel_reader.cc b/ipc/ipc_channel_reader.cc index fa26734c314c8a..e999028a6f3b6e 100644 --- a/ipc/ipc_channel_reader.cc +++ b/ipc/ipc_channel_reader.cc @@ -20,7 +20,7 @@ namespace IPC { namespace internal { -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) namespace { std::string GetMessageText(const Message& message) { @@ -42,7 +42,7 @@ std::string GetMessageText(const Message& message) { (message).flags(), TRACE_EVENT_FLAG_FLOW_IN, "class", \ IPC_MESSAGE_ID_CLASS((message).type()), "line", \ IPC_MESSAGE_ID_LINE((message).type())); -#endif // IPC_MESSAGE_LOG_ENABLED +#endif // BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) ChannelReader::ChannelReader(Listener* listener) : listener_(listener), diff --git a/ipc/ipc_logging.cc b/ipc/ipc_logging.cc index af532cd318e7b8..aad1b73326ae32 100644 --- a/ipc/ipc_logging.cc +++ b/ipc/ipc_logging.cc @@ -4,7 +4,7 @@ #include "ipc/ipc_logging.h" -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) #define IPC_MESSAGE_MACROS_LOG_ENABLED #endif @@ -31,7 +31,7 @@ #include #endif -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) using base::Time; @@ -310,4 +310,4 @@ void GenerateLogData(const Message& message, LogData* data, bool get_params) { } -#endif // IPC_MESSAGE_LOG_ENABLED +#endif // BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) diff --git a/ipc/ipc_logging.h b/ipc/ipc_logging.h index af490f0c91e7fc..929f55e50a9c8e 100644 --- a/ipc/ipc_logging.h +++ b/ipc/ipc_logging.h @@ -5,12 +5,11 @@ #ifndef IPC_IPC_LOGGING_H_ #define IPC_IPC_LOGGING_H_ -#include - -#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. +#include "ipc/ipc_features.h" -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) +#include #include #include "base/containers/hash_tables.h" @@ -18,6 +17,7 @@ #include "base/memory/singleton.h" #include "base/single_thread_task_runner.h" #include "ipc/ipc_export.h" +#include "ipc/ipc_message.h" // Logging function. |name| is a string in ASCII and |params| is a string in // UTF-8. @@ -123,6 +123,6 @@ class IPC_EXPORT Logging { } // namespace IPC -#endif // IPC_MESSAGE_LOG_ENABLED +#endif // BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) #endif // IPC_IPC_LOGGING_H_ diff --git a/ipc/ipc_message.cc b/ipc/ipc_message.cc index f5e9ac7a8b807c..f66b4fe882c60a 100644 --- a/ipc/ipc_message.cc +++ b/ipc/ipc_message.cc @@ -82,7 +82,7 @@ Message::Message(const Message& other) : base::Pickle(other) { void Message::Init() { dispatch_error_ = false; -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) received_time_ = 0; dont_log_ = false; log_data_ = NULL; @@ -109,7 +109,7 @@ void Message::EnsureMessageAttachmentSet() { attachment_set_ = new MessageAttachmentSet; } -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) void Message::set_sent_time(int64_t time) { DCHECK((header()->flags & HAS_SENT_TIME_BIT) == 0); header()->flags |= HAS_SENT_TIME_BIT; @@ -128,7 +128,7 @@ int64_t Message::sent_time() const { void Message::set_received_time(int64_t time) const { received_time_ = time; } -#endif +#endif // BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) Message::NextMessageInfo::NextMessageInfo() : message_size(0), message_found(false), pickle_end(nullptr), diff --git a/ipc/ipc_message.h b/ipc/ipc_message.h index 43e9ae39c13d96..3ca75482b189bb 100644 --- a/ipc/ipc_message.h +++ b/ipc/ipc_message.h @@ -16,10 +16,7 @@ #include "base/trace_event/trace_event.h" #include "build/build_config.h" #include "ipc/ipc_export.h" - -#if !defined(NDEBUG) -#define IPC_MESSAGE_LOG_ENABLED -#endif +#include "ipc/ipc_features.h" namespace IPC { @@ -207,7 +204,7 @@ class IPC_EXPORT Message : public base::Pickle { // Returns true if there are any attachment in this message. bool HasAttachments() const override; -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) // Adds the outgoing time from Time::Now() at the end of the message and sets // a bit to indicate that it's been added. void set_sent_time(int64_t time); @@ -275,7 +272,7 @@ class IPC_EXPORT Message : public base::Pickle { return attachment_set_.get(); } -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) // Used for logging. mutable int64_t received_time_; mutable std::string output_params_; diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index dd6755e04a0edf..84324ebaf417f5 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -1160,7 +1160,7 @@ IPC_EXPORT void GenerateLogData(const Message& message, LogData* data, bool get_params); -#if defined(IPC_MESSAGE_LOG_ENABLED) +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) inline void AddOutputParamsToLog(const Message* msg, std::string* l) { const std::string& output_params = msg->output_params(); if (!l->empty() && !output_params.empty()) diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc index e2db7939cada1e..35a70dda347d98 100644 --- a/ipc/ipc_sync_channel.cc +++ b/ipc/ipc_sync_channel.cc @@ -587,7 +587,7 @@ scoped_refptr SyncChannel::CreateSyncMessageFilter() { } bool SyncChannel::Send(Message* message) { -#ifdef IPC_MESSAGE_LOG_ENABLED +#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED) std::string name; Logging::GetInstance()->GetMessageText( message->type(), &name, message, nullptr); diff --git a/ppapi/nacl_irt/irt_ppapi.cc b/ppapi/nacl_irt/irt_ppapi.cc index d7ed0690f4a401..b32f83a5b0eff3 100644 --- a/ppapi/nacl_irt/irt_ppapi.cc +++ b/ppapi/nacl_irt/irt_ppapi.cc @@ -3,10 +3,6 @@ // found in the LICENSE file. #include "build/build_config.h" -// Need to include this before most other files because it defines -// IPC_MESSAGE_LOG_ENABLED. We need to use it to define -// IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the -// ViewMsgLog et al. functions. #include