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

Unified Diff: base/memory/weak_ptr.h

Issue 1602443003: Improve GetWeakPtr() to better protect against unsafe usage patterns. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 33d1e473624583d9c7ec7e7c84afbe844608187f..25de4ed718df3891cc33f06a48cd0337e852d830 100644
--- a/base/memory/weak_ptr.h
+++ b/base/memory/weak_ptr.h
@@ -272,6 +272,9 @@ class WeakPtrFactory {
ptr_ = NULL;
}
+ // Returns a new WeakPtr. This is not thread-safe - in general callers should
dcheng 2016/02/19 20:45:00 "in general" is only true for code that wants a we
Wez 2016/03/01 23:20:28 I've reworded the comment to be more explicit abou
+ // take and store a WeakPtr to pass to code that needs to post tasks rather
+ // than call GetWeakPtr() from different threads.
WeakPtr<T> GetWeakPtr() {
DCHECK(ptr_);
return WeakPtr<T>(weak_reference_owner_.GetRef(), ptr_);
« 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