| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/child_process.h" | 5 #include "chrome/common/child_process.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #include <signal.h> // For SigUSR1Handler below. | 8 #include <signal.h> // For SigUSR1Handler below. |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/thread.h" | 15 #include "base/thread.h" |
| 16 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/common/child_thread.h" | 17 #include "chrome/common/child_thread.h" |
| 17 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
| 18 | 19 |
| 19 #if defined(OS_POSIX) | 20 #if defined(OS_POSIX) |
| 20 static void SigUSR1Handler(int signal) { } | 21 static void SigUSR1Handler(int signal) { } |
| 21 #endif | 22 #endif |
| 22 | 23 |
| 23 ChildProcess* ChildProcess::child_process_; | 24 ChildProcess* ChildProcess::child_process_; |
| 24 | 25 |
| 25 ChildProcess::ChildProcess() | 26 ChildProcess::ChildProcess() |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 base::WaitableEvent* ChildProcess::GetShutDownEvent() { | 70 base::WaitableEvent* ChildProcess::GetShutDownEvent() { |
| 70 DCHECK(child_process_); | 71 DCHECK(child_process_); |
| 71 return &child_process_->shutdown_event_; | 72 return &child_process_->shutdown_event_; |
| 72 } | 73 } |
| 73 | 74 |
| 74 void ChildProcess::WaitForDebugger(const std::wstring& label) { | 75 void ChildProcess::WaitForDebugger(const std::wstring& label) { |
| 75 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
| 76 std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME); | 77 std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME); |
| 77 std::wstring message = label; | 78 std::wstring message = label; |
| 78 message += L" starting with pid: "; | 79 message += L" starting with pid: "; |
| 79 message += IntToWString(base::GetCurrentProcId()); | 80 message += UTF8ToWide(base::IntToString(base::GetCurrentProcId())); |
| 80 title += L" "; | 81 title += L" "; |
| 81 title += label; // makes attaching to process easier | 82 title += label; // makes attaching to process easier |
| 82 ::MessageBox(NULL, message.c_str(), title.c_str(), | 83 ::MessageBox(NULL, message.c_str(), title.c_str(), |
| 83 MB_OK | MB_SETFOREGROUND); | 84 MB_OK | MB_SETFOREGROUND); |
| 84 #elif defined(OS_POSIX) | 85 #elif defined(OS_POSIX) |
| 85 // TODO(playmobil): In the long term, overriding this flag doesn't seem | 86 // TODO(playmobil): In the long term, overriding this flag doesn't seem |
| 86 // right, either use our own flag or open a dialog we can use. | 87 // right, either use our own flag or open a dialog we can use. |
| 87 // This is just to ease debugging in the interim. | 88 // This is just to ease debugging in the interim. |
| 88 LOG(WARNING) << label | 89 LOG(WARNING) << label |
| 89 << " (" | 90 << " (" |
| 90 << getpid() | 91 << getpid() |
| 91 << ") paused waiting for debugger to attach @ pid"; | 92 << ") paused waiting for debugger to attach @ pid"; |
| 92 // Install a signal handler so that pause can be woken. | 93 // Install a signal handler so that pause can be woken. |
| 93 struct sigaction sa; | 94 struct sigaction sa; |
| 94 memset(&sa, 0, sizeof(sa)); | 95 memset(&sa, 0, sizeof(sa)); |
| 95 sa.sa_handler = SigUSR1Handler; | 96 sa.sa_handler = SigUSR1Handler; |
| 96 sigaction(SIGUSR1, &sa, NULL); | 97 sigaction(SIGUSR1, &sa, NULL); |
| 97 | 98 |
| 98 pause(); | 99 pause(); |
| 99 #endif // defined(OS_POSIX) | 100 #endif // defined(OS_POSIX) |
| 100 } | 101 } |
| OLD | NEW |