summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-28 21:08:04 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-28 21:08:04 +0000
commitd55aaa139da94452ebd6812bfa9241ba050978d9 (patch)
treec5fd3ad94b96114b9109fc92610cae3b9688014b /chrome/common
parent50e8299eb26f3a289c35badb7e740eb109981cd1 (diff)
downloadchromium_src-d55aaa139da94452ebd6812bfa9241ba050978d9.zip
chromium_src-d55aaa139da94452ebd6812bfa9241ba050978d9.tar.gz
chromium_src-d55aaa139da94452ebd6812bfa9241ba050978d9.tar.bz2
Implement about:ipc dialog for Mac.
Convert IPC logging trigger from x-process waitable event to a messages sent to all processes. Review URL: http://codereview.chromium.org/192070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/child_process_host.cc7
-rw-r--r--chrome/common/child_process_host.h3
-rw-r--r--chrome/common/child_thread.cc38
-rw-r--r--chrome/common/child_thread.h7
-rw-r--r--chrome/common/logging_chrome.cc28
-rw-r--r--chrome/common/plugin_messages_internal.h7
-rw-r--r--chrome/common/render_messages_internal.h7
7 files changed, 79 insertions, 18 deletions
diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc
index 5ac925a..f7fe2df 100644
--- a/chrome/common/child_process_host.cc
+++ b/chrome/common/child_process_host.cc
@@ -22,7 +22,6 @@
#include "chrome/common/process_watcher.h"
#include "chrome/common/result_codes.h"
#include "chrome/installer/util/google_update_settings.h"
-#include "ipc/ipc_logging.h"
#if defined(OS_LINUX)
#include "base/linux_util.h"
@@ -256,6 +255,12 @@ void ChildProcessHost::ListenerHook::OnMessageReceived(
void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) {
host_->opening_channel_ = false;
host_->OnChannelConnected(peer_pid);
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+ bool enabled = IPC::Logging::current()->Enabled();
+ host_->Send(new PluginProcessMsg_SetIPCLoggingEnabled(enabled));
+#endif
+
host_->Send(new PluginProcessMsg_AskBeforeShutdown());
// Notify in the main loop of the connection.
diff --git a/chrome/common/child_process_host.h b/chrome/common/child_process_host.h
index 778b5a2..eaff476 100644
--- a/chrome/common/child_process_host.h
+++ b/chrome/common/child_process_host.h
@@ -8,6 +8,9 @@
#include <list>
#include <string>
+// Must be included early (e.g. before chrome/common/plugin_messages.h)
+#include "ipc/ipc_logging.h"
+
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
diff --git a/chrome/common/child_thread.cc b/chrome/common/child_thread.cc
index 8e9e90c..43da09a 100644
--- a/chrome/common/child_thread.cc
+++ b/chrome/common/child_thread.cc
@@ -11,6 +11,7 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/plugin_messages.h"
#include "ipc/ipc_logging.h"
+#include "ipc/ipc_message.h"
#include "ipc/ipc_switches.h"
#include "webkit/glue/webkit_glue.h"
@@ -98,15 +99,19 @@ void ChildThread::OnMessageReceived(const IPC::Message& msg) {
if (resource_dispatcher_->OnMessageReceived(msg))
return;
- if (msg.type() == PluginProcessMsg_AskBeforeShutdown::ID) {
- check_with_browser_before_shutdown_ = true;
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ChildThread, msg)
+ IPC_MESSAGE_HANDLER(PluginProcessMsg_AskBeforeShutdown, OnAskBeforeShutdown)
+ IPC_MESSAGE_HANDLER(PluginProcessMsg_Shutdown, OnShutdown)
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+ IPC_MESSAGE_HANDLER(PluginProcessMsg_SetIPCLoggingEnabled,
+ OnSetIPCLoggingEnabled)
+#endif // IPC_MESSAGE_HANDLER
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ if (handled)
return;
- }
-
- if (msg.type() == PluginProcessMsg_Shutdown::ID) {
- MessageLoop::current()->Quit();
- return;
- }
if (msg.routing_id() == MSG_ROUTING_CONTROL) {
OnControlMessageReceived(msg);
@@ -115,6 +120,23 @@ void ChildThread::OnMessageReceived(const IPC::Message& msg) {
}
}
+void ChildThread::OnAskBeforeShutdown() {
+ check_with_browser_before_shutdown_ = true;
+}
+
+void ChildThread::OnShutdown() {
+ MessageLoop::current()->Quit();
+}
+
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+void ChildThread::OnSetIPCLoggingEnabled(bool enable) {
+ if (enable)
+ IPC::Logging::current()->Enable();
+ else
+ IPC::Logging::current()->Disable();
+}
+#endif // IPC_MESSAGE_LOG_ENABLED
+
ChildThread* ChildThread::current() {
return ChildProcess::current()->main_thread();
}
diff --git a/chrome/common/child_thread.h b/chrome/common/child_thread.h
index afcd803..9b37e19 100644
--- a/chrome/common/child_thread.h
+++ b/chrome/common/child_thread.h
@@ -10,6 +10,7 @@
#include "chrome/common/message_router.h"
#include "chrome/common/resource_dispatcher.h"
#include "ipc/ipc_sync_channel.h"
+#include "ipc/ipc_message.h"
class NotificationService;
@@ -46,6 +47,12 @@ class ChildThread : public IPC::Channel::Listener,
void OnProcessFinalRelease();
virtual void OnControlMessageReceived(const IPC::Message& msg) { }
+ virtual void OnAskBeforeShutdown();
+ virtual void OnShutdown();
+
+#ifdef IPC_MESSAGE_LOG_ENABLED
+ virtual void OnSetIPCLoggingEnabled(bool enable);
+#endif
IPC::SyncChannel* channel() { return channel_.get(); }
diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc
index ee0caaa..ae0b48e 100644
--- a/chrome/common/logging_chrome.cc
+++ b/chrome/common/logging_chrome.cc
@@ -4,6 +4,24 @@
#include "build/build_config.h"
+// Need to include this before most other files because it defines
+// IPC_MESSAGE_LOG_ENABLED. We need to use it to define
+// IPC_MESSAGE_MACROS_LOG_ENABLED so render_messages.h will generate the
+// ViewMsgLog et al. functions.
+#include "ipc/ipc_message.h"
+
+// On Windows, the about:ipc dialog shows IPCs; on POSIX, we hook up a
+// logger in this file. (We implement about:ipc on Mac but implement
+// the loggers here anyway). We need to do this real early to be sure
+// IPC_MESSAGE_MACROS_LOG_ENABLED doesn't get undefined.
+#if defined(OS_POSIX) && defined(IPC_MESSAGE_LOG_ENABLED)
+#define IPC_MESSAGE_MACROS_LOG_ENABLED
+#include "chrome/common/devtools_messages.h"
+#include "chrome/common/plugin_messages.h"
+#include "chrome/common/render_messages.h"
+#include "chrome/common/worker_messages.h"
+#endif
+
#if defined(OS_WIN)
#include <windows.h>
#endif
@@ -25,16 +43,8 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
-#include "ipc/ipc_message.h"
-
-// On Windows, the about:ipc dialog shows IPCs; on POSIX, we hook up a
-// logger in this file.
-#if defined(OS_POSIX) && defined(IPC_MESSAGE_LOG_ENABLED)
-#define IPC_MESSAGE_MACROS_LOG_ENABLED
#include "ipc/ipc_logging.h"
-#include "chrome/common/plugin_messages.h"
-#include "chrome/common/render_messages.h"
-#endif
+#include "ipc/ipc_message.h"
// When true, this means that error dialogs should not be shown.
static bool dialogs_are_suppressed_ = false;
diff --git a/chrome/common/plugin_messages_internal.h b/chrome/common/plugin_messages_internal.h
index 3c64bcf..9049fa7 100644
--- a/chrome/common/plugin_messages_internal.h
+++ b/chrome/common/plugin_messages_internal.h
@@ -40,6 +40,13 @@ IPC_BEGIN_MESSAGES(PluginProcess)
// process that it's safe to shutdown.
IPC_MESSAGE_CONTROL0(PluginProcessMsg_Shutdown)
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+ // Tell the child process to begin or end IPC message logging.
+ // Like above, this is used by all ChildProcesses.
+ IPC_MESSAGE_CONTROL1(PluginProcessMsg_SetIPCLoggingEnabled,
+ bool /* on or off */)
+#endif
+
IPC_END_MESSAGES(PluginProcess)
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 22ba42a..ac124b5 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -26,6 +26,7 @@
#include "chrome/common/transport_dib.h"
#include "chrome/common/view_types.h"
#include "ipc/ipc_channel_handle.h"
+#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "webkit/appcache/appcache_interfaces.h"
@@ -733,6 +734,12 @@ IPC_BEGIN_MESSAGES(View)
int32 /* the ID of the message we're replying to */,
int64 /* the size of the given DB file */)
+#if defined(IPC_MESSAGE_LOG_ENABLED)
+ // Tell the renderer process to begin or end IPC message logging.
+ IPC_MESSAGE_CONTROL1(ViewMsg_SetIPCLoggingEnabled,
+ bool /* on or off */)
+#endif
+
//---------------------------------------------------------------------------
// Utility process messages:
// These are messages from the browser to the utility process. They're here