Trace Redaction - Rename "BuildTimeline" to "CollectTimelineEvents"

The "BuildTimeline" primitive was not a build primitive; it was a
collect primitive. The "OptimizeTimeline" was a build primitive.

This CL changes the collect primitive (BuildTimeline) to better name
(CollectTimelineEvents).

Change-Id: I4999e7f995b2b0b45e7bc21f6fe329b51a255cb2
diff --git a/Android.bp b/Android.bp
index 40484c4..1683b53 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12859,7 +12859,7 @@
 filegroup {
     name: "perfetto_src_trace_redaction_trace_redaction",
     srcs: [
-        "src/trace_redaction/build_timeline.cc",
+        "src/trace_redaction/collect_timeline_events.cc",
         "src/trace_redaction/filter_ftrace_using_allowlist.cc",
         "src/trace_redaction/filter_packet_using_allowlist.cc",
         "src/trace_redaction/filter_print_events.cc",
@@ -12888,7 +12888,7 @@
 filegroup {
     name: "perfetto_src_trace_redaction_unittests",
     srcs: [
-        "src/trace_redaction/build_timeline_unittest.cc",
+        "src/trace_redaction/collect_timeline_events_unittest.cc",
         "src/trace_redaction/filter_ftrace_using_allowlist_unittest.cc",
         "src/trace_redaction/filter_packet_using_allowlist_unittest.cc",
         "src/trace_redaction/filter_sched_waking_events_unittest.cc",
diff --git a/src/trace_redaction/BUILD.gn b/src/trace_redaction/BUILD.gn
index 08abf3c..3dc9cdf 100644
--- a/src/trace_redaction/BUILD.gn
+++ b/src/trace_redaction/BUILD.gn
@@ -28,8 +28,8 @@
 
 source_set("trace_redaction") {
   sources = [
-    "build_timeline.cc",
-    "build_timeline.h",
+    "collect_timeline_events.cc",
+    "collect_timeline_events.h",
     "filter_ftrace_using_allowlist.cc",
     "filter_ftrace_using_allowlist.h",
     "filter_packet_using_allowlist.cc",
@@ -118,7 +118,7 @@
 perfetto_unittest_source_set("unittests") {
   testonly = true
   sources = [
-    "build_timeline_unittest.cc",
+    "collect_timeline_events_unittest.cc",
     "filter_ftrace_using_allowlist_unittest.cc",
     "filter_packet_using_allowlist_unittest.cc",
     "filter_sched_waking_events_unittest.cc",
diff --git a/src/trace_redaction/build_timeline.cc b/src/trace_redaction/collect_timeline_events.cc
similarity index 96%
rename from src/trace_redaction/build_timeline.cc
rename to src/trace_redaction/collect_timeline_events.cc
index 8c44f82..c5a98a7 100644
--- a/src/trace_redaction/build_timeline.cc
+++ b/src/trace_redaction/collect_timeline_events.cc
@@ -14,9 +14,8 @@
  * limitations under the License.
  */
 
-#include "src/trace_redaction/build_timeline.h"
+#include "src/trace_redaction/collect_timeline_events.h"
 
-#include "perfetto/ext/base/status_or.h"
 #include "src/trace_redaction/process_thread_timeline.h"
 #include "src/trace_redaction/trace_redaction_framework.h"
 
@@ -109,7 +108,7 @@
 
 }  // namespace
 
-base::Status BuildTimeline::Collect(const TracePacket::Decoder& packet,
+base::Status CollectTimelineEvents::Collect(const TracePacket::Decoder& packet,
                                     Context* context) const {
   // TODO(vaage): This should only be true on the first call. However, that
   // means a branch is called N times when N-1 times it will be false. This may
diff --git a/src/trace_redaction/build_timeline.h b/src/trace_redaction/collect_timeline_events.h
similarity index 82%
rename from src/trace_redaction/build_timeline.h
rename to src/trace_redaction/collect_timeline_events.h
index d39474f..fb29062 100644
--- a/src/trace_redaction/build_timeline.h
+++ b/src/trace_redaction/collect_timeline_events.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef SRC_TRACE_REDACTION_BUILD_TIMELINE_H_
-#define SRC_TRACE_REDACTION_BUILD_TIMELINE_H_
+#ifndef SRC_TRACE_REDACTION_COLLECT_TIMELINE_EVENTS_H_
+#define SRC_TRACE_REDACTION_COLLECT_TIMELINE_EVENTS_H_
 
 #include "src/trace_redaction/trace_redaction_framework.h"
 
@@ -25,7 +25,7 @@
 
 // Creates events from process_tree, task_newtask, and sched_process_free
 // packets and stores them in a timeline.
-class BuildTimeline : public CollectPrimitive {
+class CollectTimelineEvents : public CollectPrimitive {
  public:
   base::Status Collect(const protos::pbzero::TracePacket::Decoder& packet,
                        Context* context) const override;
@@ -33,4 +33,4 @@
 
 }  // namespace perfetto::trace_redaction
 
-#endif  // SRC_TRACE_REDACTION_BUILD_TIMELINE_H_
+#endif  // SRC_TRACE_REDACTION_COLLECT_TIMELINE_EVENTS_H_
diff --git a/src/trace_redaction/build_timeline_unittest.cc b/src/trace_redaction/collect_timeline_events_unittest.cc
similarity index 91%
rename from src/trace_redaction/build_timeline_unittest.cc
rename to src/trace_redaction/collect_timeline_events_unittest.cc
index 6041afd..14aa982 100644
--- a/src/trace_redaction/build_timeline_unittest.cc
+++ b/src/trace_redaction/collect_timeline_events_unittest.cc
@@ -18,7 +18,7 @@
 #include <string>
 
 #include "src/base/test/status_matchers.h"
-#include "src/trace_redaction/build_timeline.h"
+#include "src/trace_redaction/collect_timeline_events.h"
 #include "src/trace_redaction/trace_redaction_framework.h"
 
 #include "protos/perfetto/trace/ftrace/ftrace_event.gen.h"
@@ -87,7 +87,7 @@
 
 }  // namespace
 
-class BuildTimelineTest : public testing::Test,
+class CollectTimelineEventsTest : public testing::Test,
                           public testing::WithParamInterface<TestParams> {
  protected:
   base::Status PushProcessTreePacket(uint64_t timestamp) {
@@ -147,13 +147,13 @@
                           &context_);
   }
 
-  BuildTimeline build_;
+  CollectTimelineEvents build_;
   Context context_;
 };
 
-class BuildTimelineWithProcessTree : public BuildTimelineTest {};
+class CollectTimelineEventsWithProcessTree : public CollectTimelineEventsTest {};
 
-TEST_P(BuildTimelineWithProcessTree, FindsOpenSpans) {
+TEST_P(CollectTimelineEventsWithProcessTree, FindsOpenSpans) {
   auto params = GetParam();
 
   auto result = PushProcessTreePacket(kProcessTreeTimestamp);
@@ -168,7 +168,7 @@
 
 INSTANTIATE_TEST_SUITE_P(
     AcrossWholeTimeline,
-    BuildTimelineWithProcessTree,
+    CollectTimelineEventsWithProcessTree,
     testing::Values(
         // Before the processes/threads existed.
         TestParams(0, kZygotePid, kNoPackage),
@@ -185,10 +185,10 @@
         TestParams(kProcessTreeTimestamp + 1, kUnityPid, kUnityPackage),
         TestParams(kProcessTreeTimestamp + 1, kUnityTid, kUnityPackage)));
 
-// Assumes all BuildTimelineWithProcessTree tests pass.
-class BuildTimelineWithFreeProcess : public BuildTimelineTest {};
+// Assumes all CollectTimelineEventsWithProcessTree tests pass.
+class CollectTimelineEventsWithFreeProcess : public CollectTimelineEventsTest {};
 
-TEST_P(BuildTimelineWithFreeProcess, FindsClosedSpans) {
+TEST_P(CollectTimelineEventsWithFreeProcess, FindsClosedSpans) {
   auto params = GetParam();
 
   auto result = PushProcessTreePacket(kProcessTreeTimestamp);
@@ -206,7 +206,7 @@
 
 INSTANTIATE_TEST_SUITE_P(
     AcrossWholeTimeline,
-    BuildTimelineWithFreeProcess,
+    CollectTimelineEventsWithFreeProcess,
     testing::Values(
         TestParams(kThreadFreeTimestamp - 1, kZygotePid, kNoPackage),
         TestParams(kThreadFreeTimestamp - 1, kUnityPid, kUnityPackage),
diff --git a/src/trace_redaction/filter_sched_waking_events_integrationtest.cc b/src/trace_redaction/filter_sched_waking_events_integrationtest.cc
index 03c53c4..d86bf74 100644
--- a/src/trace_redaction/filter_sched_waking_events_integrationtest.cc
+++ b/src/trace_redaction/filter_sched_waking_events_integrationtest.cc
@@ -21,7 +21,7 @@
 #include "perfetto/base/status.h"
 #include "perfetto/ext/base/flat_hash_map.h"
 #include "src/base/test/status_matchers.h"
-#include "src/trace_redaction/build_timeline.h"
+#include "src/trace_redaction/collect_timeline_events.h"
 #include "src/trace_redaction/filter_sched_waking_events.h"
 #include "src/trace_redaction/find_package_uid.h"
 #include "src/trace_redaction/optimize_timeline.h"
@@ -49,7 +49,7 @@
  protected:
   void SetUp() override {
     trace_redactor()->emplace_collect<FindPackageUid>();
-    trace_redactor()->emplace_collect<BuildTimeline>();
+    trace_redactor()->emplace_collect<CollectTimelineEvents>();
     trace_redactor()->emplace_build<OptimizeTimeline>();
 
     auto* ftrace_filter =
diff --git a/src/trace_redaction/filter_task_rename_integrationtest.cc b/src/trace_redaction/filter_task_rename_integrationtest.cc
index babc2ce..14c66dd 100644
--- a/src/trace_redaction/filter_task_rename_integrationtest.cc
+++ b/src/trace_redaction/filter_task_rename_integrationtest.cc
@@ -21,10 +21,10 @@
 
 #include "perfetto/base/status.h"
 #include "src/base/test/status_matchers.h"
-#include "src/trace_redaction/build_timeline.h"
+#include "src/trace_redaction/collect_timeline_events.h"
+#include "src/trace_redaction/filter_task_rename.h"
 #include "src/trace_redaction/find_package_uid.h"
 #include "src/trace_redaction/optimize_timeline.h"
-#include "src/trace_redaction/filter_task_rename.h"
 #include "src/trace_redaction/trace_redaction_framework.h"
 #include "src/trace_redaction/trace_redaction_integration_fixture.h"
 #include "src/trace_redaction/trace_redactor.h"
@@ -56,7 +56,7 @@
     // In order for ScrubTaskRename to work, it needs the timeline. All
     // registered primitives are there to generate the timeline.
     trace_redactor()->emplace_collect<FindPackageUid>();
-    trace_redactor()->emplace_collect<BuildTimeline>();
+    trace_redactor()->emplace_collect<CollectTimelineEvents>();
     trace_redactor()->emplace_build<OptimizeTimeline>();
 
     auto scrub_ftrace_events =
diff --git a/src/trace_redaction/main.cc b/src/trace_redaction/main.cc
index 003ad78..3fa0080 100644
--- a/src/trace_redaction/main.cc
+++ b/src/trace_redaction/main.cc
@@ -16,7 +16,7 @@
 
 #include "perfetto/base/logging.h"
 #include "perfetto/base/status.h"
-#include "src/trace_redaction/build_timeline.h"
+#include "src/trace_redaction/collect_timeline_events.h"
 #include "src/trace_redaction/filter_ftrace_using_allowlist.h"
 #include "src/trace_redaction/filter_packet_using_allowlist.h"
 #include "src/trace_redaction/filter_print_events.h"
@@ -47,7 +47,7 @@
 
   // Add all collectors.
   redactor.emplace_collect<FindPackageUid>();
-  redactor.emplace_collect<BuildTimeline>();
+  redactor.emplace_collect<CollectTimelineEvents>();
 
   // Add all builders.
   redactor.emplace_build<PopulateAllowlists>();
diff --git a/src/trace_redaction/optimize_timeline.cc b/src/trace_redaction/optimize_timeline.cc
index f4f09e6..713f7c7 100644
--- a/src/trace_redaction/optimize_timeline.cc
+++ b/src/trace_redaction/optimize_timeline.cc
@@ -24,7 +24,8 @@
 base::Status OptimizeTimeline::Build(Context* context) const {
   if (!context->timeline) {
     return base::ErrStatus(
-        "Cannot optimize a null timeline. Are you missing BuildTimeline or an "
+        "Cannot optimize a null timeline. Are you missing "
+        "CollectTimelineEvents or an "
         "alternative?");
   }
 
diff --git a/src/trace_redaction/redact_sched_switch_integrationtest.cc b/src/trace_redaction/redact_sched_switch_integrationtest.cc
index 08f6cc8..3b3523f 100644
--- a/src/trace_redaction/redact_sched_switch_integrationtest.cc
+++ b/src/trace_redaction/redact_sched_switch_integrationtest.cc
@@ -20,7 +20,7 @@
 #include "perfetto/base/status.h"
 #include "perfetto/ext/base/flat_hash_map.h"
 #include "src/base/test/status_matchers.h"
-#include "src/trace_redaction/build_timeline.h"
+#include "src/trace_redaction/collect_timeline_events.h"
 #include "src/trace_redaction/find_package_uid.h"
 #include "src/trace_redaction/optimize_timeline.h"
 #include "src/trace_redaction/redact_sched_switch.h"
@@ -43,7 +43,7 @@
  protected:
   void SetUp() override {
     trace_redactor()->emplace_collect<FindPackageUid>();
-    trace_redactor()->emplace_collect<BuildTimeline>();
+    trace_redactor()->emplace_collect<CollectTimelineEvents>();
     trace_redactor()->emplace_build<OptimizeTimeline>();
 
     auto* ftrace_event_redactions =
diff --git a/src/trace_redaction/scrub_process_stats_integrationtest.cc b/src/trace_redaction/scrub_process_stats_integrationtest.cc
index 01c61b1..2b081e5 100644
--- a/src/trace_redaction/scrub_process_stats_integrationtest.cc
+++ b/src/trace_redaction/scrub_process_stats_integrationtest.cc
@@ -19,7 +19,7 @@
 
 #include "perfetto/base/status.h"
 #include "src/base/test/status_matchers.h"
-#include "src/trace_redaction/build_timeline.h"
+#include "src/trace_redaction/collect_timeline_events.h"
 #include "src/trace_redaction/optimize_timeline.h"
 #include "src/trace_redaction/scrub_process_stats.h"
 #include "src/trace_redaction/trace_redaction_framework.h"
@@ -37,7 +37,7 @@
                               protected TraceRedactionIntegrationFixure {
  protected:
   void SetUp() override {
-    trace_redactor()->emplace_collect<BuildTimeline>();
+    trace_redactor()->emplace_collect<CollectTimelineEvents>();
     trace_redactor()->emplace_build<OptimizeTimeline>();
     trace_redactor()->emplace_transform<ScrubProcessStats>();
 
diff --git a/src/trace_redaction/scrub_process_trees_integrationtest.cc b/src/trace_redaction/scrub_process_trees_integrationtest.cc
index c362ae2..58396b2 100644
--- a/src/trace_redaction/scrub_process_trees_integrationtest.cc
+++ b/src/trace_redaction/scrub_process_trees_integrationtest.cc
@@ -19,7 +19,7 @@
 #include <vector>
 
 #include "src/base/test/status_matchers.h"
-#include "src/trace_redaction/build_timeline.h"
+#include "src/trace_redaction/collect_timeline_events.h"
 #include "src/trace_redaction/find_package_uid.h"
 #include "src/trace_redaction/optimize_timeline.h"
 #include "src/trace_redaction/scrub_process_trees.h"
@@ -51,13 +51,13 @@
     //
     // OptimizeTimeline depends on:
     //    - FindPackageUid (uses: uid)
-    //    - BuildTimeline  (uses: timeline)
+    //    - CollectTimelineEvents  (uses: timeline)
     //
-    // BuildTimeline depends on.... nothing
+    // CollectTimelineEvents depends on.... nothing
     // FindPackageUid depends on... nothing
 
     trace_redactor()->emplace_collect<FindPackageUid>();
-    trace_redactor()->emplace_collect<BuildTimeline>();
+    trace_redactor()->emplace_collect<CollectTimelineEvents>();
     trace_redactor()->emplace_build<OptimizeTimeline>();
     trace_redactor()->emplace_transform<ScrubProcessTrees>();