Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(936)

Side by Side Diff: ipc/ipc_channel_proxy.cc

Issue 975903002: Add a flag to dump IPC messages sent from the renderer to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove BUILD.gn changes, since the IPC fuzzer doesn't work with gn Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | tools/ipc_fuzzer/dump/dump.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/ipc_channel_proxy.h" 5 #include "ipc/ipc_channel_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // Called on the listener's thread 245 // Called on the listener's thread
246 void ChannelProxy::Context::AddFilter(MessageFilter* filter) { 246 void ChannelProxy::Context::AddFilter(MessageFilter* filter) {
247 base::AutoLock auto_lock(pending_filters_lock_); 247 base::AutoLock auto_lock(pending_filters_lock_);
248 pending_filters_.push_back(make_scoped_refptr(filter)); 248 pending_filters_.push_back(make_scoped_refptr(filter));
249 ipc_task_runner_->PostTask( 249 ipc_task_runner_->PostTask(
250 FROM_HERE, base::Bind(&Context::OnAddFilter, this)); 250 FROM_HERE, base::Bind(&Context::OnAddFilter, this));
251 } 251 }
252 252
253 // Called on the listener's thread 253 // Called on the listener's thread
254 void ChannelProxy::Context::OnDispatchMessage(const Message& message) { 254 void ChannelProxy::Context::OnDispatchMessage(const Message& message) {
255 #ifdef IPC_MESSAGE_LOG_ENABLED 255 #if defined(IPC_MESSAGE_LOG_ENABLED)
256 Logging* logger = Logging::GetInstance(); 256 Logging* logger = Logging::GetInstance();
257 std::string name; 257 std::string name;
258 logger->GetMessageText(message.type(), &name, &message, NULL); 258 logger->GetMessageText(message.type(), &name, &message, NULL);
259 TRACE_EVENT1("ipc", "ChannelProxy::Context::OnDispatchMessage", 259 TRACE_EVENT1("ipc", "ChannelProxy::Context::OnDispatchMessage",
260 "name", name); 260 "name", name);
261 #else 261 #else
262 TRACE_EVENT2("ipc", "ChannelProxy::Context::OnDispatchMessage", 262 TRACE_EVENT2("ipc", "ChannelProxy::Context::OnDispatchMessage",
263 "class", IPC_MESSAGE_ID_CLASS(message.type()), 263 "class", IPC_MESSAGE_ID_CLASS(message.type()),
264 "line", IPC_MESSAGE_ID_LINE(message.type())); 264 "line", IPC_MESSAGE_ID_LINE(message.type()));
265 #endif 265 #endif
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 Listener* listener, 330 Listener* listener,
331 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { 331 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
332 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); 332 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner));
333 channel->Init(factory.Pass(), true); 333 channel->Init(factory.Pass(), true);
334 return channel.Pass(); 334 return channel.Pass();
335 } 335 }
336 336
337 ChannelProxy::ChannelProxy(Context* context) 337 ChannelProxy::ChannelProxy(Context* context)
338 : context_(context), 338 : context_(context),
339 did_init_(false) { 339 did_init_(false) {
340 #if defined(ENABLE_IPC_FUZZER)
341 outgoing_message_filter_ = NULL;
342 #endif
340 } 343 }
341 344
342 ChannelProxy::ChannelProxy( 345 ChannelProxy::ChannelProxy(
343 Listener* listener, 346 Listener* listener,
344 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) 347 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner)
345 : context_(new Context(listener, ipc_task_runner)), did_init_(false) { 348 : context_(new Context(listener, ipc_task_runner)), did_init_(false) {
349 #if defined(ENABLE_IPC_FUZZER)
350 outgoing_message_filter_ = NULL;
351 #endif
346 } 352 }
347 353
348 ChannelProxy::~ChannelProxy() { 354 ChannelProxy::~ChannelProxy() {
349 DCHECK(CalledOnValidThread()); 355 DCHECK(CalledOnValidThread());
350 356
351 Close(); 357 Close();
352 } 358 }
353 359
354 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, 360 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle,
355 Channel::Mode mode, 361 Channel::Mode mode,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 FROM_HERE, base::Bind(&Context::OnChannelClosed, context_.get())); 410 FROM_HERE, base::Bind(&Context::OnChannelClosed, context_.get()));
405 } 411 }
406 } 412 }
407 413
408 bool ChannelProxy::Send(Message* message) { 414 bool ChannelProxy::Send(Message* message) {
409 DCHECK(did_init_); 415 DCHECK(did_init_);
410 416
411 // TODO(alexeypa): add DCHECK(CalledOnValidThread()) here. Currently there are 417 // TODO(alexeypa): add DCHECK(CalledOnValidThread()) here. Currently there are
412 // tests that call Send() from a wrong thread. See http://crbug.com/163523. 418 // tests that call Send() from a wrong thread. See http://crbug.com/163523.
413 419
420 #ifdef ENABLE_IPC_FUZZER
421 // In IPC fuzzing builds, it is possible to define a filter to apply to
422 // outgoing messages. It will either rewrite the message and return a new
423 // one, freeing the original, or return the message unchanged.
424 if (outgoing_message_filter())
425 message = outgoing_message_filter()->Rewrite(message);
426 #endif
427
414 #ifdef IPC_MESSAGE_LOG_ENABLED 428 #ifdef IPC_MESSAGE_LOG_ENABLED
415 Logging::GetInstance()->OnSendMessage(message, context_->channel_id()); 429 Logging::GetInstance()->OnSendMessage(message, context_->channel_id());
416 #endif 430 #endif
417 431
418 context_->ipc_task_runner()->PostTask( 432 context_->ipc_task_runner()->PostTask(
419 FROM_HERE, 433 FROM_HERE,
420 base::Bind(&ChannelProxy::Context::OnSendMessage, 434 base::Bind(&ChannelProxy::Context::OnSendMessage,
421 context_, base::Passed(scoped_ptr<Message>(message)))); 435 context_, base::Passed(scoped_ptr<Message>(message))));
422 return true; 436 return true;
423 } 437 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 Channel* channel = context_.get()->channel_.get(); 481 Channel* channel = context_.get()->channel_.get();
468 // Channel must have been created first. 482 // Channel must have been created first.
469 DCHECK(channel) << context_.get()->channel_id_; 483 DCHECK(channel) << context_.get()->channel_id_;
470 return channel->TakeClientFileDescriptor(); 484 return channel->TakeClientFileDescriptor();
471 } 485 }
472 #endif 486 #endif
473 487
474 //----------------------------------------------------------------------------- 488 //-----------------------------------------------------------------------------
475 489
476 } // namespace IPC 490 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | tools/ipc_fuzzer/dump/dump.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698