Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: content/child/child_process.cc

Issue 16328003: Move a bunch of child-only code from content/common to content/child (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some sort orders Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/child_process.h" 5 #include "content/child/child_process.h"
6
7 #if defined(OS_POSIX) && !defined(OS_ANDROID)
8 #include <signal.h> // For SigUSR1Handler below.
9 #endif
10 6
11 #include "base/message_loop.h" 7 #include "base/message_loop.h"
12 #include "base/metrics/statistics_recorder.h" 8 #include "base/metrics/statistics_recorder.h"
13 #include "base/process_util.h" 9 #include "base/process_util.h"
14 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
15 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
16 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
17 #include "content/common/child_thread.h" 13 #include "content/child/child_thread.h"
18 14
19 #if defined(OS_ANDROID) 15 #if defined(OS_ANDROID)
20 #include "base/debug/debugger.h" 16 #include "base/debug/debugger.h"
21 #endif 17 #endif
22 18
23 #if defined(OS_POSIX) && !defined(OS_ANDROID)
24 static void SigUSR1Handler(int signal) { }
25 #endif
26
27 namespace content { 19 namespace content {
28 // The singleton instance for this process. 20 // The singleton instance for this process.
29 ChildProcess* child_process = NULL; 21 ChildProcess* child_process = NULL;
30 22
31 ChildProcess::ChildProcess() 23 ChildProcess::ChildProcess()
32 : ref_count_(0), 24 : ref_count_(0),
33 shutdown_event_(true, false), 25 shutdown_event_(true, false),
34 io_thread_("Chrome_ChildIOThread") { 26 io_thread_("Chrome_ChildIOThread") {
35 DCHECK(!child_process); 27 DCHECK(!child_process);
36 child_process = this; 28 child_process = this;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 85
94 ChildProcess* ChildProcess::current() { 86 ChildProcess* ChildProcess::current() {
95 return child_process; 87 return child_process;
96 } 88 }
97 89
98 base::WaitableEvent* ChildProcess::GetShutDownEvent() { 90 base::WaitableEvent* ChildProcess::GetShutDownEvent() {
99 DCHECK(child_process); 91 DCHECK(child_process);
100 return &child_process->shutdown_event_; 92 return &child_process->shutdown_event_;
101 } 93 }
102 94
103 void ChildProcess::WaitForDebugger(const std::string& label) {
104 #if defined(OS_WIN)
105 #if defined(GOOGLE_CHROME_BUILD)
106 std::string title = "Google Chrome";
107 #else // CHROMIUM_BUILD
108 std::string title = "Chromium";
109 #endif // CHROMIUM_BUILD
110 title += " ";
111 title += label; // makes attaching to process easier
112 std::string message = label;
113 message += " starting with pid: ";
114 message += base::IntToString(base::GetCurrentProcId());
115 ::MessageBox(NULL, UTF8ToWide(message).c_str(), UTF8ToWide(title).c_str(),
116 MB_OK | MB_SETFOREGROUND);
117 #elif defined(OS_POSIX)
118 #if defined(OS_ANDROID)
119 LOG(ERROR) << label << " waiting for GDB.";
120 // Wait 24 hours for a debugger to be attached to the current process.
121 base::debug::WaitForDebugger(24 * 60 * 60, false);
122 #else
123 // TODO(playmobil): In the long term, overriding this flag doesn't seem
124 // right, either use our own flag or open a dialog we can use.
125 // This is just to ease debugging in the interim.
126 LOG(ERROR) << label
127 << " ("
128 << getpid()
129 << ") paused waiting for debugger to attach. "
130 << "Send SIGUSR1 to unpause.";
131 // Install a signal handler so that pause can be woken.
132 struct sigaction sa;
133 memset(&sa, 0, sizeof(sa));
134 sa.sa_handler = SigUSR1Handler;
135 sigaction(SIGUSR1, &sa, NULL);
136
137 pause();
138 #endif // defined(OS_ANDROID)
139 #endif // defined(OS_POSIX)
140 }
141
142 } // namespace content 95 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698