summaryrefslogtreecommitdiffstats
path: root/chrome/common/child_process.cc
diff options
context:
space:
mode:
authordeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-07 14:10:08 +0000
committerdeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-07 14:10:08 +0000
commitdd6ad6dd02501f33768037ced54ff3eaedf9bbb6 (patch)
tree85f93be898260d0f4ee90292ac7d1ad57bf6442b /chrome/common/child_process.cc
parentb0b373d689287801f0057377ff9fea98b2accfa4 (diff)
downloadchromium_src-dd6ad6dd02501f33768037ced54ff3eaedf9bbb6.zip
chromium_src-dd6ad6dd02501f33768037ced54ff3eaedf9bbb6.tar.gz
chromium_src-dd6ad6dd02501f33768037ced54ff3eaedf9bbb6.tar.bz2
Move away from the deprecated atomic.h interface to AtomicRefCount and AtomicSequenceNumber.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@510 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/child_process.cc')
-rw-r--r--chrome/common/child_process.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/chrome/common/child_process.cc b/chrome/common/child_process.cc
index 9c4310a..f501ba5 100644
--- a/chrome/common/child_process.cc
+++ b/chrome/common/child_process.cc
@@ -30,11 +30,12 @@
#include <windows.h>
#include "chrome/common/child_process.h"
+#include "base/atomic_ref_count.h"
#include "base/basictypes.h"
ChildProcess* ChildProcess::child_process_;
MessageLoop* ChildProcess::main_thread_loop_;
-LONG ChildProcess::ref_count_;
+static base::AtomicRefCount ref_count;
HANDLE ChildProcess::shutdown_event_;
@@ -48,17 +49,23 @@ ChildProcess::~ChildProcess() {
// Called on any thread
void ChildProcess::AddRefProcess() {
- InterlockedIncrement(&ref_count_);
+ base::AtomicRefCountInc(&ref_count);
}
// Called on any thread
void ChildProcess::ReleaseProcess() {
- DCHECK(ref_count_ > 0);
+ DCHECK(!base::AtomicRefCountIsZero(&ref_count));
DCHECK(child_process_);
- if (InterlockedDecrement(&ref_count_) == 0)
+ if (!base::AtomicRefCountDec(&ref_count))
child_process_->OnFinalRelease();
}
+// Called on any thread
+// static
+bool ChildProcess::ProcessRefCountIsZero() {
+ return base::AtomicRefCountIsZero(&ref_count);
+}
+
void ChildProcess::OnFinalRelease() {
DCHECK(main_thread_loop_);
main_thread_loop_->Quit();