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

Unified Diff: base/metrics/histogram_snapshot_manager.cc

Issue 1425533011: Support "shared" histograms between processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shmem-alloc
Patch Set: added a couple tests (and fixed related issues) Created 5 years, 1 month 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/metrics/histogram_snapshot_manager.cc
diff --git a/base/metrics/histogram_snapshot_manager.cc b/base/metrics/histogram_snapshot_manager.cc
index 0b3e9a4550c978c37852a7c2dd5e3539e7f38c14..ef1ab26284b4e20852acfe7a278446af7943fdea 100644
--- a/base/metrics/histogram_snapshot_manager.cc
+++ b/base/metrics/histogram_snapshot_manager.cc
@@ -22,27 +22,13 @@ HistogramSnapshotManager::~HistogramSnapshotManager() {
STLDeleteValues(&logged_samples_);
}
-void HistogramSnapshotManager::PrepareDeltas(
- HistogramBase::Flags flag_to_set,
- HistogramBase::Flags required_flags) {
- StatisticsRecorder::Histograms histograms;
- StatisticsRecorder::GetHistograms(&histograms);
- for (StatisticsRecorder::Histograms::const_iterator it = histograms.begin();
- histograms.end() != it;
- ++it) {
- (*it)->SetFlags(flag_to_set);
- if (((*it)->flags() & required_flags) == required_flags)
- PrepareDelta(**it);
- }
-}
-
void HistogramSnapshotManager::PrepareDelta(const HistogramBase& histogram) {
DCHECK(histogram_flattener_);
// Get up-to-date snapshot of sample stats.
scoped_ptr<HistogramSamples> snapshot(histogram.SnapshotSamples());
const std::string& histogram_name = histogram.histogram_name();
- const uint64_t histogram_id = histogram.name_hash();
+ const uint64_t histogram_hash = histogram.name_hash();
int corruption = histogram.FindCorruption(*snapshot);
@@ -66,10 +52,10 @@ void HistogramSnapshotManager::PrepareDelta(const HistogramBase& histogram) {
histogram_flattener_->InconsistencyDetected(
static_cast<HistogramBase::Inconsistency>(corruption));
// Don't record corrupt data to metrics services.
- int old_corruption = inconsistencies_[histogram_id];
+ int old_corruption = inconsistencies_[histogram_hash];
if (old_corruption == (corruption | old_corruption))
return; // We've already seen this corruption for this histogram.
- inconsistencies_[histogram_id] |= corruption;
+ inconsistencies_[histogram_hash] |= corruption;
histogram_flattener_->UniqueInconsistencyDetected(
static_cast<HistogramBase::Inconsistency>(corruption));
return;
@@ -77,12 +63,12 @@ void HistogramSnapshotManager::PrepareDelta(const HistogramBase& histogram) {
HistogramSamples* to_log;
std::map<uint64_t, HistogramSamples*>::iterator it =
- logged_samples_.find(histogram_id);
+ logged_samples_.find(histogram_hash);
if (it == logged_samples_.end()) {
to_log = snapshot.release();
// This histogram has not been logged before, add a new entry.
- logged_samples_[histogram_id] = to_log;
+ logged_samples_[histogram_hash] = to_log;
} else {
HistogramSamples* already_logged = it->second;
InspectLoggedSamplesInconsistency(*snapshot, already_logged);

Powered by Google App Engine
This is Rietveld 408576698