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

Unified Diff: base/debug/activity_tracker.cc

Issue 2544853003: Store log messages in global activity tracker. (Closed)
Patch Set: added comment about NUL terminator Created 4 years 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
Index: base/debug/activity_tracker.cc
diff --git a/base/debug/activity_tracker.cc b/base/debug/activity_tracker.cc
index 59b63526488ffaa780c364e602027b1ac89fcc68..a1c05c1697339cda05c616c3598f4d0fc7a7734d 100644
--- a/base/debug/activity_tracker.cc
+++ b/base/debug/activity_tracker.cc
@@ -858,6 +858,19 @@ void GlobalActivityTracker::ReleaseUserDataMemory(
*reference = PersistentMemoryAllocator::kReferenceNull;
}
+void GlobalActivityTracker::RecordLogMessage(StringPiece message) {
+ // Allocate at least one extra byte so the string is NUL terminated. All
+ // memory returned by the allocator is guaranteed to be zeroed.
+ PersistentMemoryAllocator::Reference ref =
+ allocator_->Allocate(message.size() + 1, kTypeIdGlobalLogMessage);
+ char* memory = allocator_->GetAsArray<char>(ref, kTypeIdGlobalLogMessage,
+ message.size() + 1);
+ if (memory) {
+ memcpy(memory, message.data(), message.size());
+ allocator_->MakeIterable(ref);
+ }
+}
+
GlobalActivityTracker::GlobalActivityTracker(
std::unique_ptr<PersistentMemoryAllocator> allocator,
int stack_depth)

Powered by Google App Engine
This is Rietveld 408576698