Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/common/child_process.h" | 5 #include "chrome/common/child_process.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/common/child_thread.h" | 9 #include "chrome/common/child_thread.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 // Signal this event before destroying the child process. That way all | 26 // Signal this event before destroying the child process. That way all |
| 27 // background threads can cleanup. | 27 // background threads can cleanup. |
| 28 // For example, in the renderer the RenderThread instances will be able to | 28 // For example, in the renderer the RenderThread instances will be able to |
| 29 // notice shutdown before the render process begins waiting for them to exit. | 29 // notice shutdown before the render process begins waiting for them to exit. |
| 30 shutdown_event_.Signal(); | 30 shutdown_event_.Signal(); |
| 31 | 31 |
| 32 if (child_thread_.get()) | 32 if (child_thread_.get()) |
| 33 child_thread_->Stop(); | 33 child_thread_->Stop(); |
| 34 | 34 |
| 35 // Make sure the child thread goes away first before setting child_process_ to | |
| 36 // NULL since it can use it. | |
| 37 child_thread_.reset(); | |
|
darin (slow to review)
2009/02/24 22:11:43
can you explain why this change is made?
| |
| 38 | |
| 39 child_process_ = NULL; | 35 child_process_ = NULL; |
| 40 } | 36 } |
| 41 | 37 |
| 42 // Called on any thread | 38 // Called on any thread |
| 43 void ChildProcess::AddRefProcess() { | 39 void ChildProcess::AddRefProcess() { |
| 44 base::AtomicRefCountInc(&ref_count_); | 40 base::AtomicRefCountInc(&ref_count_); |
| 45 } | 41 } |
| 46 | 42 |
| 47 // Called on any thread | 43 // Called on any thread |
| 48 void ChildProcess::ReleaseProcess() { | 44 void ChildProcess::ReleaseProcess() { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 61 bool ChildProcess::ProcessRefCountIsZero() { | 57 bool ChildProcess::ProcessRefCountIsZero() { |
| 62 return base::AtomicRefCountIsZero(&ref_count_); | 58 return base::AtomicRefCountIsZero(&ref_count_); |
| 63 } | 59 } |
| 64 | 60 |
| 65 void ChildProcess::OnFinalRelease() { | 61 void ChildProcess::OnFinalRelease() { |
| 66 if (child_thread_.get()) { | 62 if (child_thread_.get()) { |
| 67 child_thread_->owner_loop()->PostTask( | 63 child_thread_->owner_loop()->PostTask( |
| 68 FROM_HERE, new MessageLoop::QuitTask()); | 64 FROM_HERE, new MessageLoop::QuitTask()); |
| 69 } | 65 } |
| 70 } | 66 } |
| OLD | NEW |