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

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: pkasting's comments 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
« no previous file with comments | « base/base.gyp ('k') | base/supports_user_data_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/supports_user_data.cc
diff --git a/base/supports_user_data.cc b/base/supports_user_data.cc
index 2a0263ed0d1881e6552f04b44a34fadf3e441cb2..9689014d4ad8ebe08b487e228f7fa67b6e052e7f 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
+ // examining a being-destroyed object.
}
} // namespace base
« no previous file with comments | « base/base.gyp ('k') | base/supports_user_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698