diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-01 23:16:20 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-01 23:16:20 +0000 |
commit | bc581a6829fe49e43f4869075781d6dc94843f09 (patch) | |
tree | a94363488dadff28fe2c03f3a169b6ad2eeb02e8 /chrome/common/deprecated | |
parent | 10f33b1bd6c6adb6306759a45bf3a5c18221d878 (diff) | |
download | chromium_src-bc581a6829fe49e43f4869075781d6dc94843f09.zip chromium_src-bc581a6829fe49e43f4869075781d6dc94843f09.tar.gz chromium_src-bc581a6829fe49e43f4869075781d6dc94843f09.tar.bz2 |
Move base/lock and base/condition_variable to base/synchronization/
I kept a base/lock.h in place with a using statement to avoid updating
all callers in one CL.
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/6018013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70363 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/deprecated')
-rw-r--r-- | chrome/common/deprecated/event_sys-inl.h | 22 | ||||
-rw-r--r-- | chrome/common/deprecated/event_sys.h | 6 | ||||
-rw-r--r-- | chrome/common/deprecated/event_sys_unittest.cc | 14 |
3 files changed, 22 insertions, 20 deletions
diff --git a/chrome/common/deprecated/event_sys-inl.h b/chrome/common/deprecated/event_sys-inl.h index 835eabe..c92de62 100644 --- a/chrome/common/deprecated/event_sys-inl.h +++ b/chrome/common/deprecated/event_sys-inl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,11 +9,11 @@ #include <map> #include "base/basictypes.h" -#include "base/condition_variable.h" -#include "base/lock.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/port.h" +#include "base/synchronization/condition_variable.h" +#include "base/synchronization/lock.h" #include "chrome/common/deprecated/event_sys.h" // How to use Channels: @@ -65,9 +65,9 @@ class CallbackWaiters { ~CallbackWaiters() { DCHECK_EQ(0, waiter_count_); } - void WaitForCallbackToComplete(Lock* listeners_mutex) { + void WaitForCallbackToComplete(base::Lock* listeners_mutex) { { - AutoLock lock(mutex_); + base::AutoLock lock(mutex_); waiter_count_ += 1; listeners_mutex->Release(); while (!callback_done_) @@ -80,7 +80,7 @@ class CallbackWaiters { } void Signal() { - AutoLock lock(mutex_); + base::AutoLock lock(mutex_); callback_done_ = true; condvar_.Broadcast(); } @@ -88,8 +88,8 @@ class CallbackWaiters { protected: int waiter_count_; bool callback_done_; - Lock mutex_; - ConditionVariable condvar_; + base::Lock mutex_; + base::ConditionVariable condvar_; }; template <typename EventTraitsType, typename NotifyLock, @@ -119,7 +119,7 @@ class EventChannel { // Make sure all the listeners have been disconnected. Otherwise, they // will try to call RemoveListener() at a later date. #if defined(DEBUG) - AutoLock lock(listeners_mutex_); + base::AutoLock lock(listeners_mutex_); for (typename Listeners::iterator i = listeners_.begin(); i != listeners_.end(); ++i) { DCHECK(i->second) << "Listener not disconnected"; @@ -131,7 +131,7 @@ class EventChannel { // // Thread safe. void AddListener(Listener* listener) { - AutoLock lock(listeners_mutex_); + base::AutoLock lock(listeners_mutex_); typename Listeners::iterator found = listeners_.find(listener); if (found == listeners_.end()) { listeners_.insert(std::make_pair(listener, @@ -209,7 +209,7 @@ class EventChannel { // Remove while in callback. Owned and closed by the thread calling Remove(). CallbackWaiters* callback_waiters_; - Lock listeners_mutex_; // Protects all members above. + base::Lock listeners_mutex_; // Protects all members above. const EventType shutdown_event_; NotifyLock notify_lock_; diff --git a/chrome/common/deprecated/event_sys.h b/chrome/common/deprecated/event_sys.h index 6e34eb7..944ef1f 100644 --- a/chrome/common/deprecated/event_sys.h +++ b/chrome/common/deprecated/event_sys.h @@ -9,8 +9,10 @@ // TODO: This class should be removed or moved to Notifier code. // See Bug 42450 (http://code.google.com/p/chromium/issues/detail?id=42450). +namespace base { class AutoLock; class Lock; +} // An abstract base class for listening to events. // @@ -27,8 +29,8 @@ class EventListener { // See the -inl.h for details about the following. -template <typename EventTraits, typename NotifyLock = Lock, - typename ScopedNotifyLocker = AutoLock> +template <typename EventTraits, typename NotifyLock = base::Lock, + typename ScopedNotifyLocker = base::AutoLock> class EventChannel; class EventListenerHookup; diff --git a/chrome/common/deprecated/event_sys_unittest.cc b/chrome/common/deprecated/event_sys_unittest.cc index 1d35d5f..941543a 100644 --- a/chrome/common/deprecated/event_sys_unittest.cc +++ b/chrome/common/deprecated/event_sys_unittest.cc @@ -159,14 +159,14 @@ class ThreadTester : public EventListener<TestEvent>, }; struct ThreadArgs { - ConditionVariable* thread_running_cond; - Lock* thread_running_mutex; + base::ConditionVariable* thread_running_cond; + base::Lock* thread_running_mutex; bool thread_running; }; void Go() { - Lock thread_running_mutex; - ConditionVariable thread_running_cond(&thread_running_mutex); + base::Lock thread_running_mutex; + base::ConditionVariable thread_running_cond(&thread_running_mutex); ThreadArgs args; ThreadInfo info; args.thread_running_cond = &(thread_running_cond); @@ -225,10 +225,10 @@ class ThreadTester : public EventListener<TestEvent>, } Pair* pair_; - ConditionVariable remove_event_; - Lock remove_event_mutex_; + base::ConditionVariable remove_event_; + base::Lock remove_event_mutex_; bool remove_event_bool_; - Lock completed_mutex_; + base::Lock completed_mutex_; bool completed_; std::vector<ThreadInfo> threads_; ThreadArgs args_; |