mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1111810 - Remove Chromium IPC logging on CLOSED TREE. r=bent
This commit is contained in:
parent
c06c8126db
commit
50eacdecf2
@ -66,7 +66,6 @@ UNIFIED_SOURCES += [
|
||||
'src/chrome/common/chrome_switches.cc',
|
||||
'src/chrome/common/env_vars.cc',
|
||||
'src/chrome/common/ipc_channel_proxy.cc',
|
||||
'src/chrome/common/ipc_logging.cc',
|
||||
'src/chrome/common/ipc_message.cc',
|
||||
'src/chrome/common/ipc_sync_channel.cc',
|
||||
'src/chrome/common/ipc_sync_message.cc',
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "mozilla/ipc/BrowserProcessSubThread.h"
|
||||
#include "mozilla/ipc/Transport.h"
|
||||
typedef mozilla::ipc::BrowserProcessSubThread ChromeThread;
|
||||
#include "chrome/common/ipc_logging.h"
|
||||
#include "chrome/common/notification_service.h"
|
||||
#include "chrome/common/notification_type.h"
|
||||
#include "chrome/common/process_watcher.h"
|
||||
@ -156,16 +155,6 @@ ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host)
|
||||
|
||||
void ChildProcessHost::ListenerHook::OnMessageReceived(
|
||||
const IPC::Message& msg) {
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
IPC::Logging* logger = IPC::Logging::current();
|
||||
if (msg.type() == IPC_LOGGING_ID) {
|
||||
logger->OnReceivedLoggingMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (logger->Enabled())
|
||||
logger->OnPreDispatchMessage(msg);
|
||||
#endif
|
||||
|
||||
bool msg_is_ok = true;
|
||||
bool handled = false;
|
||||
@ -177,10 +166,6 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(
|
||||
if (!msg_is_ok)
|
||||
base::KillProcess(host_->handle(), ResultCodes::KILLED_BAD_MESSAGE, false);
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
if (logger->Enabled())
|
||||
logger->OnPostDispatchMessage(msg, host_->channel_id_);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChildProcessHost::ListenerHook::OnChannelConnected(int32_t peer_pid) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "base/command_line.h"
|
||||
#include "chrome/common/child_process.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/ipc_logging.h"
|
||||
|
||||
// V8 needs a 1MB stack size.
|
||||
const size_t ChildThread::kV8StackSize = 1024 * 1024;
|
||||
@ -93,15 +92,9 @@ void ChildThread::Init() {
|
||||
IPC::Channel::MODE_CLIENT,
|
||||
this);
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
IPC::Logging::current()->SetIPCSender(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChildThread::CleanUp() {
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
IPC::Logging::current()->SetIPCSender(NULL);
|
||||
#endif
|
||||
// Need to destruct the SyncChannel to the browser before we go away because
|
||||
// it caches a pointer to this thread.
|
||||
channel_ = nullptr;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "base/singleton.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/file_descriptor_set_posix.h"
|
||||
#include "chrome/common/ipc_logging.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
@ -773,9 +772,6 @@ bool Channel::ChannelImpl::Send(Message* message) {
|
||||
<< " (" << output_queue_.size() << " in queue)";
|
||||
#endif
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
Logging::current()->OnSendMessage(message, L"");
|
||||
#endif
|
||||
|
||||
// If the channel has been closed, ProcessOutgoingMessages() is never going
|
||||
// to pop anything off output_queue; output_queue will only get emptied when
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "base/message_loop.h"
|
||||
#include "base/thread.h"
|
||||
#include "chrome/common/ipc_channel_proxy.h"
|
||||
#include "chrome/common/ipc_logging.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
|
||||
namespace IPC {
|
||||
@ -33,18 +32,9 @@ void ChannelProxy::Context::CreateChannel(const std::wstring& id,
|
||||
}
|
||||
|
||||
bool ChannelProxy::Context::TryFilters(const Message& message) {
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
Logging* logger = Logging::current();
|
||||
if (logger->Enabled())
|
||||
logger->OnPreDispatchMessage(message);
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < filters_.size(); ++i) {
|
||||
if (filters_[i]->OnMessageReceived(message)) {
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
if (logger->Enabled())
|
||||
logger->OnPostDispatchMessage(message, channel_id_);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -168,23 +158,9 @@ void ChannelProxy::Context::OnDispatchMessage(const Message& message) {
|
||||
|
||||
OnDispatchConnected();
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
Logging* logger = Logging::current();
|
||||
if (message.type() == IPC_LOGGING_ID) {
|
||||
logger->OnReceivedLoggingMessage(message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (logger->Enabled())
|
||||
logger->OnPreDispatchMessage(message);
|
||||
#endif
|
||||
|
||||
listener_->OnMessageReceived(message);
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
if (logger->Enabled())
|
||||
logger->OnPostDispatchMessage(message, channel_id_);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Called on the listener's thread
|
||||
@ -263,9 +239,6 @@ void ChannelProxy::Close() {
|
||||
}
|
||||
|
||||
bool ChannelProxy::Send(Message* message) {
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
Logging::current()->OnSendMessage(message, context_->channel_id());
|
||||
#endif
|
||||
|
||||
context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
context_.get(), &Context::OnSendMessage, message));
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/non_thread_safe.h"
|
||||
#include "base/win_util.h"
|
||||
#include "chrome/common/ipc_logging.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
|
||||
@ -131,9 +130,6 @@ bool Channel::ChannelImpl::Send(Message* message) {
|
||||
<< " (" << output_queue_.size() << " in queue)";
|
||||
#endif
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
Logging::current()->OnSendMessage(message, L"");
|
||||
#endif
|
||||
|
||||
if (closed_) {
|
||||
if (mozilla::ipc::LoggingEnabled()) {
|
||||
|
@ -1,306 +0,0 @@
|
||||
// Copyright (c) 2006-2008 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 "chrome/common/ipc_logging.h"
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
// This will cause render_messages.h etc to define ViewMsgLog and friends.
|
||||
#define IPC_MESSAGE_MACROS_LOG_ENABLED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/string_util.h"
|
||||
#include "base/thread.h"
|
||||
#include "base/time.h"
|
||||
#include "base/waitable_event.h"
|
||||
#include "base/waitable_event_watcher.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/ipc_sync_message.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#include "base/string_util.h"
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
|
||||
using base::Time;
|
||||
|
||||
// IPC::Logging is allocated as a singleton, so we don't need any kind of
|
||||
// special retention program.
|
||||
template <>
|
||||
struct RunnableMethodTraits<IPC::Logging> {
|
||||
static void RetainCallee(IPC::Logging*) {}
|
||||
static void ReleaseCallee(IPC::Logging*) {}
|
||||
};
|
||||
|
||||
namespace IPC {
|
||||
|
||||
const wchar_t kLoggingEventName[] = L"ChromeIPCLog.%d";
|
||||
const int kLogSendDelayMs = 100;
|
||||
|
||||
// We use a pointer to the function table to avoid any linker dependencies on
|
||||
// all the traits used as IPC message parameters.
|
||||
Logging::LogFunction *Logging::log_function_mapping_;
|
||||
|
||||
Logging::Logging()
|
||||
: logging_event_on_(NULL),
|
||||
logging_event_off_(NULL),
|
||||
enabled_(false),
|
||||
queue_invoke_later_pending_(false),
|
||||
sender_(NULL),
|
||||
main_thread_(MessageLoop::current()),
|
||||
consumer_(NULL) {
|
||||
// Create an event for this browser instance that's set when logging is
|
||||
// enabled, so child processes can know when logging is enabled.
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// On Windows we have a couple of named events which switch logging on and
|
||||
// off.
|
||||
int browser_pid;
|
||||
const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
|
||||
std::wstring process_type =
|
||||
parsed_command_line.GetSwitchValue(switches::kProcessType);
|
||||
if (process_type.empty()) {
|
||||
browser_pid = GetCurrentProcessId();
|
||||
} else {
|
||||
std::wstring channel_name =
|
||||
parsed_command_line.GetSwitchValue(switches::kProcessChannelID);
|
||||
|
||||
browser_pid = _wtoi(channel_name.c_str());
|
||||
DCHECK(browser_pid != 0);
|
||||
}
|
||||
|
||||
std::wstring event_name = GetEventName(browser_pid, true);
|
||||
logging_event_on_.reset(new base::WaitableEvent(
|
||||
CreateEventW(NULL, TRUE, FALSE, event_name.c_str())));
|
||||
|
||||
event_name = GetEventName(browser_pid, false);
|
||||
logging_event_off_.reset(new base::WaitableEvent(
|
||||
CreateEventW(NULL, TRUE, FALSE, event_name.c_str())));
|
||||
|
||||
RegisterWaitForEvent(true);
|
||||
#endif
|
||||
|
||||
MessageLoop::current()->AddDestructionObserver(this);
|
||||
}
|
||||
|
||||
Logging::~Logging() {
|
||||
}
|
||||
|
||||
Logging* Logging::current() {
|
||||
return Singleton<Logging>::get();
|
||||
}
|
||||
|
||||
void Logging::RegisterWaitForEvent(bool enabled) {
|
||||
watcher_.StopWatching();
|
||||
watcher_.StartWatching(
|
||||
enabled ? logging_event_on_.get() : logging_event_off_.get(), this);
|
||||
}
|
||||
|
||||
void Logging::OnWaitableEventSignaled(base::WaitableEvent* event) {
|
||||
enabled_ = event == logging_event_on_.get();
|
||||
RegisterWaitForEvent(!enabled_);
|
||||
}
|
||||
|
||||
void Logging::WillDestroyCurrentMessageLoop() {
|
||||
watcher_.StopWatching();
|
||||
}
|
||||
|
||||
void Logging::SetLoggerFunctions(LogFunction *functions) {
|
||||
log_function_mapping_ = functions;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
std::wstring Logging::GetEventName(bool enabled) {
|
||||
return current()->GetEventName(GetCurrentProcessId(), enabled);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::wstring Logging::GetEventName(int browser_pid, bool enabled) {
|
||||
std::wstring result = StringPrintf(kLoggingEventName, browser_pid);
|
||||
result += enabled ? L"on" : L"off";
|
||||
return result;
|
||||
}
|
||||
|
||||
void Logging::SetConsumer(Consumer* consumer) {
|
||||
consumer_ = consumer;
|
||||
}
|
||||
|
||||
void Logging::Enable() {
|
||||
logging_event_off_->Reset();
|
||||
logging_event_on_->Signal();
|
||||
}
|
||||
|
||||
void Logging::Disable() {
|
||||
logging_event_on_->Reset();
|
||||
logging_event_off_->Signal();
|
||||
}
|
||||
|
||||
void Logging::OnSendLogs() {
|
||||
queue_invoke_later_pending_ = false;
|
||||
if (!sender_)
|
||||
return;
|
||||
|
||||
Message* msg = new Message(
|
||||
MSG_ROUTING_CONTROL, IPC_LOGGING_ID, Message::PRIORITY_NORMAL);
|
||||
WriteParam(msg, queued_logs_);
|
||||
queued_logs_.clear();
|
||||
sender_->Send(msg);
|
||||
}
|
||||
|
||||
void Logging::SetIPCSender(IPC::Message::Sender* sender) {
|
||||
sender_ = sender;
|
||||
}
|
||||
|
||||
void Logging::OnReceivedLoggingMessage(const Message& message) {
|
||||
std::vector<LogData> data;
|
||||
void* iter = NULL;
|
||||
if (!ReadParam(&message, &iter, &data))
|
||||
return;
|
||||
|
||||
for (size_t i = 0; i < data.size(); ++i) {
|
||||
Log(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Logging::OnSendMessage(Message* message, const std::wstring& channel_id) {
|
||||
if (!Enabled())
|
||||
return;
|
||||
|
||||
if (message->is_reply()) {
|
||||
LogData* data = message->sync_log_data();
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
// This is actually the delayed reply to a sync message. Create a string
|
||||
// of the output parameters, add it to the LogData that was earlier stashed
|
||||
// with the reply, and log the result.
|
||||
data->channel = channel_id;
|
||||
GenerateLogData(L"", *message, data);
|
||||
Log(*data);
|
||||
delete data;
|
||||
message->set_sync_log_data(NULL);
|
||||
} else {
|
||||
// If the time has already been set (i.e. by ChannelProxy), keep that time
|
||||
// instead as it's more accurate.
|
||||
if (!message->sent_time())
|
||||
message->set_sent_time(Time::Now().ToInternalValue());
|
||||
}
|
||||
}
|
||||
|
||||
void Logging::OnPreDispatchMessage(const Message& message) {
|
||||
message.set_received_time(Time::Now().ToInternalValue());
|
||||
}
|
||||
|
||||
void Logging::OnPostDispatchMessage(const Message& message,
|
||||
const std::wstring& channel_id) {
|
||||
if (!Enabled() ||
|
||||
#if defined(OS_WIN)
|
||||
!message.sent_time() ||
|
||||
#endif
|
||||
message.dont_log())
|
||||
return;
|
||||
|
||||
LogData data;
|
||||
GenerateLogData(channel_id, message, &data);
|
||||
|
||||
if (MessageLoop::current() == main_thread_) {
|
||||
Log(data);
|
||||
} else {
|
||||
main_thread_->PostTask(FROM_HERE, NewRunnableMethod(
|
||||
this, &Logging::Log, data));
|
||||
}
|
||||
}
|
||||
|
||||
void Logging::GetMessageText(uint16_t type, std::wstring* name,
|
||||
const Message* message,
|
||||
std::wstring* params) {
|
||||
if (!log_function_mapping_)
|
||||
return;
|
||||
|
||||
int message_class = type >> 12;
|
||||
if (log_function_mapping_[message_class] != NULL) {
|
||||
log_function_mapping_[message_class](type, name, message, params);
|
||||
} else {
|
||||
DLOG(INFO) << "No logger function associated with message class " <<
|
||||
message_class;
|
||||
}
|
||||
}
|
||||
|
||||
void Logging::Log(const LogData& data) {
|
||||
#if defined(OS_WIN)
|
||||
if (consumer_) {
|
||||
// We're in the browser process.
|
||||
consumer_->Log(data);
|
||||
} else {
|
||||
// We're in the renderer or plugin processes.
|
||||
if (sender_) {
|
||||
queued_logs_.push_back(data);
|
||||
if (!queue_invoke_later_pending_) {
|
||||
queue_invoke_later_pending_ = true;
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(
|
||||
this, &Logging::OnSendLogs), kLogSendDelayMs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif defined(OS_POSIX)
|
||||
// On POSIX, for now, we just dump the log to stderr
|
||||
fprintf(stderr, "ipc %s %d %d %s %s %s\n",
|
||||
WideToUTF8(data.channel).c_str(),
|
||||
data.routing_id,
|
||||
data.type,
|
||||
WideToUTF8(data.flags).c_str(),
|
||||
WideToUTF8(data.message_name).c_str(),
|
||||
WideToUTF8(data.params).c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
void GenerateLogData(const std::wstring& channel, const Message& message,
|
||||
LogData* data) {
|
||||
if (message.is_reply()) {
|
||||
// "data" should already be filled in.
|
||||
std::wstring params;
|
||||
Logging::GetMessageText(data->type, NULL, &message, ¶ms);
|
||||
|
||||
if (!data->params.empty() && !params.empty())
|
||||
data->params += L", ";
|
||||
|
||||
data->flags += L" DR";
|
||||
|
||||
data->params += params;
|
||||
} else {
|
||||
std::wstring flags;
|
||||
if (message.is_sync())
|
||||
flags = L"S";
|
||||
|
||||
if (message.is_reply())
|
||||
flags += L"R";
|
||||
|
||||
if (message.is_reply_error())
|
||||
flags += L"E";
|
||||
|
||||
std::wstring params, message_name;
|
||||
Logging::GetMessageText(message.type(), &message_name, &message, ¶ms);
|
||||
|
||||
data->channel = channel;
|
||||
data->routing_id = message.routing_id();
|
||||
data->type = message.type();
|
||||
data->flags = flags;
|
||||
data->sent = message.sent_time();
|
||||
data->receive = message.received_time();
|
||||
data->dispatch = Time::Now().ToInternalValue();
|
||||
data->params = params;
|
||||
data->message_name = message_name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // IPC_MESSAGE_LOG_ENABLED
|
@ -1,114 +0,0 @@
|
||||
// Copyright (c) 2006-2008 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.
|
||||
|
||||
#ifndef CHROME_COMMON_IPC_LOGGING_H_
|
||||
#define CHROME_COMMON_IPC_LOGGING_H_
|
||||
|
||||
#include "chrome/common/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
|
||||
#include "base/lock.h"
|
||||
#include "base/message_loop.h"
|
||||
#include "base/singleton.h"
|
||||
#include "base/waitable_event_watcher.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
class MessageLoop;
|
||||
|
||||
namespace IPC {
|
||||
|
||||
class Message;
|
||||
|
||||
// One instance per process. Needs to be created on the main thread (the UI
|
||||
// thread in the browser) but OnPreDispatchMessage/OnPostDispatchMessage
|
||||
// can be called on other threads.
|
||||
class Logging : public base::WaitableEventWatcher::Delegate,
|
||||
public MessageLoop::DestructionObserver {
|
||||
public:
|
||||
// Implemented by consumers of log messages.
|
||||
class Consumer {
|
||||
public:
|
||||
virtual void Log(const LogData& data) = 0;
|
||||
};
|
||||
|
||||
void SetConsumer(Consumer* consumer);
|
||||
|
||||
~Logging();
|
||||
static Logging* current();
|
||||
|
||||
void Enable();
|
||||
void Disable();
|
||||
bool Enabled() const { return enabled_; }
|
||||
|
||||
// Called by child processes to give the logger object the channel to send
|
||||
// logging data to the browser process.
|
||||
void SetIPCSender(Message::Sender* sender);
|
||||
|
||||
// Called in the browser process when logging data from a child process is
|
||||
// received.
|
||||
void OnReceivedLoggingMessage(const Message& message);
|
||||
|
||||
void OnSendMessage(Message* message, const std::wstring& channel_id);
|
||||
void OnPreDispatchMessage(const Message& message);
|
||||
void OnPostDispatchMessage(const Message& message,
|
||||
const std::wstring& channel_id);
|
||||
|
||||
// Returns the name of the logging enabled/disabled events so that the
|
||||
// sandbox can add them to to the policy. If true, gets the name of the
|
||||
// enabled event, if false, gets the name of the disabled event.
|
||||
static std::wstring GetEventName(bool enabled);
|
||||
|
||||
// Like the *MsgLog functions declared for each message class, except this
|
||||
// calls the correct one based on the message type automatically. Defined in
|
||||
// ipc_logging.cc.
|
||||
static void GetMessageText(uint16_t type, std::wstring* name,
|
||||
const Message* message, std::wstring* params);
|
||||
|
||||
// WaitableEventWatcher::Delegate implementation
|
||||
void OnWaitableEventSignaled(base::WaitableEvent* event);
|
||||
|
||||
// MessageLoop::DestructionObserver implementation
|
||||
void WillDestroyCurrentMessageLoop();
|
||||
|
||||
typedef void (*LogFunction)(uint16_t type,
|
||||
std::wstring* name,
|
||||
const Message* msg,
|
||||
std::wstring* params);
|
||||
|
||||
static void SetLoggerFunctions(LogFunction *functions);
|
||||
|
||||
private:
|
||||
friend struct DefaultSingletonTraits<Logging>;
|
||||
Logging();
|
||||
|
||||
std::wstring GetEventName(int browser_pid, bool enabled);
|
||||
void OnSendLogs();
|
||||
void Log(const LogData& data);
|
||||
|
||||
void RegisterWaitForEvent(bool enabled);
|
||||
|
||||
base::WaitableEventWatcher watcher_;
|
||||
|
||||
mozilla::UniquePtr<base::WaitableEvent> logging_event_on_;
|
||||
mozilla::UniquePtr<base::WaitableEvent> logging_event_off_;
|
||||
bool enabled_;
|
||||
|
||||
std::vector<LogData> queued_logs_;
|
||||
bool queue_invoke_later_pending_;
|
||||
|
||||
Message::Sender* sender_;
|
||||
MessageLoop* main_thread_;
|
||||
|
||||
Consumer* consumer_;
|
||||
|
||||
static LogFunction *log_function_mapping_;
|
||||
};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
#endif // IPC_MESSAGE_LOG_ENABLED
|
||||
|
||||
#endif // CHROME_COMMON_IPC_LOGGING_H_
|
@ -96,11 +96,6 @@ Message::Message(Message&& other) : Pickle(mozilla::Move(other)) {
|
||||
|
||||
void Message::InitLoggingVariables(const char* const name) {
|
||||
name_ = name;
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
received_time_ = 0;
|
||||
dont_log_ = false;
|
||||
log_data_ = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
Message& Message::operator=(const Message& other) {
|
||||
@ -131,26 +126,6 @@ Message& Message::operator=(Message&& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef 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;
|
||||
WriteInt64(time);
|
||||
}
|
||||
|
||||
int64_t Message::sent_time() const {
|
||||
if ((header()->flags & HAS_SENT_TIME_BIT) == 0)
|
||||
return 0;
|
||||
|
||||
const char* data = end_of_payload();
|
||||
data -= sizeof(int64_t);
|
||||
return *(reinterpret_cast<const int64_t*>(data));
|
||||
}
|
||||
|
||||
void Message::set_received_time(int64_t time) const {
|
||||
received_time_ = time;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
bool Message::WriteFileDescriptor(const base::FileDescriptor& descriptor) {
|
||||
|
@ -14,10 +14,6 @@
|
||||
#include "GeckoTaskTracer.h"
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define IPC_MESSAGE_LOG_ENABLED
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
#include "nsAutoPtr.h"
|
||||
#endif
|
||||
@ -261,25 +257,6 @@ class Message : public Pickle {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef 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);
|
||||
int64_t sent_time() const;
|
||||
|
||||
void set_received_time(int64_t time) const;
|
||||
int64_t received_time() const { return received_time_; }
|
||||
void set_output_params(const std::wstring& op) const { output_params_ = op; }
|
||||
const std::wstring& output_params() const { return output_params_; }
|
||||
// The following four functions are needed so we can log sync messages with
|
||||
// delayed replies. We stick the log data from the sent message into the
|
||||
// reply message, so that when it's sent and we have the output parameters
|
||||
// we can log it. As such, we set a flag on the sent message to not log it.
|
||||
void set_sync_log_data(LogData* data) const { log_data_ = data; }
|
||||
LogData* sync_log_data() const { return log_data_; }
|
||||
void set_dont_log() const { dont_log_ = true; }
|
||||
bool dont_log() const { return dont_log_; }
|
||||
#endif
|
||||
|
||||
friend class Channel;
|
||||
friend class MessageReplyDeserializer;
|
||||
@ -365,13 +342,6 @@ class Message : public Pickle {
|
||||
|
||||
const char* name_;
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
// Used for logging.
|
||||
mutable int64_t received_time_;
|
||||
mutable std::wstring output_params_;
|
||||
mutable LogData* log_data_;
|
||||
mutable bool dont_log_;
|
||||
#endif
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -732,52 +732,6 @@ struct ParamTraitsIPC<FilePath> {
|
||||
static void Log(const param_type& p, std::wstring* l);
|
||||
};
|
||||
|
||||
struct LogData {
|
||||
std::wstring channel;
|
||||
int32_t routing_id;
|
||||
uint16_t type;
|
||||
std::wstring flags;
|
||||
int64_t sent; // Time that the message was sent (i.e. at Send()).
|
||||
int64_t receive; // Time before it was dispatched (i.e. before calling
|
||||
// OnMessageReceived).
|
||||
int64_t dispatch; // Time after it was dispatched (i.e. after calling
|
||||
// OnMessageReceived).
|
||||
std::wstring message_name;
|
||||
std::wstring params;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraitsIPC<LogData> {
|
||||
typedef LogData param_type;
|
||||
static void Write(Message* m, const param_type& p) {
|
||||
WriteParam(m, p.channel);
|
||||
WriteParam(m, p.routing_id);
|
||||
WriteParam(m, static_cast<int>(p.type));
|
||||
WriteParam(m, p.flags);
|
||||
WriteParam(m, p.sent);
|
||||
WriteParam(m, p.receive);
|
||||
WriteParam(m, p.dispatch);
|
||||
WriteParam(m, p.params);
|
||||
}
|
||||
static bool Read(const Message* m, void** iter, param_type* r) {
|
||||
int type = 0;
|
||||
bool result =
|
||||
ReadParam(m, iter, &r->channel) &&
|
||||
ReadParam(m, iter, &r->routing_id) &&
|
||||
ReadParam(m, iter, &type) &&
|
||||
ReadParam(m, iter, &r->flags) &&
|
||||
ReadParam(m, iter, &r->sent) &&
|
||||
ReadParam(m, iter, &r->receive) &&
|
||||
ReadParam(m, iter, &r->dispatch) &&
|
||||
ReadParam(m, iter, &r->params);
|
||||
r->type = static_cast<uint16_t>(type);
|
||||
return result;
|
||||
}
|
||||
static void Log(const param_type& p, std::wstring* l) {
|
||||
// Doesn't make sense to implement this!
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(OS_WIN)
|
||||
template<>
|
||||
struct ParamTraitsIPC<TransportDIB::Id> {
|
||||
@ -1195,10 +1149,6 @@ class ParamDeserializer : public MessageReplyDeserializer {
|
||||
RefTuple out_;
|
||||
};
|
||||
|
||||
// defined in ipc_logging.cc
|
||||
void GenerateLogData(const std::wstring& channel, const Message& message,
|
||||
LogData* data);
|
||||
|
||||
// Used for synchronous messages.
|
||||
template <class SendParamType, class ReplyParamType>
|
||||
class MessageWithReply : public SyncMessage {
|
||||
@ -1220,13 +1170,6 @@ class MessageWithReply : public SyncMessage {
|
||||
if (ReadParam(msg, &iter, &p))
|
||||
LogParam(p, l);
|
||||
|
||||
#if defined(IPC_MESSAGE_LOG_ENABLED)
|
||||
const std::wstring& output_params = msg->output_params();
|
||||
if (!l->empty() && !output_params.empty())
|
||||
l->append(L", ");
|
||||
|
||||
l->append(output_params);
|
||||
#endif
|
||||
} else {
|
||||
// This is an outgoing reply. Now that we have the output parameters, we
|
||||
// can finally log the message.
|
||||
@ -1248,13 +1191,6 @@ class MessageWithReply : public SyncMessage {
|
||||
DispatchToMethod(obj, func, send_params, &reply_params);
|
||||
WriteParam(reply, reply_params);
|
||||
error = false;
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
if (msg->received_time() != 0) {
|
||||
std::wstring output_params;
|
||||
LogParam(reply_params, &output_params);
|
||||
msg->set_output_params(output_params);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
NOTREACHED() << "Error deserializing message " << msg->type();
|
||||
reply->set_reply_error();
|
||||
@ -1274,17 +1210,6 @@ class MessageWithReply : public SyncMessage {
|
||||
if (ReadParam(msg, &iter, &send_params)) {
|
||||
Tuple1<Message&> t = MakeRefTuple(*reply);
|
||||
|
||||
#ifdef IPC_MESSAGE_LOG_ENABLED
|
||||
if (msg->sent_time()) {
|
||||
// Don't log the sync message after dispatch, as we don't have the
|
||||
// output parameters at that point. Instead, save its data and log it
|
||||
// with the outgoing reply message when it's sent.
|
||||
LogData* data = new LogData;
|
||||
GenerateLogData(L"", *msg, data);
|
||||
msg->set_dont_log();
|
||||
reply->set_sync_log_data(data);
|
||||
}
|
||||
#endif
|
||||
DispatchToMethod(obj, func, send_params, &t);
|
||||
error = false;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user