Skip to content

Commit

Permalink
Remove IPC channel IDs.
Browse files Browse the repository at this point in the history
Channel IDs are now always empty. This CL removes them entirely.

BUG=659448

Review-Url: https://codereview.chromium.org/2494373002
Cr-Commit-Position: refs/heads/master@{#432020}
  • Loading branch information
sammc authored and Commit bot committed Nov 15, 2016
1 parent 3aa3a7b commit a1b3b4d
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 33 deletions.
2 changes: 1 addition & 1 deletion content/common/child_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ bool ChildProcessHostImpl::OnMessageReceived(const IPC::Message& msg) {

#ifdef IPC_MESSAGE_LOG_ENABLED
if (logger->Enabled())
logger->OnPostDispatchMessage(msg, channel_id_);
logger->OnPostDispatchMessage(msg);
#endif
return handled;
}
Expand Down
2 changes: 0 additions & 2 deletions ipc/ipc_channel_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class PlatformChannelFactory : public ChannelFactory {
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner)
: handle_(handle), mode_(mode), ipc_task_runner_(ipc_task_runner) {}

std::string GetName() const override { return ""; }

std::unique_ptr<Channel> BuildChannel(Listener* listener) override {
#if defined(OS_NACL_SFI)
return Channel::Create(handle_, mode_, listener);
Expand Down
1 change: 0 additions & 1 deletion ipc/ipc_channel_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class IPC_EXPORT ChannelFactory {
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner);

virtual ~ChannelFactory() { }
virtual std::string GetName() const = 0;
virtual std::unique_ptr<Channel> BuildChannel(Listener* listener) = 0;
virtual scoped_refptr<base::SingleThreadTaskRunner> GetIPCTaskRunner() = 0;
};
Expand Down
2 changes: 0 additions & 2 deletions ipc/ipc_channel_mojo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class MojoChannelFactory : public ChannelFactory {
mode_(mode),
ipc_task_runner_(ipc_task_runner) {}

std::string GetName() const override { return ""; }

std::unique_ptr<Channel> BuildChannel(Listener* listener) override {
return ChannelMojo::Create(
std::move(handle_), mode_, listener, ipc_task_runner_);
Expand Down
2 changes: 1 addition & 1 deletion ipc/ipc_channel_nacl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ bool ChannelNacl::Send(Message* message) {
std::unique_ptr<Message> message_ptr(message);

#ifdef IPC_MESSAGE_LOG_ENABLED
Logging::GetInstance()->OnSendMessage(message_ptr.get(), "");
Logging::GetInstance()->OnSendMessage(message_ptr.get());
#endif // IPC_MESSAGE_LOG_ENABLED

TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("ipc.flow"),
Expand Down
7 changes: 3 additions & 4 deletions ipc/ipc_channel_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ void ChannelProxy::Context::CreateChannel(
base::AutoLock l(channel_lifetime_lock_);
DCHECK(!channel_);
DCHECK_EQ(factory->GetIPCTaskRunner(), ipc_task_runner_);
channel_id_ = factory->GetName();
channel_ = factory->BuildChannel(this);

Channel::AssociatedInterfaceSupport* support =
Expand Down Expand Up @@ -103,7 +102,7 @@ bool ChannelProxy::Context::TryFilters(const Message& message) {
}
#ifdef IPC_MESSAGE_LOG_ENABLED
if (logger->Enabled())
logger->OnPostDispatchMessage(message, channel_id_);
logger->OnPostDispatchMessage(message);
#endif
return true;
}
Expand Down Expand Up @@ -344,7 +343,7 @@ void ChannelProxy::Context::OnDispatchMessage(const Message& message) {

#ifdef IPC_MESSAGE_LOG_ENABLED
if (logger->Enabled())
logger->OnPostDispatchMessage(message, channel_id_);
logger->OnPostDispatchMessage(message);
#endif
}

Expand Down Expand Up @@ -565,7 +564,7 @@ bool ChannelProxy::Send(Message* message) {
#endif

#ifdef IPC_MESSAGE_LOG_ENABLED
Logging::GetInstance()->OnSendMessage(message, context_->channel_id());
Logging::GetInstance()->OnSendMessage(message);
#endif

context_->Send(message);
Expand Down
3 changes: 0 additions & 3 deletions ipc/ipc_channel_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
base::SingleThreadTaskRunner* ipc_task_runner() const {
return ipc_task_runner_.get();
}
const std::string& channel_id() const { return channel_id_; }

// Dispatches a message on the listener thread.
void OnDispatchMessage(const Message& message);

Expand Down Expand Up @@ -339,7 +337,6 @@ class IPC_EXPORT ChannelProxy : public Sender, public base::NonThreadSafe {
// thread.
// One exception is the thread-safe send. See the class comment.
std::unique_ptr<Channel> channel_;
std::string channel_id_;
bool channel_connected_called_;

// Lock for |channel_| value. This is only relevant in the context of
Expand Down
17 changes: 6 additions & 11 deletions ipc/ipc_logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void Logging::OnReceivedLoggingMessage(const Message& message) {
}
}

void Logging::OnSendMessage(Message* message, const std::string& channel_id) {
void Logging::OnSendMessage(Message* message) {
if (!Enabled())
return;

Expand All @@ -134,8 +134,7 @@ void Logging::OnSendMessage(Message* message, const std::string& channel_id) {
// 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.
GenerateLogData("", *message, data, true);
data->channel = channel_id;
GenerateLogData(*message, data, true);
Log(*data);
delete data;
message->set_sync_log_data(NULL);
Expand All @@ -151,16 +150,15 @@ void Logging::OnPreDispatchMessage(const Message& message) {
message.set_received_time(Time::Now().ToInternalValue());
}

void Logging::OnPostDispatchMessage(const Message& message,
const std::string& channel_id) {
void Logging::OnPostDispatchMessage(const Message& message) {
if (!Enabled() ||
!message.sent_time() ||
!message.received_time() ||
message.dont_log())
return;

LogData data;
GenerateLogData(channel_id, message, &data, true);
GenerateLogData(message, &data, true);

if (main_thread_->BelongsToCurrentThread()) {
Log(data);
Expand Down Expand Up @@ -255,8 +253,7 @@ void Logging::Log(const LogData& data) {
(Time::FromInternalValue(data.dispatch) -
Time::FromInternalValue(data.sent)).InSecondsF();
fprintf(stderr,
"ipc %s %d %s %s%s %s%s\n %18.5f %s%18.5f %s%18.5f%s\n",
data.channel.c_str(),
"ipc %d %s %s%s %s%s\n %18.5f %s%18.5f %s%18.5f%s\n",
data.routing_id,
data.flags.c_str(),
ANSIEscape(sender_ ? ANSI_COLOR_BLUE : ANSI_COLOR_CYAN),
Expand All @@ -273,8 +270,7 @@ void Logging::Log(const LogData& data) {
}
}

void GenerateLogData(const std::string& channel, const Message& message,
LogData* data, bool get_params) {
void GenerateLogData(const Message& message, LogData* data, bool get_params) {
if (message.is_reply()) {
// "data" should already be filled in.
std::string params;
Expand All @@ -301,7 +297,6 @@ void GenerateLogData(const std::string& channel, const Message& message,
Logging::GetMessageText(message.type(), &message_name, &message,
get_params ? &params : NULL);

data->channel = channel;
data->routing_id = message.routing_id();
data->type = message.type();
data->flags = flags;
Expand Down
5 changes: 2 additions & 3 deletions ipc/ipc_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ class IPC_EXPORT Logging {
// received.
void OnReceivedLoggingMessage(const Message& message);

void OnSendMessage(Message* message, const std::string& channel_id);
void OnSendMessage(Message* message);
void OnPreDispatchMessage(const Message& message);
void OnPostDispatchMessage(const Message& message,
const std::string& channel_id);
void OnPostDispatchMessage(const Message& message);

// Like the *MsgLog functions declared for each message class, except this
// calls the correct one based on the message type automatically. Defined in
Expand Down
9 changes: 4 additions & 5 deletions ipc/ipc_message_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1100,10 +1100,9 @@ struct IPC_EXPORT ParamTraits<MSG> {
// Generic message subclasses

// defined in ipc_logging.cc
IPC_EXPORT void GenerateLogData(const std::string& channel,
const Message& message,
LogData* data, bool get_params);

IPC_EXPORT void GenerateLogData(const Message& message,
LogData* data,
bool get_params);

#if defined(IPC_MESSAGE_LOG_ENABLED)
inline void AddOutputParamsToLog(const Message* msg, std::string* l) {
Expand All @@ -1130,7 +1129,7 @@ inline void ConnectMessageAndReply(const Message* msg, Message* reply) {
// 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("", *msg, data, true);
GenerateLogData(*msg, data, true);
msg->set_dont_log();
reply->set_sync_log_data(data);
}
Expand Down

0 comments on commit a1b3b4d

Please sign in to comment.