summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 19:56:53 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 19:56:53 +0000
commit6aacd8d639d7bb6d85c83e91e97e78e6bda12a27 (patch)
tree83aa8593b3de5dabf1501b063565b3d3d0245a66
parent964e5633a2868cde519f6c281ec569d2c0e29ea6 (diff)
downloadchromium_src-6aacd8d639d7bb6d85c83e91e97e78e6bda12a27.zip
chromium_src-6aacd8d639d7bb6d85c83e91e97e78e6bda12a27.tar.gz
chromium_src-6aacd8d639d7bb6d85c83e91e97e78e6bda12a27.tar.bz2
Make WeakPtr more strict about its NonThreadSafe behavior.
BUG=none TEST=none Review URL: http://codereview.chromium.org/6657020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77681 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/weak_ptr.cc12
-rw-r--r--base/weak_ptr.h4
2 files changed, 13 insertions, 3 deletions
diff --git a/base/weak_ptr.cc b/base/weak_ptr.cc
index 86c89c1..c9a6f48 100644
--- a/base/weak_ptr.cc
+++ b/base/weak_ptr.cc
@@ -25,6 +25,16 @@ void WeakReference::Flag::Release() const {
RefCounted<Flag>::Release();
}
+void WeakReference::Flag::Invalidate() {
+ DCHECK(CalledOnValidThread());
+ handle_ = NULL;
+}
+
+bool WeakReference::Flag::IsValid() const {
+ DCHECK(CalledOnValidThread());
+ return handle_ != NULL;
+}
+
WeakReference::WeakReference() {
}
@@ -35,7 +45,7 @@ WeakReference::~WeakReference() {
}
bool WeakReference::is_valid() const {
- return flag_ && flag_->is_valid();
+ return flag_ && flag_->IsValid();
}
WeakReferenceOwner::WeakReferenceOwner() : flag_(NULL) {
diff --git a/base/weak_ptr.h b/base/weak_ptr.h
index 6168367..60da03f 100644
--- a/base/weak_ptr.h
+++ b/base/weak_ptr.h
@@ -71,8 +71,8 @@ class WeakReference {
void AddRef() const;
void Release() const;
- void Invalidate() { handle_ = NULL; }
- bool is_valid() const { return handle_ != NULL; }
+ void Invalidate();
+ bool IsValid() const;
void DetachFromThread() { base::NonThreadSafe::DetachFromThread(); }