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 | |
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
-rw-r--r-- | chrome/browser/render_widget_helper.cc | 3 | ||||
-rw-r--r-- | chrome/browser/render_widget_helper.h | 3 | ||||
-rw-r--r-- | chrome/common/child_process.cc | 15 | ||||
-rw-r--r-- | chrome/common/child_process.h | 4 | ||||
-rw-r--r-- | chrome/plugin/plugin_process.cc | 2 |
5 files changed, 16 insertions, 11 deletions
diff --git a/chrome/browser/render_widget_helper.cc b/chrome/browser/render_widget_helper.cc index 241b23b..cffcd65 100644 --- a/chrome/browser/render_widget_helper.cc +++ b/chrome/browser/render_widget_helper.cc @@ -60,7 +60,6 @@ RenderWidgetHelper::RenderWidgetHelper(int render_process_id) : render_process_id_(render_process_id), ui_loop_(MessageLoop::current()), event_(CreateEvent(NULL, FALSE /* auto-reset */, FALSE, NULL)), - next_routing_id_(0), block_popups_(false) { } @@ -73,7 +72,7 @@ RenderWidgetHelper::~RenderWidgetHelper() { } int RenderWidgetHelper::GetNextRoutingID() { - return InterlockedIncrement(&next_routing_id_); + return next_routing_id_.GetNext() + 1; } void RenderWidgetHelper::CancelResourceRequests(int render_widget_id) { diff --git a/chrome/browser/render_widget_helper.h b/chrome/browser/render_widget_helper.h index 1a7f939..baff4e4 100644 --- a/chrome/browser/render_widget_helper.h +++ b/chrome/browser/render_widget_helper.h @@ -32,6 +32,7 @@ #include <hash_map> +#include "base/atomic_sequence_num.h" #include "base/ref_counted.h" #include "base/lock.h" @@ -173,7 +174,7 @@ class RenderWidgetHelper : HANDLE event_; // The next routing id to use. - LONG next_routing_id_; + base::AtomicSequenceNumber next_routing_id_; // Whether popup blocking is enabled or not. bool block_popups_; 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); diff --git a/chrome/plugin/plugin_process.cc b/chrome/plugin/plugin_process.cc index 53c0a3a..ad8a578 100644 --- a/chrome/plugin/plugin_process.cc +++ b/chrome/plugin/plugin_process.cc @@ -93,7 +93,7 @@ void PluginProcess::OnFinalRelease() { } void PluginProcess::OnProcessShutdownTimeout() { - if (GetProcessRefcount() == 0) { + if (ProcessRefCountIsZero()) { // The plugin process shutdown sequence is a request response based // mechanism, where we send out an initial feeler request to the plugin // process host instance in the browser to verify if it is ok to shutdown |