Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1865)

Unified Diff: base/memory/weak_ptr.h

Issue 7677028: Make WeakPtr thread-safe, i.e. allow cross-thread copying of WeakPtr (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/memory/weak_ptr.cc » ('j') | base/memory/weak_ptr.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/weak_ptr.h
diff --git a/base/memory/weak_ptr.h b/base/memory/weak_ptr.h
index abda1af2eaa7e0abf54a9a79bd0d9f7a4a526538..792dc0f35a41a87ad9c1c0e185a453c260c05db6 100644
--- a/base/memory/weak_ptr.h
+++ b/base/memory/weak_ptr.h
@@ -69,7 +69,7 @@ class BASE_EXPORT WeakReference {
// via base::WeakPtr::~WeakPtr().
class Flag : public RefCountedThreadSafe<Flag> {
public:
- explicit Flag(Flag** handle);
+ explicit Flag();
void Invalidate();
bool IsValid() const;
@@ -82,11 +82,11 @@ class BASE_EXPORT WeakReference {
~Flag();
ThreadChecker thread_checker_;
- Flag** handle_;
+ bool valid_;
darin (slow to review) 2011/08/18 18:29:06 nit: valid_ -> is_valid_
};
WeakReference();
- WeakReference(Flag* flag);
+ WeakReference(scoped_refptr<Flag> flag);
darin (slow to review) 2011/08/18 18:29:06 nit: WeakReference(const scoped_refptr<Flag>& flag
willchan no longer on Chromium 2011/08/18 19:14:12 While I'm glad you seem to have this preference he
~WeakReference();
bool is_valid() const;
@@ -103,7 +103,7 @@ class BASE_EXPORT WeakReferenceOwner {
WeakReference GetRef() const;
bool HasRefs() const {
- return flag_ != NULL;
+ return flag_.get() && !flag_->HasOneRef();
}
void Invalidate();
@@ -114,7 +114,7 @@ class BASE_EXPORT WeakReferenceOwner {
}
private:
- mutable WeakReference::Flag* flag_;
+ mutable scoped_refptr<WeakReference::Flag> flag_;
};
// This class simplifies the implementation of WeakPtr's type conversion
« no previous file with comments | « no previous file | base/memory/weak_ptr.cc » ('j') | base/memory/weak_ptr.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698