Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_METRICS_ENVIRONMENT_RECORDER_H_ | |
| 6 #define COMPONENTS_METRICS_ENVIRONMENT_RECORDER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 | |
| 12 class PrefService; | |
| 13 class PrefRegistrySimple; | |
| 14 | |
| 15 namespace metrics { | |
| 16 | |
| 17 class SystemProfileProto; | |
| 18 | |
| 19 // Stores system profile information to prefs for creating stability logs | |
| 20 // in the next launch of chrome, and reads data from previous launches. | |
| 21 class EnvironmentRecorder { | |
| 22 public: | |
| 23 explicit EnvironmentRecorder(PrefService* local_state); | |
| 24 ~EnvironmentRecorder(); | |
| 25 | |
| 26 // Serializes the system profile and records it in prefs for the next | |
| 27 // session. Returns the uncompressed serialized proto for passing to crash | |
| 28 // reports, or the empty string if the proto can't be serialized. | |
| 29 std::string SerializeAndRecordEnvironmentToPrefs( | |
| 30 const SystemProfileProto& system_profile); | |
| 31 | |
| 32 // Loads the system_profile data stored in a previous chrome session, and | |
| 33 // stores it in the |system_profile| object. | |
| 34 // Returns true iff a system profile was successfully read. | |
| 35 bool LoadEnvironmentFromPrefs(SystemProfileProto* system_profile); | |
| 36 | |
| 37 // Deletes system profile data from prefs. | |
| 38 void ClearEnvironmentFromPrefs(); | |
| 39 | |
| 40 // Stores a buildtime and version in prefs. | |
|
Alexei Svitkine (slow)
2017/02/17 16:02:22
Please expand comment to mention what buildtime is
Steven Holte
2017/02/17 20:21:32
Done.
| |
| 41 void SetBuildtimeAndVersion(int64_t buildtime, const std::string& version); | |
| 42 | |
| 43 // Gets the buildtime stored in prefs. | |
| 44 int64_t GetLastBuildtime(); | |
| 45 | |
| 46 // Gets the version stored in prefs. | |
| 47 std::string GetLastVersion(); | |
| 48 | |
| 49 static void RegisterPrefs(PrefRegistrySimple* registry); | |
| 50 | |
| 51 private: | |
| 52 PrefService* local_state_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(EnvironmentRecorder); | |
| 55 }; | |
| 56 | |
| 57 } // namespace metrics | |
| 58 | |
| 59 #endif // COMPONENTS_METRICS_ENVIRONMENT_RECORDER_H_ | |
| OLD | NEW |