| OLD | NEW |
| 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/common/child_process.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 7 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 8 #include <signal.h> // For SigUSR1Handler below. | 8 #include <signal.h> // For SigUSR1Handler below. |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/metrics/statistics_recorder.h" |
| 12 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 13 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 14 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 16 #include "content/common/child_thread.h" | 17 #include "content/common/child_thread.h" |
| 17 | 18 |
| 18 #if defined(OS_ANDROID) | 19 #if defined(OS_ANDROID) |
| 19 #include "base/debug/debugger.h" | 20 #include "base/debug/debugger.h" |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 23 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 23 static void SigUSR1Handler(int signal) { } | 24 static void SigUSR1Handler(int signal) { } |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 ChildProcess* ChildProcess::child_process_; | 27 ChildProcess* ChildProcess::child_process_; |
| 27 | 28 |
| 28 ChildProcess::ChildProcess() | 29 ChildProcess::ChildProcess() |
| 29 : ref_count_(0), | 30 : ref_count_(0), |
| 30 shutdown_event_(true, false), | 31 shutdown_event_(true, false), |
| 31 io_thread_("Chrome_ChildIOThread") { | 32 io_thread_("Chrome_ChildIOThread") { |
| 32 DCHECK(!child_process_); | 33 DCHECK(!child_process_); |
| 33 child_process_ = this; | 34 child_process_ = this; |
| 34 | 35 |
| 36 base::StatisticsRecorder::Initialize(); |
| 37 |
| 35 // We can't recover from failing to start the IO thread. | 38 // We can't recover from failing to start the IO thread. |
| 36 CHECK(io_thread_.StartWithOptions( | 39 CHECK(io_thread_.StartWithOptions( |
| 37 base::Thread::Options(MessageLoop::TYPE_IO, 0))); | 40 base::Thread::Options(MessageLoop::TYPE_IO, 0))); |
| 38 } | 41 } |
| 39 | 42 |
| 40 ChildProcess::~ChildProcess() { | 43 ChildProcess::~ChildProcess() { |
| 41 DCHECK(child_process_ == this); | 44 DCHECK(child_process_ == this); |
| 42 | 45 |
| 43 // Signal this event before destroying the child process. That way all | 46 // Signal this event before destroying the child process. That way all |
| 44 // background threads can cleanup. | 47 // background threads can cleanup. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Install a signal handler so that pause can be woken. | 117 // Install a signal handler so that pause can be woken. |
| 115 struct sigaction sa; | 118 struct sigaction sa; |
| 116 memset(&sa, 0, sizeof(sa)); | 119 memset(&sa, 0, sizeof(sa)); |
| 117 sa.sa_handler = SigUSR1Handler; | 120 sa.sa_handler = SigUSR1Handler; |
| 118 sigaction(SIGUSR1, &sa, NULL); | 121 sigaction(SIGUSR1, &sa, NULL); |
| 119 | 122 |
| 120 pause(); | 123 pause(); |
| 121 #endif // defined(OS_ANDROID) | 124 #endif // defined(OS_ANDROID) |
| 122 #endif // defined(OS_POSIX) | 125 #endif // defined(OS_POSIX) |
| 123 } | 126 } |
| OLD | NEW |