1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/public/browser/browser_ipc_logging.h"
8 #include "content/common/child_process_messages.h"
9 #include "content/public/browser/browser_child_process_host_iterator.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/render_process_host.h"
12 #include "ipc/ipc_logging.h"
16 #if defined(IPC_MESSAGE_LOG_ENABLED)
18 void EnableIPCLoggingForChildProcesses(bool enabled
) {
19 DCHECK_CURRENTLY_ON(BrowserThread::IO
);
21 BrowserChildProcessHostIterator i
; // default constr references a singleton
23 i
.Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled
));
28 void EnableIPCLogging(bool enable
) {
29 // First enable myself.
31 IPC::Logging::GetInstance()->Enable();
33 IPC::Logging::GetInstance()->Disable();
35 // Now tell subprocesses. Messages to ChildProcess-derived
36 // processes must be done on the IO thread.
37 BrowserThread::PostTask(
40 base::Bind(EnableIPCLoggingForChildProcesses
, enable
));
42 // Finally, tell the renderers which don't derive from ChildProcess.
43 // Messages to the renderers must be done on the UI (main) thread.
44 for (RenderProcessHost::iterator
i(RenderProcessHost::AllHostsIterator());
45 !i
.IsAtEnd(); i
.Advance())
46 i
.GetCurrentValue()->Send(new ChildProcessMsg_SetIPCLoggingEnabled(enable
));
49 #endif // IPC_MESSAGE_LOG_ENABLED
51 } // namespace content