| 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(); |
| 38 |
| 35 child_process_ = NULL; | 39 child_process_ = NULL; |
| 36 } | 40 } |
| 37 | 41 |
| 38 // Called on any thread | 42 // Called on any thread |
| 39 void ChildProcess::AddRefProcess() { | 43 void ChildProcess::AddRefProcess() { |
| 40 base::AtomicRefCountInc(&ref_count_); | 44 base::AtomicRefCountInc(&ref_count_); |
| 41 } | 45 } |
| 42 | 46 |
| 43 // Called on any thread | 47 // Called on any thread |
| 44 void ChildProcess::ReleaseProcess() { | 48 void ChildProcess::ReleaseProcess() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 57 bool ChildProcess::ProcessRefCountIsZero() { | 61 bool ChildProcess::ProcessRefCountIsZero() { |
| 58 return base::AtomicRefCountIsZero(&ref_count_); | 62 return base::AtomicRefCountIsZero(&ref_count_); |
| 59 } | 63 } |
| 60 | 64 |
| 61 void ChildProcess::OnFinalRelease() { | 65 void ChildProcess::OnFinalRelease() { |
| 62 if (child_thread_.get()) { | 66 if (child_thread_.get()) { |
| 63 child_thread_->owner_loop()->PostTask( | 67 child_thread_->owner_loop()->PostTask( |
| 64 FROM_HERE, new MessageLoop::QuitTask()); | 68 FROM_HERE, new MessageLoop::QuitTask()); |
| 65 } | 69 } |
| 66 } | 70 } |
| OLD | NEW |