Commit 4fa1454b authored by Brian White's avatar Brian White Committed by Commit Bot

Add IsRecorded() method to ScopedActivity tracker.

Change-Id: I330fcde6b5413bee9f035866518f1bd4734220d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2095343
Auto-Submit: Brian White <bcwhite@chromium.org>
Reviewed-by: default avatarSigurður Ásgeirsson <siggi@chromium.org>
Commit-Queue: Brian White <bcwhite@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748775}
parent 98d5af2a
......@@ -685,6 +685,10 @@ ThreadActivityTracker::ScopedActivity::~ScopedActivity() {
tracker_->PopActivity(activity_id_);
}
bool ThreadActivityTracker::ScopedActivity::IsRecorded() {
return tracker_ && tracker_->IsRecorded(activity_id_);
}
void ThreadActivityTracker::ScopedActivity::ChangeTypeAndData(
Activity::Type type,
const ActivityData& data) {
......@@ -855,6 +859,10 @@ void ThreadActivityTracker::PopActivity(ActivityId id) {
header_->data_version.fetch_add(1, std::memory_order_release);
}
bool ThreadActivityTracker::IsRecorded(ActivityId id) {
return id < stack_slots_;
}
std::unique_ptr<ActivityUserData> ThreadActivityTracker::GetUserData(
ActivityId id,
ActivityTrackerMemoryAllocator* allocator) {
......
......@@ -639,6 +639,11 @@ class BASE_EXPORT ThreadActivityTracker {
const ActivityData& data);
~ScopedActivity();
// Indicates if this activity is actually being recorded. It may not be if
// (a) activity tracking is not enabled globally or
// (b) there was insufficient stack space to hold it.
bool IsRecorded();
// Changes some basic metadata about the activity.
void ChangeTypeAndData(Activity::Type type, const ActivityData& data);
......@@ -693,6 +698,9 @@ class BASE_EXPORT ThreadActivityTracker {
// Indicates that an activity has completed.
void PopActivity(ActivityId id);
// Indicates if an activity is actually being recorded.
bool IsRecorded(ActivityId id);
// Sets the user-data information for an activity.
std::unique_ptr<ActivityUserData> GetUserData(
ActivityId id,
......
......@@ -219,6 +219,7 @@ TEST_F(ActivityTrackerTest, ScopedTaskTest) {
ScopedTaskRunActivity activity1(task1);
ActivityUserData& user_data1 = activity1.user_data();
(void)user_data1; // Tell compiler it's been used.
EXPECT_TRUE(activity1.IsRecorded());
ASSERT_TRUE(tracker->CreateSnapshot(&snapshot));
ASSERT_EQ(1U, snapshot.activity_stack_depth);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment