Commit 58188f92 authored by jam@chromium.org's avatar jam@chromium.org

Move enabling IPC logging for all child processes to the Content API.

BUG=98716
Review URL: http://codereview.chromium.org/8574070

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110747 0039d316-1c4b-4281-b951-d872f2087c98
parent adf7716f
......@@ -224,13 +224,6 @@ class BrowserProcess {
virtual prerender::PrerenderTracker* prerender_tracker() = 0;
#if defined(IPC_MESSAGE_LOG_ENABLED)
// Enable or disable IPC logging for the browser, all processes
// derived from ChildProcess (plugin etc), and all
// renderers.
virtual void SetIPCLoggingEnabled(bool enable) = 0;
#endif
virtual MHTMLGenerationManager* mhtml_generation_manager() = 0;
virtual GpuBlacklistUpdater* gpu_blacklist_updater() = 0;
......
......@@ -68,7 +68,6 @@
#include "chrome/common/switch_utils.h"
#include "chrome/common/url_constants.h"
#include "chrome/installer/util/google_update_constants.h"
#include "content/browser/browser_child_process_host.h"
#include "content/browser/browser_process_sub_thread.h"
#include "content/browser/child_process_security_policy.h"
#include "content/browser/debugger/devtools_manager.h"
......@@ -84,7 +83,6 @@
#include "content/public/browser/notification_details.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/url_fetcher.h"
#include "ipc/ipc_logging.h"
#include "net/socket/client_socket_pool_manager.h"
#include "net/url_request/url_request_context_getter.h"
#include "ui/base/clipboard/clipboard.h"
......@@ -96,10 +94,6 @@
#include "chrome/browser/chrome_browser_main_mac.h"
#endif
#if defined(IPC_MESSAGE_LOG_ENABLED)
#include "content/common/child_process_messages.h"
#endif
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/web_socket_proxy_controller.h"
#include "chrome/browser/oom_priority_manager.h"
......@@ -1054,49 +1048,6 @@ void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() {
resource_dispatcher_host()->set_allow_cross_origin_auth_prompt(value);
}
// The BrowserProcess object must outlive the file thread so we use traits
// which don't do any management.
DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowserProcessImpl);
#if defined(IPC_MESSAGE_LOG_ENABLED)
void BrowserProcessImpl::SetIPCLoggingEnabled(bool enable) {
// First enable myself.
if (enable)
IPC::Logging::GetInstance()->Enable();
else
IPC::Logging::GetInstance()->Disable();
// Now tell subprocesses. Messages to ChildProcess-derived
// processes must be done on the IO thread.
io_thread()->message_loop()->PostTask
(FROM_HERE,
NewRunnableMethod(
this,
&BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses,
enable));
// Finally, tell the renderers which don't derive from ChildProcess.
// Messages to the renderers must be done on the UI (main) thread.
for (content::RenderProcessHost::iterator i(
content::RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance())
i.GetCurrentValue()->Send(new ChildProcessMsg_SetIPCLoggingEnabled(enable));
}
// Helper for SetIPCLoggingEnabled.
void BrowserProcessImpl::SetIPCLoggingEnabledForChildProcesses(bool enabled) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
BrowserChildProcessHost::Iterator i; // default constr references a singleton
while (!i.Done()) {
i->Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled));
++i;
}
}
#endif // IPC_MESSAGE_LOG_ENABLED
// Mac is currently not supported.
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
......
......@@ -113,19 +113,10 @@ class BrowserProcessImpl : public BrowserProcess,
#endif
virtual ChromeNetLog* net_log() OVERRIDE;
virtual prerender::PrerenderTracker* prerender_tracker() OVERRIDE;
#if defined(IPC_MESSAGE_LOG_ENABLED)
virtual void SetIPCLoggingEnabled(bool enable) OVERRIDE;
#endif
virtual MHTMLGenerationManager* mhtml_generation_manager() OVERRIDE;
virtual GpuBlacklistUpdater* gpu_blacklist_updater() OVERRIDE;
virtual ComponentUpdateService* component_updater() OVERRIDE;
virtual CRLSetFetcher* crl_set_fetcher();
private:
......@@ -168,10 +159,6 @@ class BrowserProcessImpl : public BrowserProcess,
void ApplyAllowCrossOriginAuthPromptPolicy();
void ApplyDefaultBrowserPolicy();
#if defined(IPC_MESSAGE_LOG_ENABLED)
void SetIPCLoggingEnabledForChildProcesses(bool enabled);
#endif
bool created_resource_dispatcher_host_;
scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_;
......
......@@ -7,8 +7,8 @@
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "base/time.h"
#include "chrome/browser/browser_process.h"
#import "chrome/browser/ui/cocoa/about_ipc_controller.h"
#include "content/public/browser/content_ipc_logging.h"
#if defined(IPC_MESSAGE_LOG_ENABLED)
......@@ -100,8 +100,7 @@ AboutIPCController* gSharedController = nil;
- (void)dealloc {
if (gSharedController == self)
gSharedController = nil;
if (g_browser_process)
g_browser_process->SetIPCLoggingEnabled(false); // just in case...
content::EnableIPCLogging(false); // just in case...
IPC::Logging::GetInstance()->SetConsumer(NULL);
[super dealloc];
}
......@@ -130,8 +129,7 @@ AboutIPCController* gSharedController = nil;
}
- (IBAction)startStop:(id)sender {
g_browser_process->SetIPCLoggingEnabled(
!IPC::Logging::GetInstance()->Enabled());
content::EnableIPCLogging(!IPC::Logging::GetInstance()->Enabled());
[self updateVisibleRunState];
}
......
......@@ -5,8 +5,10 @@
#import <Cocoa/Cocoa.h>
#import "base/memory/scoped_nsobject.h"
#include "base/message_loop.h"
#import "chrome/browser/ui/cocoa/about_ipc_controller.h"
#include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
#include "content/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
......@@ -15,6 +17,22 @@
namespace {
class AboutIPCControllerTest : public CocoaTest {
public:
virtual void SetUp() {
CocoaTest::SetUp();
ui_message_loop_.reset(new MessageLoopForUI());
ui_thread_.reset(new content::TestBrowserThread(content::BrowserThread::UI,
MessageLoop::current()));
}
virtual void TearDown() {
CocoaTest::TearDown();
ui_thread_.reset(NULL);
}
private:
scoped_ptr<MessageLoopForUI> ui_message_loop_;
scoped_ptr<content::TestBrowserThread> ui_thread_;
};
TEST_F(AboutIPCControllerTest, TestFilter) {
......
......@@ -25,9 +25,9 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/common/chrome_constants.h"
#include "content/public/browser/content_ipc_logging.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_job.h"
#include "views/controls/button/text_button.h"
......@@ -352,11 +352,11 @@ void AboutIPCDialog::ButtonPressed(
if (tracking_) {
track_toggle_->SetText(kStartTrackingLabel);
tracking_ = false;
g_browser_process->SetIPCLoggingEnabled(false);
content::EnableIPCLogging(false);
} else {
track_toggle_->SetText(kStopTrackingLabel);
tracking_ = true;
g_browser_process->SetIPCLoggingEnabled(true);
content::EnableIPCLogging(true);
}
track_toggle_->SchedulePaint();
} else if (button == clear_button_) {
......
......@@ -110,10 +110,6 @@ class TestingBrowserProcess : public BrowserProcess {
virtual ChromeNetLog* net_log() OVERRIDE;
virtual prerender::PrerenderTracker* prerender_tracker() OVERRIDE;
#if defined(IPC_MESSAGE_LOG_ENABLED)
virtual void SetIPCLoggingEnabled(bool enable) OVERRIDE {}
#endif
virtual MHTMLGenerationManager* mhtml_generation_manager() OVERRIDE;
virtual GpuBlacklistUpdater* gpu_blacklist_updater() OVERRIDE;
virtual ComponentUpdateService* component_updater() OVERRIDE;
......
// Copyright (c) 2011 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 "content/public/browser/content_ipc_logging.h"
#include "base/bind.h"
#include "content/browser/browser_child_process_host.h"
#include "content/common/child_process_messages.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "ipc/ipc_logging.h"
namespace content {
#if defined(IPC_MESSAGE_LOG_ENABLED)
void EnableIPCLoggingForChildProcesses(bool enabled) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
BrowserChildProcessHost::Iterator i; // default constr references a singleton
while (!i.Done()) {
i->Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled));
++i;
}
}
void EnableIPCLogging(bool enable) {
// First enable myself.
if (enable)
IPC::Logging::GetInstance()->Enable();
else
IPC::Logging::GetInstance()->Disable();
// Now tell subprocesses. Messages to ChildProcess-derived
// processes must be done on the IO thread.
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(EnableIPCLoggingForChildProcesses, enable));
// Finally, tell the renderers which don't derive from ChildProcess.
// Messages to the renderers must be done on the UI (main) thread.
for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance())
i.GetCurrentValue()->Send(new ChildProcessMsg_SetIPCLoggingEnabled(enable));
}
#endif // IPC_MESSAGE_LOG_ENABLED
} // namespace content
......@@ -28,6 +28,7 @@
'public/browser/browser_main_parts.h',
'public/browser/browser_thread.h',
'public/browser/content_browser_client.h',
'public/browser/content_ipc_logging.h',
'public/browser/download_manager_delegate.h',
'public/browser/native_web_keyboard_event.h',
'public/browser/navigation_types.h',
......@@ -92,6 +93,7 @@
'browser/child_process_security_policy.h',
'browser/chrome_blob_storage_context.cc',
'browser/chrome_blob_storage_context.h',
'browser/content_ipc_logging.cc',
'browser/cross_site_request_manager.cc',
'browser/cross_site_request_manager.h',
'browser/debugger/devtools_agent_host.cc',
......
// Copyright (c) 2011 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 CONTENT_PUBLIC_BROWSER_CONTENT_IPC_LOGGING_H_
#define CONTENT_PUBLIC_BROWSER_CONTENT_IPC_LOGGING_H_
#pragma once
#include "content/common/content_export.h"
#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
namespace content {
#if defined(IPC_MESSAGE_LOG_ENABLED)
// Enable or disable IPC logging for the browser, all processes
// derived from ChildProcess (plugin etc), and all
// renderers.
CONTENT_EXPORT void EnableIPCLogging(bool enable);
#endif
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_CONTENT_IPC_LOGGING_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment