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

Unified Diff: components/metrics/metrics_log.cc

Issue 2918533003: Send metrics with embedded system profiles after system startup. (Closed)
Patch Set: addressed final review comments Created 3 years, 6 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 | « components/metrics/metrics_log.h ('k') | components/metrics/metrics_log_store.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/metrics_log.cc
diff --git a/components/metrics/metrics_log.cc b/components/metrics/metrics_log.cc
index 05233728ca900905655beb5fccf1b46a16310eda..4d3123c41e4ba26a9403c9a13a265583a21b84f3 100644
--- a/components/metrics/metrics_log.cc
+++ b/components/metrics/metrics_log.cc
@@ -11,8 +11,11 @@
#include "base/build_time.h"
#include "base/cpu.h"
+#include "base/metrics/histogram_base.h"
+#include "base/metrics/histogram_flattener.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/histogram_samples.h"
+#include "base/metrics/histogram_snapshot_manager.h"
#include "base/metrics/metrics_hashes.h"
#include "base/sys_info.h"
#include "base/time/time.h"
@@ -51,6 +54,28 @@ extern const int kUserActionEventLimit = 5000;
namespace {
+// A simple class to write histogram data to a log.
+class IndependentFlattener : public base::HistogramFlattener {
+ public:
+ explicit IndependentFlattener(MetricsLog* log) : log_(log) {}
+
+ // base::HistogramFlattener:
+ void RecordDelta(const base::HistogramBase& histogram,
+ const base::HistogramSamples& snapshot) override {
+ log_->RecordHistogramDelta(histogram.histogram_name(), snapshot);
+ }
+ void InconsistencyDetected(
+ base::HistogramBase::Inconsistency problem) override {}
+ void UniqueInconsistencyDetected(
+ base::HistogramBase::Inconsistency problem) override {}
+ void InconsistencyDetectedInLoggedCount(int amount) override {}
+
+ private:
+ MetricsLog* const log_;
+
+ DISALLOW_COPY_AND_ASSIGN(IndependentFlattener);
+};
+
// Any id less than 16 bytes is considered to be a testing id.
bool IsTestingID(const std::string& id) {
return id.size() < 16;
@@ -319,6 +344,15 @@ std::string MetricsLog::RecordEnvironment(
return serialized_proto;
}
+bool MetricsLog::LoadIndependentMetrics(MetricsProvider* metrics_provider) {
+ SystemProfileProto* system_profile = uma_proto()->mutable_system_profile();
+ IndependentFlattener flattener(this);
+ base::HistogramSnapshotManager snapshot_manager(&flattener);
+
+ return metrics_provider->ProvideIndependentMetrics(system_profile,
+ &snapshot_manager);
+}
+
bool MetricsLog::LoadSavedEnvironmentFromPrefs(std::string* app_version) {
DCHECK(app_version);
app_version->clear();
« no previous file with comments | « components/metrics/metrics_log.h ('k') | components/metrics/metrics_log_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698