diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 14:10:08 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 14:10:08 +0000 |
commit | dd6ad6dd02501f33768037ced54ff3eaedf9bbb6 (patch) | |
tree | 85f93be898260d0f4ee90292ac7d1ad57bf6442b /chrome/common | |
parent | b0b373d689287801f0057377ff9fea98b2accfa4 (diff) | |
download | chromium_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')
-rw-r--r-- | chrome/common/child_process.cc | 15 | ||||
-rw-r--r-- | chrome/common/child_process.h | 4 |
2 files changed, 12 insertions, 7 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(); diff --git a/chrome/common/child_process.h b/chrome/common/child_process.h index ca88d25..3d8c260 100644 --- a/chrome/common/child_process.h +++ b/chrome/common/child_process.h @@ -88,7 +88,7 @@ class ChildProcess { static bool GlobalInit(const std::wstring& channel_name, ChildProcessFactoryInterface* factory); - static int GetProcessRefcount() { return static_cast<int>(ref_count_);} + static bool ProcessRefCountIsZero(); // The singleton instance for this process. static ChildProcess* child_process_; @@ -105,8 +105,6 @@ class ChildProcess { // Derived classes can override this to handle any cleanup, called by // GlobalCleanup. virtual void Cleanup() {} - - static LONG ref_count_; static HANDLE shutdown_event_; DISALLOW_EVIL_CONSTRUCTORS(ChildProcess); |