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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 ChildProcess::~ChildProcess() { | 61 ChildProcess::~ChildProcess() { |
62 DCHECK(g_lazy_tls.Pointer()->Get() == this); | 62 DCHECK(g_lazy_tls.Pointer()->Get() == this); |
63 | 63 |
64 // Signal this event before destroying the child process. That way all | 64 // Signal this event before destroying the child process. That way all |
65 // background threads can cleanup. | 65 // background threads can cleanup. |
66 // For example, in the renderer the RenderThread instances will be able to | 66 // For example, in the renderer the RenderThread instances will be able to |
67 // notice shutdown before the render process begins waiting for them to exit. | 67 // notice shutdown before the render process begins waiting for them to exit. |
68 shutdown_event_.Signal(); | 68 shutdown_event_.Signal(); |
69 | 69 |
70 // Kill the main thread object before nulling child_process, since | |
71 // destruction code might depend on it. | |
72 if (main_thread_) { // null in unittests. | 70 if (main_thread_) { // null in unittests. |
73 main_thread_->Shutdown(); | 71 main_thread_->Shutdown(); |
74 main_thread_.reset(); | 72 if (main_thread_->ShouldBeDestroyed()) { |
| 73 main_thread_.reset(); |
| 74 } else { |
| 75 // Leak the main_thread_. See a comment in |
| 76 // RenderThreadImpl::ShouldBeDestroyed. |
| 77 main_thread_.release(); |
| 78 } |
75 } | 79 } |
76 | 80 |
77 g_lazy_tls.Pointer()->Set(NULL); | 81 g_lazy_tls.Pointer()->Set(NULL); |
78 io_thread_.Stop(); | 82 io_thread_.Stop(); |
79 } | 83 } |
80 | 84 |
81 ChildThreadImpl* ChildProcess::main_thread() { | 85 ChildThreadImpl* ChildProcess::main_thread() { |
82 return main_thread_.get(); | 86 return main_thread_.get(); |
83 } | 87 } |
84 | 88 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 memset(&sa, 0, sizeof(sa)); | 156 memset(&sa, 0, sizeof(sa)); |
153 sa.sa_handler = SigUSR1Handler; | 157 sa.sa_handler = SigUSR1Handler; |
154 sigaction(SIGUSR1, &sa, NULL); | 158 sigaction(SIGUSR1, &sa, NULL); |
155 | 159 |
156 pause(); | 160 pause(); |
157 #endif // defined(OS_ANDROID) | 161 #endif // defined(OS_ANDROID) |
158 #endif // defined(OS_POSIX) | 162 #endif // defined(OS_POSIX) |
159 } | 163 } |
160 | 164 |
161 } // namespace content | 165 } // namespace content |
OLD | NEW |