Merge "Fix battery aggregates."
diff --git a/OWNERS b/OWNERS
index 3e319bc..b61ef9c 100644
--- a/OWNERS
+++ b/OWNERS
@@ -13,6 +13,7 @@
nuskos@google.com
khokhlov@google.com
ssid@google.com
+ddrone@google.com
# chromium.org aliases for DEPS on third_party/perfetto.
eseckler@chromium.org
diff --git a/include/perfetto/tracing/internal/track_event_data_source.h b/include/perfetto/tracing/internal/track_event_data_source.h
index f737054..e63f114 100644
--- a/include/perfetto/tracing/internal/track_event_data_source.h
+++ b/include/perfetto/tracing/internal/track_event_data_source.h
@@ -150,6 +150,7 @@
// - Two debug annotations
// - Track
// - Track + Lambda
+ // - Track + timestamp
// - Track + Lambda + timestamp
// - Track + one debug annotation
// - Track + two debug annotations
@@ -238,6 +239,22 @@
TrackEventInternal::GetTimeNs(), std::move(arg_function));
}
+ // Trace point with a track and overridden timestamp.
+ template <size_t CategoryIndex,
+ typename CategoryType,
+ typename TrackType,
+ typename TrackTypeCheck = typename std::enable_if<
+ std::is_convertible<TrackType, Track>::value>::type>
+ static void TraceForCategory(uint32_t instances,
+ const CategoryType& dynamic_category,
+ const char* event_name,
+ perfetto::protos::pbzero::TrackEvent::Type type,
+ const TrackType& track,
+ uint64_t timestamp) PERFETTO_NO_INLINE {
+ TraceForCategoryImpl<CategoryIndex>(instances, dynamic_category, event_name,
+ type, track, timestamp);
+ }
+
// Trace point with a track, a lambda function and an overridden timestamp.
// |timestamp| must be in nanoseconds in the trace clock timebase.
template <size_t CategoryIndex,
diff --git a/src/tracing/test/api_integrationtest.cc b/src/tracing/test/api_integrationtest.cc
index 1d48dd5..d44489a 100644
--- a/src/tracing/test/api_integrationtest.cc
+++ b/src/tracing/test/api_integrationtest.cc
@@ -1307,6 +1307,46 @@
perfetto::TrackEvent::EraseTrackDescriptor(track);
}
+TEST_F(PerfettoApiTest, TrackEventCustomTrackAndTimestampNoLambda) {
+ auto* tracing_session = NewTraceWithCategories({"bar"});
+ tracing_session->get()->StartBlocking();
+
+ perfetto::Track track(789);
+
+ constexpr uint64_t kBeginEventTime = 10;
+ constexpr uint64_t kEndEventTime = 15;
+ TRACE_EVENT_BEGIN("bar", "Event", track, kBeginEventTime);
+ TRACE_EVENT_END("bar", track, kEndEventTime);
+
+ perfetto::TrackEvent::Flush();
+ tracing_session->get()->StopBlocking();
+
+ std::vector<char> raw_trace = tracing_session->get()->ReadTraceBlocking();
+ perfetto::protos::gen::Trace trace;
+ ASSERT_TRUE(trace.ParseFromArray(raw_trace.data(), raw_trace.size()));
+
+ int event_count = 0;
+ for (const auto& packet : trace.packet()) {
+ if (!packet.has_track_event())
+ continue;
+ event_count++;
+ switch (packet.track_event().type()) {
+ case perfetto::protos::gen::TrackEvent::TYPE_SLICE_BEGIN:
+ EXPECT_EQ(packet.timestamp(), kBeginEventTime);
+ break;
+ case perfetto::protos::gen::TrackEvent::TYPE_SLICE_END:
+ EXPECT_EQ(packet.timestamp(), kEndEventTime);
+ break;
+ case perfetto::protos::gen::TrackEvent::TYPE_INSTANT:
+ case perfetto::protos::gen::TrackEvent::TYPE_COUNTER:
+ case perfetto::protos::gen::TrackEvent::TYPE_UNSPECIFIED:
+ ADD_FAILURE();
+ }
+ }
+
+ EXPECT_EQ(event_count, 2);
+}
+
TEST_F(PerfettoApiTest, TrackEventAnonymousCustomTrack) {
// Create a new trace session.
auto* tracing_session = NewTraceWithCategories({"bar"});