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

Unified Diff: base/metrics/statistics_recorder.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/statistics_recorder.cc
diff --git a/base/metrics/statistics_recorder.cc b/base/metrics/statistics_recorder.cc
index 84ebbc58dbc37fb7724180b34d157b22021ae222..5553a5681a23480d90330d3ca558b942e05dae62 100644
--- a/base/metrics/statistics_recorder.cc
+++ b/base/metrics/statistics_recorder.cc
@@ -24,6 +24,22 @@ base::LazyInstance<base::StatisticsRecorder>::Leaky g_statistics_recorder_ =
namespace base {
+StatisticsRecorder::HistogramIterator&
+StatisticsRecorder::HistogramIterator::operator++() {
+ const HistogramMap::iterator histograms_end = histograms_->end();
+ while (iter_ != histograms_end) {
+ ++iter_;
+ if (iter_ == histograms_end)
+ break;
+ if (!include_persistent_ && (iter_->second->flags() &
+ HistogramBase::kIsPersistent)) {
+ continue;
+ }
+ break;
+ }
+ return *this;
+}
+
// static
void StatisticsRecorder::Initialize() {
// Ensure that an instance of the StatisticsRecorder object is created.
@@ -59,10 +75,10 @@ HistogramBase* StatisticsRecorder::RegisterOrDeleteDuplicate(
histogram_to_return = histogram;
} else {
const std::string& name = histogram->histogram_name();
- uint64_t id = histogram->name_hash();
- HistogramMap::iterator it = histograms_->find(id);
+ uint64_t hash = histogram->name_hash();
+ HistogramMap::iterator it = histograms_->find(hash);
if (histograms_->end() == it) {
- (*histograms_)[id] = histogram;
+ (*histograms_)[hash] = histogram;
ANNOTATE_LEAKING_OBJECT_PTR(histogram); // see crbug.com/79322
// If there are callbacks for this histogram, we set the kCallbackExists
// flag.
@@ -296,7 +312,18 @@ StatisticsRecorder::OnSampleCallback StatisticsRecorder::FindCallback(
: OnSampleCallback();
}
-// private static
+// static
+StatisticsRecorder::HistogramIterator StatisticsRecorder::begin(
+ bool include_persistent) {
+ return HistogramIterator(histograms_->begin(), include_persistent);
+}
+
+// static
+StatisticsRecorder::HistogramIterator StatisticsRecorder::end() {
+ return HistogramIterator(histograms_->end(), true);
+}
+
+// static
void StatisticsRecorder::GetSnapshot(const std::string& query,
Histograms* snapshot) {
if (lock_ == NULL)

Powered by Google App Engine
This is Rietveld 408576698