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

Side by Side Diff: base/metrics/histogram_samples.cc

Issue 1537743006: Persist setup metrics and have Chrome report them during UMA upload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared-histograms
Patch Set: addressed final review comments by Alexei Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « base/metrics/histogram_persistence.cc ('k') | base/metrics/histogram_snapshot_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/histogram_samples.h" 5 #include "base/metrics/histogram_samples.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/pickle.h" 8 #include "base/pickle.h"
9 9
10 namespace base { 10 namespace base {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // initialize meta_ is okay because the object now exists and local_meta_ 66 // initialize meta_ is okay because the object now exists and local_meta_
67 // is before meta_ in the construction order. 67 // is before meta_ in the construction order.
68 HistogramSamples::HistogramSamples(uint64_t id) 68 HistogramSamples::HistogramSamples(uint64_t id)
69 : meta_(&local_meta_) { 69 : meta_(&local_meta_) {
70 meta_->id = id; 70 meta_->id = id;
71 } 71 }
72 72
73 HistogramSamples::HistogramSamples(uint64_t id, Metadata* meta) 73 HistogramSamples::HistogramSamples(uint64_t id, Metadata* meta)
74 : meta_(meta) { 74 : meta_(meta) {
75 DCHECK(meta_->id == 0 || meta_->id == id); 75 DCHECK(meta_->id == 0 || meta_->id == id);
76 meta_->id = id; 76
77 // It's possible that |meta| is contained in initialized, read-only memory
78 // so it's essential that no write be done in that case.
79 if (!meta_->id)
80 meta_->id = id;
77 } 81 }
78 82
79 HistogramSamples::~HistogramSamples() {} 83 HistogramSamples::~HistogramSamples() {}
80 84
81 // Despite using atomic operations, the increment/add actions below are *not* 85 // Despite using atomic operations, the increment/add actions below are *not*
82 // atomic! Race conditions may cause loss of samples or even completely corrupt 86 // atomic! Race conditions may cause loss of samples or even completely corrupt
83 // the 64-bit sum on 32-bit machines. This is done intentionally to reduce the 87 // the 64-bit sum on 32-bit machines. This is done intentionally to reduce the
84 // cost of these operations that could be executed in performance-significant 88 // cost of these operations that could be executed in performance-significant
85 // points of the code. 89 // points of the code.
86 // 90 //
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 163 }
160 164
161 SampleCountIterator::~SampleCountIterator() {} 165 SampleCountIterator::~SampleCountIterator() {}
162 166
163 bool SampleCountIterator::GetBucketIndex(size_t* index) const { 167 bool SampleCountIterator::GetBucketIndex(size_t* index) const {
164 DCHECK(!Done()); 168 DCHECK(!Done());
165 return false; 169 return false;
166 } 170 }
167 171
168 } // namespace base 172 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/histogram_persistence.cc ('k') | base/metrics/histogram_snapshot_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698