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

Unified Diff: components/metrics/persistent_system_profile.h

Issue 2938013002: Persist core system profile during startup. (Closed)
Patch Set: added test 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.cc ('k') | components/metrics/persistent_system_profile.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/persistent_system_profile.h
diff --git a/components/metrics/persistent_system_profile.h b/components/metrics/persistent_system_profile.h
index 1775dde9cd423575fe54adca6347101f30502312..2f687811bd74abc2f0cccc0fc9bc1f9449a2d92e 100644
--- a/components/metrics/persistent_system_profile.h
+++ b/components/metrics/persistent_system_profile.h
@@ -31,9 +31,12 @@ class PersistentSystemProfile {
base::PersistentMemoryAllocator* memory_allocator);
// Stores a complete system profile. Use the version taking the serialized
- // version if available to avoid multiple serialization actions.
- void SetSystemProfile(const std::string& serialized_profile);
- void SetSystemProfile(const SystemProfileProto& profile);
+ // version if available to avoid multiple serialization actions. The
+ // |complete| flag indicates that this profile contains all known information
+ // and can replace whatever exists. If the flag is false, the profile will be
+ // stored only if there is nothing else already present.
+ void SetSystemProfile(const std::string& serialized_profile, bool complete);
+ void SetSystemProfile(const SystemProfileProto& profile, bool complete);
// Tests if a persistent memory allocator contains an system profile.
static bool HasSystemProfile(
@@ -76,6 +79,9 @@ class PersistentSystemProfile {
base::PersistentMemoryAllocator* allocator() { return allocator_; }
+ bool has_complete_profile() { return has_complete_profile_; }
+ void set_complete_profile() { has_complete_profile_ = true; }
+
private:
// Advance to the next record segment in the memory allocator.
bool NextSegment() const;
@@ -97,6 +103,9 @@ class PersistentSystemProfile {
// This never changes but can't be "const" because vector calls operator=().
base::PersistentMemoryAllocator* allocator_; // Storage location.
+ // Indicates if a complete profile has been stored.
+ bool has_complete_profile_;
+
// These change even though the underlying data may be "const".
mutable uint32_t alloc_reference_; // Last storage block.
mutable size_t alloc_size_; // Size of the block.
@@ -109,6 +118,9 @@ class PersistentSystemProfile {
// instances.
std::vector<RecordAllocator> allocators_;
+ // Indicates if a complete profile has been stored to all allocators.
+ bool all_have_complete_profile_ = false;
+
THREAD_CHECKER(thread_checker_);
DISALLOW_COPY_AND_ASSIGN(PersistentSystemProfile);
« no previous file with comments | « components/metrics/metrics_log.cc ('k') | components/metrics/persistent_system_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698