Commit 50b04f5d authored by Nicolò Mazzucato's avatar Nicolò Mazzucato Committed by Commit Bot

Add categories to DataSourceDescriptor

The tracing categories have been added to the DataSourceDescriptor, so
that is possible to retrieve them through the ConsumerPort.

Change-Id: I779c8ebcb20028e2707ff9a29a14a5749ab07896
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1814357
Commit-Queue: Nicolò Mazzucato <nicomazz@google.com>
Auto-Submit: Nicolò Mazzucato <nicomazz@google.com>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699915}
parent 06b337cd
...@@ -11,11 +11,15 @@ ...@@ -11,11 +11,15 @@
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "services/tracing/public/cpp/perfetto/shared_memory.h" #include "services/tracing/public/cpp/perfetto/shared_memory.h"
#include "services/tracing/public/cpp/traced_process_impl.h"
#include "third_party/perfetto/include/perfetto/ext/tracing/core/commit_data_request.h" #include "third_party/perfetto/include/perfetto/ext/tracing/core/commit_data_request.h"
#include "third_party/perfetto/include/perfetto/ext/tracing/core/shared_memory_arbiter.h" #include "third_party/perfetto/include/perfetto/ext/tracing/core/shared_memory_arbiter.h"
#include "third_party/perfetto/include/perfetto/ext/tracing/core/startup_trace_writer_registry.h" #include "third_party/perfetto/include/perfetto/ext/tracing/core/startup_trace_writer_registry.h"
#include "third_party/perfetto/include/perfetto/ext/tracing/core/trace_writer.h" #include "third_party/perfetto/include/perfetto/ext/tracing/core/trace_writer.h"
#include "third_party/perfetto/include/perfetto/ext/tracing/ipc/producer_ipc_client.h" #include "third_party/perfetto/include/perfetto/ext/tracing/ipc/producer_ipc_client.h"
#include "third_party/perfetto/include/perfetto/protozero/scattered_heap_buffer.h"
#include "third_party/perfetto/include/perfetto/protozero/scattered_stream_writer.h"
#include "third_party/perfetto/protos/perfetto/common/track_event_descriptor.pbzero.h"
namespace tracing { namespace tracing {
namespace { namespace {
...@@ -81,6 +85,24 @@ void AndroidSystemProducer::NewDataSourceAdded( ...@@ -81,6 +85,24 @@ void AndroidSystemProducer::NewDataSourceAdded(
new_registration.set_will_notify_on_start(true); new_registration.set_will_notify_on_start(true);
new_registration.set_will_notify_on_stop(true); new_registration.set_will_notify_on_stop(true);
new_registration.set_handles_incremental_state_clear(true); new_registration.set_handles_incremental_state_clear(true);
// Add categories to the DataSourceDescriptor.
protozero::ScatteredHeapBuffer buffer;
protozero::ScatteredStreamWriter stream(&buffer);
perfetto::protos::pbzero::TrackEventDescriptor proto;
proto.Reset(&stream);
buffer.set_writer(&stream);
std::set<std::string> category_set;
tracing::TracedProcessImpl::GetInstance()->GetCategories(&category_set);
for (const std::string& s : category_set) {
proto.add_available_categories(s.c_str());
}
auto raw_proto = buffer.StitchSlices();
std::string track_event_descriptor_raw(raw_proto.begin(), raw_proto.end());
new_registration.set_track_event_descriptor_raw(track_event_descriptor_raw);
service_->RegisterDataSource(new_registration); service_->RegisterDataSource(new_registration);
} }
......
...@@ -13,11 +13,15 @@ ...@@ -13,11 +13,15 @@
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "services/tracing/public/cpp/perfetto/shared_memory.h" #include "services/tracing/public/cpp/perfetto/shared_memory.h"
#include "services/tracing/public/cpp/perfetto/trace_event_data_source.h" #include "services/tracing/public/cpp/perfetto/trace_event_data_source.h"
#include "services/tracing/public/cpp/traced_process_impl.h"
#include "services/tracing/public/mojom/constants.mojom.h" #include "services/tracing/public/mojom/constants.mojom.h"
#include "third_party/perfetto/include/perfetto/ext/tracing/core/commit_data_request.h" #include "third_party/perfetto/include/perfetto/ext/tracing/core/commit_data_request.h"
#include "third_party/perfetto/include/perfetto/ext/tracing/core/shared_memory_arbiter.h" #include "third_party/perfetto/include/perfetto/ext/tracing/core/shared_memory_arbiter.h"
#include "third_party/perfetto/include/perfetto/ext/tracing/core/startup_trace_writer_registry.h" #include "third_party/perfetto/include/perfetto/ext/tracing/core/startup_trace_writer_registry.h"
#include "third_party/perfetto/include/perfetto/ext/tracing/core/trace_writer.h" #include "third_party/perfetto/include/perfetto/ext/tracing/core/trace_writer.h"
#include "third_party/perfetto/include/perfetto/protozero/scattered_heap_buffer.h"
#include "third_party/perfetto/include/perfetto/protozero/scattered_stream_writer.h"
#include "third_party/perfetto/protos/perfetto/common/track_event_descriptor.pbzero.h"
namespace tracing { namespace tracing {
...@@ -99,6 +103,24 @@ void ProducerClient::NewDataSourceAdded( ...@@ -99,6 +103,24 @@ void ProducerClient::NewDataSourceAdded(
new_registration.set_will_notify_on_start(true); new_registration.set_will_notify_on_start(true);
new_registration.set_will_notify_on_stop(true); new_registration.set_will_notify_on_stop(true);
new_registration.set_handles_incremental_state_clear(true); new_registration.set_handles_incremental_state_clear(true);
// Add categories to the DataSourceDescriptor.
protozero::ScatteredHeapBuffer buffer;
protozero::ScatteredStreamWriter stream(&buffer);
perfetto::protos::pbzero::TrackEventDescriptor proto;
proto.Reset(&stream);
buffer.set_writer(&stream);
std::set<std::string> category_set;
tracing::TracedProcessImpl::GetInstance()->GetCategories(&category_set);
for (const std::string& s : category_set) {
proto.add_available_categories(s.c_str());
}
auto raw_proto = buffer.StitchSlices();
std::string track_event_descriptor_raw(raw_proto.begin(), raw_proto.end());
new_registration.set_track_event_descriptor_raw(track_event_descriptor_raw);
producer_host_->RegisterDataSource(std::move(new_registration)); producer_host_->RegisterDataSource(std::move(new_registration));
} }
......
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