Chromium Code Reviews| 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 #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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); | 47 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); |
| 48 #if defined(OS_ANDROID) | 48 #if defined(OS_ANDROID) |
| 49 thread_options.priority = base::ThreadPriority::DISPLAY; | 49 thread_options.priority = base::ThreadPriority::DISPLAY; |
| 50 #endif | 50 #endif |
| 51 CHECK(io_thread_.StartWithOptions(thread_options)); | 51 CHECK(io_thread_.StartWithOptions(thread_options)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 ChildProcess::~ChildProcess() { | 54 ChildProcess::~ChildProcess() { |
| 55 DCHECK(g_lazy_tls.Pointer()->Get() == this); | 55 DCHECK(g_lazy_tls.Pointer()->Get() == this); |
| 56 | 56 |
| 57 // Kill the main thread object before nulling child_process, since | |
| 58 // destruction code might depend on it. | |
| 59 if (main_thread_) // null in unittests. | |
| 60 main_thread_->Shutdown(); | |
| 61 | |
| 57 // Signal this event before destroying the child process. That way all | 62 // Signal this event before destroying the child process. That way all |
| 58 // background threads can cleanup. | 63 // background threads can cleanup. |
| 59 // For example, in the renderer the RenderThread instances will be able to | 64 // For example, in the renderer the RenderThread instances will be able to |
| 60 // notice shutdown before the render process begins waiting for them to exit. | 65 // notice shutdown before the render process begins waiting for them to exit. |
| 61 shutdown_event_.Signal(); | 66 shutdown_event_.Signal(); |
|
reveman
2015/09/11 22:26:13
This needs to happen after Shutdown() as that migh
| |
| 62 | 67 |
| 63 // Kill the main thread object before nulling child_process, since | 68 main_thread_.reset(); |
| 64 // destruction code might depend on it. | |
| 65 if (main_thread_) { // null in unittests. | |
| 66 main_thread_->Shutdown(); | |
| 67 main_thread_.reset(); | |
| 68 } | |
| 69 | |
| 70 g_lazy_tls.Pointer()->Set(NULL); | 69 g_lazy_tls.Pointer()->Set(NULL); |
| 71 io_thread_.Stop(); | 70 io_thread_.Stop(); |
| 72 } | 71 } |
| 73 | 72 |
| 74 ChildThreadImpl* ChildProcess::main_thread() { | 73 ChildThreadImpl* ChildProcess::main_thread() { |
| 75 return main_thread_.get(); | 74 return main_thread_.get(); |
| 76 } | 75 } |
| 77 | 76 |
| 78 void ChildProcess::set_main_thread(ChildThreadImpl* thread) { | 77 void ChildProcess::set_main_thread(ChildThreadImpl* thread) { |
| 79 main_thread_.reset(thread); | 78 main_thread_.reset(thread); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 memset(&sa, 0, sizeof(sa)); | 137 memset(&sa, 0, sizeof(sa)); |
| 139 sa.sa_handler = SigUSR1Handler; | 138 sa.sa_handler = SigUSR1Handler; |
| 140 sigaction(SIGUSR1, &sa, NULL); | 139 sigaction(SIGUSR1, &sa, NULL); |
| 141 | 140 |
| 142 pause(); | 141 pause(); |
| 143 #endif // defined(OS_ANDROID) | 142 #endif // defined(OS_ANDROID) |
| 144 #endif // defined(OS_POSIX) | 143 #endif // defined(OS_POSIX) |
| 145 } | 144 } |
| 146 | 145 |
| 147 } // namespace content | 146 } // namespace content |
| OLD | NEW |