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

Unified Diff: components/metrics/environment_recorder.h

Issue 2687393004: Gather stability prefs into managing objects. (Closed)
Patch Set: Incorporate Feedback Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/metrics/clean_exit_beacon.cc ('k') | components/metrics/environment_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/environment_recorder.h
diff --git a/components/metrics/environment_recorder.h b/components/metrics/environment_recorder.h
new file mode 100644
index 0000000000000000000000000000000000000000..0042d2e7d95b99e570cfa1c65acded4abebf037d
--- /dev/null
+++ b/components/metrics/environment_recorder.h
@@ -0,0 +1,59 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_METRICS_ENVIRONMENT_RECORDER_H_
+#define COMPONENTS_METRICS_ENVIRONMENT_RECORDER_H_
+
+#include <string>
+
+#include "base/macros.h"
+
+class PrefService;
+class PrefRegistrySimple;
+
+namespace metrics {
+
+class SystemProfileProto;
+
+// Stores system profile information to prefs for creating stability logs
+// in the next launch of chrome, and reads data from previous launches.
+class EnvironmentRecorder {
+ public:
+ explicit EnvironmentRecorder(PrefService* local_state);
+ ~EnvironmentRecorder();
+
+ // Serializes the system profile and records it in prefs for the next
+ // session. Returns the uncompressed serialized proto for passing to crash
+ // reports, or the empty string if the proto can't be serialized.
+ std::string SerializeAndRecordEnvironmentToPrefs(
+ const SystemProfileProto& system_profile);
+
+ // Loads the system_profile data stored in a previous chrome session, and
+ // stores it in the |system_profile| object.
+ // Returns true iff a system profile was successfully read.
+ bool LoadEnvironmentFromPrefs(SystemProfileProto* system_profile);
+
+ // Deletes system profile data from prefs.
+ void ClearEnvironmentFromPrefs();
+
+ // Stores the buildtime of the current binary and version in prefs.
+ void SetBuildtimeAndVersion(int64_t buildtime, const std::string& version);
+
+ // Gets the buildtime stored in prefs.
+ int64_t GetLastBuildtime();
+
+ // Gets the version stored in prefs.
+ std::string GetLastVersion();
+
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ private:
+ PrefService* local_state_;
+
+ DISALLOW_COPY_AND_ASSIGN(EnvironmentRecorder);
+};
+
+} // namespace metrics
+
+#endif // COMPONENTS_METRICS_ENVIRONMENT_RECORDER_H_
« no previous file with comments | « components/metrics/clean_exit_beacon.cc ('k') | components/metrics/environment_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698