Index: components/metrics/persistent_system_profile.cc |
diff --git a/components/metrics/persistent_system_profile.cc b/components/metrics/persistent_system_profile.cc |
index 526b1407f0fa7351be0bc3900c361847307c2432..dc4e7eb7a772e7ad88c62a9fbccc2c2cc0431c67 100644 |
--- a/components/metrics/persistent_system_profile.cc |
+++ b/components/metrics/persistent_system_profile.cc |
@@ -101,6 +101,22 @@ bool PersistentSystemProfile::RecordAllocator::Write( |
return true; |
} |
+bool PersistentSystemProfile::RecordAllocator::HasMoreData() const { |
+ if (alloc_reference_ == 0 && !NextSegment()) |
+ return false; |
+ |
+ char* block = |
+ allocator_->GetAsArray<char>(alloc_reference_, kTypeIdSystemProfile, |
+ base::PersistentMemoryAllocator::kSizeAny); |
+ if (!block) |
+ return false; |
+ |
+ RecordHeader header; |
+ header.as_atomic = base::subtle::Acquire_Load( |
+ reinterpret_cast<base::subtle::Atomic32*>(block + end_offset_)); |
+ return header.as_parts.type != kUnusedSpace; |
+} |
+ |
bool PersistentSystemProfile::RecordAllocator::Read(RecordType* type, |
std::string* record) const { |
*type = kUnusedSpace; |
@@ -276,6 +292,21 @@ void PersistentSystemProfile::SetSystemProfile( |
} |
} |
+void PersistentSystemProfile::SetSystemProfile( |
+ const SystemProfileProto& profile) { |
+ std::string serialized_profile; |
+ if (!profile.SerializeToString(&serialized_profile)) |
+ return; |
+ SetSystemProfile(serialized_profile); |
+} |
+ |
+// static |
+bool PersistentSystemProfile::HasSystemProfile( |
+ const base::PersistentMemoryAllocator& memory_allocator) { |
+ const RecordAllocator records(&memory_allocator); |
+ return records.HasMoreData(); |
+} |
+ |
// static |
bool PersistentSystemProfile::GetSystemProfile( |
const base::PersistentMemoryAllocator& memory_allocator, |