Commit a2740099 authored by Stephen Nusko's avatar Stephen Nusko Committed by Commit Bot

Use the base class variable for the PerfettoProducer.

This prevents the producer from being set when a new trace gets started.
Also add a TODO to refactor the data source so this can't be forgotten.

Bug: 987887
Change-Id: I1a6d5efad9d635a4325c19dcce1a5cae9925bf0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1722938
Commit-Queue: Stephen Nusko <nuskos@chromium.org>
Auto-Submit: Stephen Nusko <nuskos@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681889}
parent 93a63643
...@@ -43,6 +43,8 @@ class COMPONENT_EXPORT(TRACING_CPP) PerfettoTracedProcess final { ...@@ -43,6 +43,8 @@ class COMPONENT_EXPORT(TRACING_CPP) PerfettoTracedProcess final {
PerfettoProducer* producer, PerfettoProducer* producer,
const perfetto::DataSourceConfig& data_source_config) = 0; const perfetto::DataSourceConfig& data_source_config) = 0;
// StopTracing must set |producer_| to nullptr before invoking the callback. // StopTracing must set |producer_| to nullptr before invoking the callback.
// TODO(nuskos): Refactor this so that the implementation doesn't have to
// remember to do this.
virtual void StopTracing( virtual void StopTracing(
base::OnceClosure stop_complete_callback = base::OnceClosure()) = 0; base::OnceClosure stop_complete_callback = base::OnceClosure()) = 0;
......
...@@ -67,8 +67,7 @@ class TracingSamplerProfilerDataSource ...@@ -67,8 +67,7 @@ class TracingSamplerProfilerDataSource
if (is_started_) { if (is_started_) {
profiler->StartTracing( profiler->StartTracing(
perfetto_producer_->CreateTraceWriter( producer_->CreateTraceWriter(data_source_config_.target_buffer()),
data_source_config_.target_buffer()),
data_source_config_.chrome_config().privacy_filtering_enabled()); data_source_config_.chrome_config().privacy_filtering_enabled());
} else if (is_startup_tracing_) { } else if (is_startup_tracing_) {
profiler->StartTracing(nullptr, /*should_enable_filtering=*/true); profiler->StartTracing(nullptr, /*should_enable_filtering=*/true);
...@@ -105,7 +104,6 @@ class TracingSamplerProfilerDataSource ...@@ -105,7 +104,6 @@ class TracingSamplerProfilerDataSource
DCHECK(!is_started_); DCHECK(!is_started_);
is_started_ = true; is_started_ = true;
is_startup_tracing_ = false; is_startup_tracing_ = false;
perfetto_producer_ = producer;
data_source_config_ = data_source_config; data_source_config_ = data_source_config;
bool should_enable_filtering = bool should_enable_filtering =
...@@ -123,7 +121,7 @@ class TracingSamplerProfilerDataSource ...@@ -123,7 +121,7 @@ class TracingSamplerProfilerDataSource
DCHECK(is_started_); DCHECK(is_started_);
is_started_ = false; is_started_ = false;
is_startup_tracing_ = false; is_startup_tracing_ = false;
perfetto_producer_ = nullptr; producer_ = nullptr;
for (auto* profiler : profilers_) { for (auto* profiler : profilers_) {
profiler->StopTracing(); profiler->StopTracing();
...@@ -149,7 +147,6 @@ class TracingSamplerProfilerDataSource ...@@ -149,7 +147,6 @@ class TracingSamplerProfilerDataSource
std::set<TracingSamplerProfiler*> profilers_; std::set<TracingSamplerProfiler*> profilers_;
bool is_startup_tracing_ = false; bool is_startup_tracing_ = false;
bool is_started_ = false; bool is_started_ = false;
PerfettoProducer* perfetto_producer_ = nullptr;
perfetto::DataSourceConfig data_source_config_; perfetto::DataSourceConfig data_source_config_;
static std::atomic<uint32_t> incremental_state_reset_id_; static std::atomic<uint32_t> incremental_state_reset_id_;
...@@ -488,8 +485,8 @@ void TracingSamplerProfiler::RegisterDataSource() { ...@@ -488,8 +485,8 @@ void TracingSamplerProfiler::RegisterDataSource() {
// static // static
void TracingSamplerProfiler::StartTracingForTesting( void TracingSamplerProfiler::StartTracingForTesting(
PerfettoProducer* producer) { PerfettoProducer* producer) {
TracingSamplerProfilerDataSource::Get()->StartTracing( TracingSamplerProfilerDataSource::Get()->StartTracingWithID(
producer, perfetto::DataSourceConfig()); 1, producer, perfetto::DataSourceConfig());
} }
// static // static
......
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