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

Unified Diff: base/memory/weak_ptr.h

Issue 10387063: Let WeakPtrFactory operations fail once its dtor is called (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 | no next file » | no next file with comments »
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 b66f02431aac2aa48bcf9babc396de3d8e055095..f7bf677f1aac2886f569863265413989a1de0ce8 100644
--- a/base/memory/weak_ptr.h
+++ b/base/memory/weak_ptr.h
@@ -231,23 +231,30 @@ class WeakPtrFactory {
public:
explicit WeakPtrFactory(T* ptr) : ptr_(ptr) {
}
+ ~WeakPtrFactory(){
darin (slow to review) 2012/05/17 22:00:52 nit: add new line above the destructor
oshima 2012/05/17 22:16:43 Done.
+ ptr_ = NULL;
darin (slow to review) 2012/05/17 22:00:52 i wonder... should we null this out only in debug
oshima 2012/05/17 22:16:43 I wanted this to fail on trybots, which is release
+ }
WeakPtr<T> GetWeakPtr() {
+ DCHECK(ptr_);
return WeakPtr<T>(weak_reference_owner_.GetRef(), ptr_);
}
// Call this method to invalidate all existing weak pointers.
void InvalidateWeakPtrs() {
+ DCHECK(ptr_);
weak_reference_owner_.Invalidate();
}
// Call this method to determine if any weak pointers exist.
bool HasWeakPtrs() const {
+ DCHECK(ptr_);
return weak_reference_owner_.HasRefs();
}
// Indicates that this object will be used on another thread from now on.
void DetachFromThread() {
+ DCHECK(ptr_);
weak_reference_owner_.DetachFromThread();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698