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

Unified Diff: base/supports_user_data.cc

Issue 298023008: Make sure that when a SupportsUserData is destroyed, objects destroyed transitively see it as empty. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
Index: base/supports_user_data.cc
diff --git a/base/supports_user_data.cc b/base/supports_user_data.cc
index 2a0263ed0d1881e6552f04b44a34fadf3e441cb2..8c6bf9116a13fb54536367bcee489bf77d393600 100644
--- a/base/supports_user_data.cc
+++ b/base/supports_user_data.cc
@@ -35,6 +35,11 @@ void SupportsUserData::DetachUserDataThread() {
SupportsUserData::~SupportsUserData() {
DCHECK(thread_checker_.CalledOnValidThread() || user_data_.empty());
+ DataMap local_user_data;
+ user_data_.swap(local_user_data);
+ // Now this->user_data_ is empty, and any destructors called transitively from
+ // the destruction of |local_user_data| will see it that way instead of
+ // calling into a being-destroyed object.
Peter Kasting 2014/05/28 03:44:13 Nit: calling into -> examining
Jeffrey Yasskin 2014/05/28 05:45:26 Done.
}
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698