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 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 : ref_count_(0), | 44 : ref_count_(0), |
45 shutdown_event_(true, false), | 45 shutdown_event_(true, false), |
46 io_thread_("Chrome_ChildIOThread") { | 46 io_thread_("Chrome_ChildIOThread") { |
47 DCHECK(!child_process_); | 47 DCHECK(!child_process_); |
48 child_process_ = this; | 48 child_process_ = this; |
49 | 49 |
50 base::StatisticsRecorder::Initialize(); | 50 base::StatisticsRecorder::Initialize(); |
51 | 51 |
52 // We can't recover from failing to start the IO thread. | 52 // We can't recover from failing to start the IO thread. |
53 CHECK(io_thread_.StartWithOptions( | 53 CHECK(io_thread_.StartWithOptions( |
54 base::Thread::Options(MessageLoop::TYPE_IO, 0))); | 54 base::Thread::Options(base::MessageLoop::TYPE_IO, 0))); |
55 | 55 |
56 #if defined(OS_ANDROID) | 56 #if defined(OS_ANDROID) |
57 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) | 57 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
58 io_thread_.message_loop()->PostTask(FROM_HERE, | 58 io_thread_.message_loop()->PostTask(FROM_HERE, |
59 base::Bind(&SetHighThreadPriority)); | 59 base::Bind(&SetHighThreadPriority)); |
60 #endif | 60 #endif |
61 } | 61 } |
62 | 62 |
63 ChildProcess::~ChildProcess() { | 63 ChildProcess::~ChildProcess() { |
64 DCHECK(child_process_ == this); | 64 DCHECK(child_process_ == this); |
(...skipping 17 matching lines...) Expand all Loading... |
82 ChildThread* ChildProcess::main_thread() { | 82 ChildThread* ChildProcess::main_thread() { |
83 return main_thread_.get(); | 83 return main_thread_.get(); |
84 } | 84 } |
85 | 85 |
86 void ChildProcess::set_main_thread(ChildThread* thread) { | 86 void ChildProcess::set_main_thread(ChildThread* thread) { |
87 main_thread_.reset(thread); | 87 main_thread_.reset(thread); |
88 } | 88 } |
89 | 89 |
90 void ChildProcess::AddRefProcess() { | 90 void ChildProcess::AddRefProcess() { |
91 DCHECK(!main_thread_.get() || // null in unittests. | 91 DCHECK(!main_thread_.get() || // null in unittests. |
92 MessageLoop::current() == main_thread_->message_loop()); | 92 base::MessageLoop::current() == main_thread_->message_loop()); |
93 ref_count_++; | 93 ref_count_++; |
94 } | 94 } |
95 | 95 |
96 void ChildProcess::ReleaseProcess() { | 96 void ChildProcess::ReleaseProcess() { |
97 DCHECK(!main_thread_.get() || // null in unittests. | 97 DCHECK(!main_thread_.get() || // null in unittests. |
98 MessageLoop::current() == main_thread_->message_loop()); | 98 base::MessageLoop::current() == main_thread_->message_loop()); |
99 DCHECK(ref_count_); | 99 DCHECK(ref_count_); |
100 DCHECK(child_process_); | 100 DCHECK(child_process_); |
101 if (--ref_count_) | 101 if (--ref_count_) |
102 return; | 102 return; |
103 | 103 |
104 if (main_thread_) // null in unittests. | 104 if (main_thread_) // null in unittests. |
105 main_thread_->OnProcessFinalRelease(); | 105 main_thread_->OnProcessFinalRelease(); |
106 } | 106 } |
107 | 107 |
108 base::WaitableEvent* ChildProcess::GetShutDownEvent() { | 108 base::WaitableEvent* ChildProcess::GetShutDownEvent() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 memset(&sa, 0, sizeof(sa)); | 143 memset(&sa, 0, sizeof(sa)); |
144 sa.sa_handler = SigUSR1Handler; | 144 sa.sa_handler = SigUSR1Handler; |
145 sigaction(SIGUSR1, &sa, NULL); | 145 sigaction(SIGUSR1, &sa, NULL); |
146 | 146 |
147 pause(); | 147 pause(); |
148 #endif // defined(OS_ANDROID) | 148 #endif // defined(OS_ANDROID) |
149 #endif // defined(OS_POSIX) | 149 #endif // defined(OS_POSIX) |
150 } | 150 } |
151 | 151 |
152 } // namespace content | 152 } // namespace content |
OLD | NEW |