diff options
-rw-r--r-- | chrome/browser/worker_host/worker_process_host.cc | 5 | ||||
-rw-r--r-- | chrome/common/child_process.cc | 38 | ||||
-rw-r--r-- | chrome/common/child_process.h | 1 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/plugin/plugin_main.cc | 17 | ||||
-rw-r--r-- | chrome/renderer/renderer_main.cc | 30 | ||||
-rw-r--r-- | chrome/worker/worker_main.cc | 5 |
8 files changed, 55 insertions, 45 deletions
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc index 02e3cc6..a5cbbb8 100644 --- a/chrome/browser/worker_host/worker_process_host.cc +++ b/chrome/browser/worker_host/worker_process_host.cc @@ -111,6 +111,11 @@ bool WorkerProcessHost::Init() { cmd_line.AppendSwitch(switches::kWebWorkerShareProcesses); } + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kWorkerStartupDialog)) { + cmd_line.AppendSwitch(switches::kWorkerStartupDialog); + } + base::ProcessHandle process; #if defined(OS_WIN) process = sandbox::StartProcess(&cmd_line); diff --git a/chrome/common/child_process.cc b/chrome/common/child_process.cc index 34ea7a2..328ca14 100644 --- a/chrome/common/child_process.cc +++ b/chrome/common/child_process.cc @@ -4,8 +4,18 @@ #include "chrome/common/child_process.h" +#include "app/l10n_util.h" #include "base/message_loop.h" +#include "base/process_util.h" +#include "base/string_util.h" #include "chrome/common/child_thread.h" +#include "grit/chromium_strings.h" + +#if defined(OS_POSIX) +#include <signal.h> + +static void SigUSR1Handler(int signal) { } +#endif ChildProcess* ChildProcess::child_process_; @@ -57,3 +67,31 @@ base::WaitableEvent* ChildProcess::GetShutDownEvent() { DCHECK(child_process_); return &child_process_->shutdown_event_; } + +void ChildProcess::WaitForDebugger(const std::wstring& label) { +#if defined(OS_WIN) + std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME); + std::wstring message = label; + message += L" starting with pid: "; + message += IntToWString(base::GetCurrentProcId()); + title += L" "; + title += label; // makes attaching to process easier + ::MessageBox(NULL, message.c_str(), title.c_str(), + MB_OK | MB_SETFOREGROUND); +#elif defined(OS_POSIX) + // TODO(playmobil): In the long term, overriding this flag doesn't seem + // right, either use our own flag or open a dialog we can use. + // This is just to ease debugging in the interim. + LOG(WARNING) << label + << " (" + << getpid() + << ") paused waiting for debugger to attach @ pid"; + // Install a signal handler so that pause can be woken. + struct sigaction sa; + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = SigUSR1Handler; + sigaction(SIGUSR1, &sa, NULL); + + pause(); +#endif // defined(OS_POSIX) +} diff --git a/chrome/common/child_process.h b/chrome/common/child_process.h index 349ae92..fb2c660 100644 --- a/chrome/common/child_process.h +++ b/chrome/common/child_process.h @@ -46,6 +46,7 @@ class ChildProcess { // Getter for the one ChildProcess object for this process. static ChildProcess* current() { return child_process_; } + static void WaitForDebugger(const std::wstring& label); private: int ref_count_; diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 76df0e3..31e93fd 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -630,6 +630,9 @@ const char kWininetFtp[] = "wininet-ftp"; // Causes the process to run as a worker subprocess. const char kWorkerProcess[] = "worker"; +// Causes the worker process to display a dialog on launch +const char kWorkerStartupDialog[] = "worker-startup-dialog"; + // The prefix used when starting the zygote process. (i.e. 'gdb --args') const char kZygoteCmdPrefix[] = "zygote-cmd-prefix"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index d42347b..bde8c92 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -177,6 +177,7 @@ extern const char kWebWorkerShareProcesses[]; extern const char kWinHttpProxyResolver[]; extern const char kWininetFtp[]; extern const char kWorkerProcess[]; +extern const char kWorkerStartupDialog[]; extern const char kZygoteCmdPrefix[]; extern const char kZygoteProcess[]; diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc index f77767e..b051501 100644 --- a/chrome/plugin/plugin_main.cc +++ b/chrome/plugin/plugin_main.cc @@ -111,22 +111,7 @@ int PluginMain(const MainFunctionParams& parameters) { } #endif if (parsed_command_line.HasSwitch(switches::kPluginStartupDialog)) { -#if defined(OS_WIN) - std::wstring title = chrome::kBrowserAppName; - title += L" plugin"; // makes attaching to process easier - win_util::MessageBox(NULL, L"plugin starting...", title, - MB_OK | MB_SETFOREGROUND); -#elif defined(OS_MACOSX) - // TODO(playmobil): In the long term, overriding this flag doesn't seem - // right, either use our own flag or open a dialog we can use. - // This is just to ease debugging in the interim. - LOG(WARNING) << "Plugin (" - << getpid() - << ") paused waiting for debugger to attach @ pid"; - pause(); -#else - NOTIMPLEMENTED() << " non-windows startup, plugin startup dialog etc."; -#endif + ChildProcess::WaitForDebugger(L"Plugin"); } { diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc index 14a9d81..1531c40 100644 --- a/chrome/renderer/renderer_main.cc +++ b/chrome/renderer/renderer_main.cc @@ -24,7 +24,6 @@ #include "chrome/renderer/renderer_main_platform_delegate.h" #include "chrome/renderer/render_process.h" #include "chrome/renderer/render_thread.h" -#include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "net/base/net_module.h" @@ -32,12 +31,6 @@ #include "chrome/app/breakpad_linux.h" #endif -#if defined(OS_POSIX) -#include <signal.h> - -static void SigUSR1Handler(int signal) { } -#endif - // This function provides some ways to test crash and assertion handling // behavior of the renderer. static void HandleRendererErrorTestParameters(const CommandLine& command_line) { @@ -53,28 +46,7 @@ static void HandleRendererErrorTestParameters(const CommandLine& command_line) { } if (command_line.HasSwitch(switches::kRendererStartupDialog)) { -#if defined(OS_WIN) - std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME); - std::wstring message = L"renderer starting with pid: "; - message += IntToWString(base::GetCurrentProcId()); - title += L" renderer"; // makes attaching to process easier - ::MessageBox(NULL, message.c_str(), title.c_str(), - MB_OK | MB_SETFOREGROUND); -#elif defined(OS_POSIX) - // TODO(playmobil): In the long term, overriding this flag doesn't seem - // right, either use our own flag or open a dialog we can use. - // This is just to ease debugging in the interim. - LOG(WARNING) << "Renderer (" - << getpid() - << ") paused waiting for debugger to attach @ pid"; - // Install a signal handler so that pause can be woken. - struct sigaction sa; - memset(&sa, 0, sizeof(sa)); - sa.sa_handler = SigUSR1Handler; - sigaction(SIGUSR1, &sa, NULL); - - pause(); -#endif // defined(OS_POSIX) + ChildProcess::WaitForDebugger(L"Renderer"); } } diff --git a/chrome/worker/worker_main.cc b/chrome/worker/worker_main.cc index d6304ab..b157dbe 100644 --- a/chrome/worker/worker_main.cc +++ b/chrome/worker/worker_main.cc @@ -39,6 +39,11 @@ int WorkerMain(const MainFunctionParams& parameters) { target_services->LowerToken(); #endif + const CommandLine& parsed_command_line = parameters.command_line_; + if (parsed_command_line.HasSwitch(switches::kWorkerStartupDialog)) { + ChildProcess::WaitForDebugger(L"Worker"); + } + // Load the accelerator table from the browser executable and tell the // message loop to use it when translating messages. MessageLoop::current()->Run(); |