| 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/child/child_process.h" | 5 #include "content/child/child_process.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 namespace content { | 29 namespace content { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 base::LazyInstance<base::ThreadLocalPointer<ChildProcess> > g_lazy_tls = | 33 base::LazyInstance<base::ThreadLocalPointer<ChildProcess> > g_lazy_tls = |
| 34 LAZY_INSTANCE_INITIALIZER; | 34 LAZY_INSTANCE_INITIALIZER; |
| 35 } | 35 } |
| 36 | 36 |
| 37 ChildProcess::ChildProcess() | 37 ChildProcess::ChildProcess() : ChildProcess(base::ThreadPriority::NORMAL) {} |
| 38 |
| 39 ChildProcess::ChildProcess(base::ThreadPriority io_thread_priority) |
| 38 : ref_count_(0), | 40 : ref_count_(0), |
| 39 shutdown_event_(true, false), | 41 shutdown_event_(true, false), |
| 40 io_thread_("Chrome_ChildIOThread") { | 42 io_thread_("Chrome_ChildIOThread") { |
| 41 DCHECK(!g_lazy_tls.Pointer()->Get()); | 43 DCHECK(!g_lazy_tls.Pointer()->Get()); |
| 42 g_lazy_tls.Pointer()->Set(this); | 44 g_lazy_tls.Pointer()->Set(this); |
| 43 | 45 |
| 44 base::StatisticsRecorder::Initialize(); | 46 base::StatisticsRecorder::Initialize(); |
| 45 | 47 |
| 46 // We can't recover from failing to start the IO thread. | 48 // We can't recover from failing to start the IO thread. |
| 47 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); | 49 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); |
| 50 thread_options.priority = io_thread_priority; |
| 48 #if defined(OS_ANDROID) | 51 #if defined(OS_ANDROID) |
| 49 thread_options.priority = base::ThreadPriority::DISPLAY; | 52 thread_options.priority = base::ThreadPriority::DISPLAY; |
| 50 #endif | 53 #endif |
| 51 CHECK(io_thread_.StartWithOptions(thread_options)); | 54 CHECK(io_thread_.StartWithOptions(thread_options)); |
| 52 } | 55 } |
| 53 | 56 |
| 54 ChildProcess::~ChildProcess() { | 57 ChildProcess::~ChildProcess() { |
| 55 DCHECK(g_lazy_tls.Pointer()->Get() == this); | 58 DCHECK(g_lazy_tls.Pointer()->Get() == this); |
| 56 | 59 |
| 57 // Signal this event before destroying the child process. That way all | 60 // Signal this event before destroying the child process. That way all |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 memset(&sa, 0, sizeof(sa)); | 141 memset(&sa, 0, sizeof(sa)); |
| 139 sa.sa_handler = SigUSR1Handler; | 142 sa.sa_handler = SigUSR1Handler; |
| 140 sigaction(SIGUSR1, &sa, NULL); | 143 sigaction(SIGUSR1, &sa, NULL); |
| 141 | 144 |
| 142 pause(); | 145 pause(); |
| 143 #endif // defined(OS_ANDROID) | 146 #endif // defined(OS_ANDROID) |
| 144 #endif // defined(OS_POSIX) | 147 #endif // defined(OS_POSIX) |
| 145 } | 148 } |
| 146 | 149 |
| 147 } // namespace content | 150 } // namespace content |
| OLD | NEW |