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

Unified Diff: base/metrics/histogram_samples.cc

Issue 1524853002: Don't use a delgating constructor passing a member variable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/metrics/histogram_samples.cc
diff --git a/base/metrics/histogram_samples.cc b/base/metrics/histogram_samples.cc
index b6303a53b469cbdbb9602fa3009cefc230e121c5..4cd8e556b81c556dff9c2050348c47449c2d06c9 100644
--- a/base/metrics/histogram_samples.cc
+++ b/base/metrics/histogram_samples.cc
@@ -59,8 +59,16 @@ void SampleCountPickleIterator::Get(HistogramBase::Sample* min,
} // namespace
+// Don't try to delegate behavior to the constructor below that accepts a
+// Matadata pointer by passing &local_meta_. Such cannot be reliably passed
Nico 2015/12/14 20:49:01 typo matadata
+// because it has not yet been constructed -- no member variables have; the
+// class itself is in the middle of being constructed. Using it to
+// initialize meta_ is okay because the object now exists and local_meta_
+// is before meta_ in the construction order.
HistogramSamples::HistogramSamples(uint64_t id)
- : HistogramSamples(id, &local_meta_) {}
+ : meta_(&local_meta_) {
+ meta_->id = id;
+}
HistogramSamples::HistogramSamples(uint64_t id, Metadata* meta)
: meta_(meta) {
« 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