Commit 39ee4b7b authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Convert perfetto_service.mojom to new Mojo types (7/n)

This CL converts,
- |Binding<TracingSessionHost>| to |Receiver<TracingSessionHost>|
- |Binding<TracingSessionClient>| to |Receiver<TracingSessionClient>|
- |TracingSessionHostPtr| to |Remote<TracingSessionHost>|
- |ProducerClientRequest| to |PendingReceiver<ProducerClient>|

Bug: 955171, 978694
Change-Id: I52566c7c7561149f73df2a5aa7ecd494eafdd489
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1843993Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#706391}
parent 6cd69069
...@@ -120,18 +120,18 @@ class ConsumerHost::StreamWriter { ...@@ -120,18 +120,18 @@ class ConsumerHost::StreamWriter {
ConsumerHost::TracingSession::TracingSession( ConsumerHost::TracingSession::TracingSession(
ConsumerHost* host, ConsumerHost* host,
mojo::PendingReceiver<mojom::TracingSessionHost> tracing_session_host, mojo::PendingReceiver<mojom::TracingSessionHost> tracing_session_host,
mojo::Remote<mojom::TracingSessionClient> tracing_session_client, mojo::PendingRemote<mojom::TracingSessionClient> tracing_session_client,
const perfetto::TraceConfig& trace_config, const perfetto::TraceConfig& trace_config,
mojom::TracingClientPriority priority) mojom::TracingClientPriority priority)
: host_(host), : host_(host),
tracing_session_client_(std::move(tracing_session_client)), tracing_session_client_(std::move(tracing_session_client)),
binding_(this, std::move(tracing_session_host)), receiver_(this, std::move(tracing_session_host)),
tracing_priority_(priority) { tracing_priority_(priority) {
host_->service()->RegisterTracingSession(this); host_->service()->RegisterTracingSession(this);
tracing_session_client_.set_disconnect_handler(base::BindOnce( tracing_session_client_.set_disconnect_handler(base::BindOnce(
&ConsumerHost::DestructTracingSession, base::Unretained(host))); &ConsumerHost::DestructTracingSession, base::Unretained(host)));
binding_.set_connection_error_handler(base::BindOnce( receiver_.set_disconnect_handler(base::BindOnce(
&ConsumerHost::DestructTracingSession, base::Unretained(host))); &ConsumerHost::DestructTracingSession, base::Unretained(host)));
privacy_filtering_enabled_ = false; privacy_filtering_enabled_ = false;
...@@ -527,14 +527,12 @@ void ConsumerHost::EnableTracing( ...@@ -527,14 +527,12 @@ void ConsumerHost::EnableTracing(
if (!weak_this) { if (!weak_this) {
return; return;
} }
mojo::Remote<mojom::TracingSessionClient>
tracing_session_client_remote(
std::move(tracing_session_client));
weak_this->tracing_session_ = weak_this->tracing_session_ =
std::make_unique<TracingSession>( std::make_unique<TracingSession>(
weak_this.get(), std::move(tracing_session_host), weak_this.get(), std::move(tracing_session_host),
std::move(tracing_session_client_remote), std::move(tracing_session_client), trace_config,
trace_config, priority); priority);
}, },
weak_factory_.GetWeakPtr(), std::move(tracing_session_host), weak_factory_.GetWeakPtr(), std::move(tracing_session_host),
std::move(tracing_session_client), trace_config, priority)); std::move(tracing_session_client), trace_config, priority));
......
...@@ -51,7 +51,7 @@ class ConsumerHost : public perfetto::Consumer, public mojom::ConsumerHost { ...@@ -51,7 +51,7 @@ class ConsumerHost : public perfetto::Consumer, public mojom::ConsumerHost {
TracingSession( TracingSession(
ConsumerHost* host, ConsumerHost* host,
mojo::PendingReceiver<mojom::TracingSessionHost> tracing_session_host, mojo::PendingReceiver<mojom::TracingSessionHost> tracing_session_host,
mojo::Remote<mojom::TracingSessionClient> tracing_session_client, mojo::PendingRemote<mojom::TracingSessionClient> tracing_session_client,
const perfetto::TraceConfig& trace_config, const perfetto::TraceConfig& trace_config,
mojom::TracingClientPriority priority); mojom::TracingClientPriority priority);
~TracingSession() override; ~TracingSession() override;
...@@ -98,7 +98,7 @@ class ConsumerHost : public perfetto::Consumer, public mojom::ConsumerHost { ...@@ -98,7 +98,7 @@ class ConsumerHost : public perfetto::Consumer, public mojom::ConsumerHost {
ConsumerHost* const host_; ConsumerHost* const host_;
mojo::Remote<mojom::TracingSessionClient> tracing_session_client_; mojo::Remote<mojom::TracingSessionClient> tracing_session_client_;
mojo::Binding<mojom::TracingSessionHost> binding_; mojo::Receiver<mojom::TracingSessionHost> receiver_;
bool privacy_filtering_enabled_ = false; bool privacy_filtering_enabled_ = false;
base::SequenceBound<StreamWriter> read_buffers_stream_writer_; base::SequenceBound<StreamWriter> read_buffers_stream_writer_;
RequestBufferUsageCallback request_buffer_usage_callback_; RequestBufferUsageCallback request_buffer_usage_callback_;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/system/data_pipe.h" #include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/public/cpp/system/data_pipe_drainer.h" #include "mojo/public/cpp/system/data_pipe_drainer.h"
#include "services/tracing/perfetto/perfetto_service.h" #include "services/tracing/perfetto/perfetto_service.h"
...@@ -48,6 +48,8 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient { ...@@ -48,6 +48,8 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient {
base::WithBaseSyncPrimitives(), base::WithBaseSyncPrimitives(),
base::TaskPriority::BEST_EFFORT})) { base::TaskPriority::BEST_EFFORT})) {
perfetto_service_ = std::make_unique<PerfettoService>(task_runner_); perfetto_service_ = std::make_unique<PerfettoService>(task_runner_);
tracing_session_host_ =
std::make_unique<mojo::Remote<mojom::TracingSessionHost>>();
base::RunLoop wait_for_construct; base::RunLoop wait_for_construct;
task_runner_->PostTaskAndReply( task_runner_->PostTaskAndReply(
FROM_HERE, FROM_HERE,
...@@ -58,8 +60,8 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient { ...@@ -58,8 +60,8 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient {
} }
~ThreadedPerfettoService() override { ~ThreadedPerfettoService() override {
if (binding_) { if (receiver_) {
task_runner_->DeleteSoon(FROM_HERE, std::move(binding_)); task_runner_->DeleteSoon(FROM_HERE, std::move(receiver_));
} }
task_runner_->DeleteSoon(FROM_HERE, std::move(producer_)); task_runner_->DeleteSoon(FROM_HERE, std::move(producer_));
...@@ -67,6 +69,9 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient { ...@@ -67,6 +69,9 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient {
task_runner_->DeleteSoon(FROM_HERE, std::move(consumer_)); task_runner_->DeleteSoon(FROM_HERE, std::move(consumer_));
} }
if (tracing_session_host_)
task_runner_->DeleteSoon(FROM_HERE, std::move(tracing_session_host_));
{ {
base::RunLoop wait_for_destruction; base::RunLoop wait_for_destruction;
task_runner_->PostTaskAndReply(FROM_HERE, base::DoNothing(), task_runner_->PostTaskAndReply(FROM_HERE, base::DoNothing(),
...@@ -145,11 +150,11 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient { ...@@ -145,11 +150,11 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient {
void EnableTracingOnSequence(const perfetto::TraceConfig& config) { void EnableTracingOnSequence(const perfetto::TraceConfig& config) {
mojo::PendingRemote<tracing::mojom::TracingSessionClient> mojo::PendingRemote<tracing::mojom::TracingSessionClient>
tracing_session_client; tracing_session_client;
binding_ = std::make_unique<mojo::Binding<mojom::TracingSessionClient>>( receiver_ = std::make_unique<mojo::Receiver<mojom::TracingSessionClient>>(
this, tracing_session_client.InitWithNewPipeAndPassReceiver()); this, tracing_session_client.InitWithNewPipeAndPassReceiver());
consumer_->EnableTracing( consumer_->EnableTracing(
mojo::MakeRequest(&tracing_session_host_), tracing_session_host_->BindNewPipeAndPassReceiver(),
std::move(tracing_session_client), std::move(config), std::move(tracing_session_client), std::move(config),
tracing::mojom::TracingClientPriority::kUserInitiated); tracing::mojom::TracingClientPriority::kUserInitiated);
} }
...@@ -164,8 +169,6 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient { ...@@ -164,8 +169,6 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient {
std::move(stream), std::move(callback))); std::move(stream), std::move(callback)));
} }
void FreeBuffers() { tracing_session_host_.reset(); }
void DisableTracing() { void DisableTracing() {
base::RunLoop wait_for_call; base::RunLoop wait_for_call;
task_runner_->PostTaskAndReply( task_runner_->PostTaskAndReply(
...@@ -290,8 +293,9 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient { ...@@ -290,8 +293,9 @@ class ThreadedPerfettoService : public mojom::TracingSessionClient {
std::unique_ptr<PerfettoService> perfetto_service_; std::unique_ptr<PerfettoService> perfetto_service_;
std::unique_ptr<ConsumerHost> consumer_; std::unique_ptr<ConsumerHost> consumer_;
std::unique_ptr<MockProducer> producer_; std::unique_ptr<MockProducer> producer_;
std::unique_ptr<mojo::Binding<mojom::TracingSessionClient>> binding_; std::unique_ptr<mojo::Receiver<mojom::TracingSessionClient>> receiver_;
tracing::mojom::TracingSessionHostPtr tracing_session_host_; std::unique_ptr<mojo::Remote<tracing::mojom::TracingSessionHost>>
tracing_session_host_;
bool tracing_enabled_ = false; bool tracing_enabled_ = false;
}; };
...@@ -503,8 +507,6 @@ TEST_F(TracingConsumerTest, FlushProducers) { ...@@ -503,8 +507,6 @@ TEST_F(TracingConsumerTest, FlushProducers) {
wait_for_packets.Run(); wait_for_packets.Run();
EXPECT_EQ(10u, matching_packet_count()); EXPECT_EQ(10u, matching_packet_count());
threaded_perfetto_service()->FreeBuffers();
} }
TEST_F(TracingConsumerTest, LargeDataSize) { TEST_F(TracingConsumerTest, LargeDataSize) {
...@@ -675,15 +677,15 @@ class MockConsumerHost : public mojom::TracingSessionClient { ...@@ -675,15 +677,15 @@ class MockConsumerHost : public mojom::TracingSessionClient {
mojom::TracingClientPriority priority) { mojom::TracingClientPriority priority) {
mojo::PendingRemote<tracing::mojom::TracingSessionClient> mojo::PendingRemote<tracing::mojom::TracingSessionClient>
tracing_session_client; tracing_session_client;
binding_.Bind(tracing_session_client.InitWithNewPipeAndPassReceiver()); receiver_.Bind(tracing_session_client.InitWithNewPipeAndPassReceiver());
binding_.set_connection_error_handler(base::BindOnce( receiver_.set_disconnect_handler(base::BindOnce(
&MockConsumerHost::OnConnectionLost, base::Unretained(this))); &MockConsumerHost::OnConnectionLost, base::Unretained(this)));
consumer_host_->EnableTracing(mojo::MakeRequest(&tracing_session_host_), consumer_host_->EnableTracing(
std::move(tracing_session_client), config, tracing_session_host_.BindNewPipeAndPassReceiver(),
priority); std::move(tracing_session_client), config, priority);
tracing_session_host_.set_connection_error_handler(base::BindOnce( tracing_session_host_.set_disconnect_handler(base::BindOnce(
&MockConsumerHost::OnConnectionLost, base::Unretained(this))); &MockConsumerHost::OnConnectionLost, base::Unretained(this)));
} }
...@@ -696,7 +698,7 @@ class MockConsumerHost : public mojom::TracingSessionClient { ...@@ -696,7 +698,7 @@ class MockConsumerHost : public mojom::TracingSessionClient {
void CloseTracingSession() { void CloseTracingSession() {
tracing_session_host_.reset(); tracing_session_host_.reset();
binding_.Close(); receiver_.reset();
} }
// mojom::TracingSessionClient implementation: // mojom::TracingSessionClient implementation:
...@@ -711,8 +713,8 @@ class MockConsumerHost : public mojom::TracingSessionClient { ...@@ -711,8 +713,8 @@ class MockConsumerHost : public mojom::TracingSessionClient {
void WaitForTracingDisabled() { wait_for_tracing_disabled_.Run(); } void WaitForTracingDisabled() { wait_for_tracing_disabled_.Run(); }
private: private:
tracing::mojom::TracingSessionHostPtr tracing_session_host_; mojo::Remote<tracing::mojom::TracingSessionHost> tracing_session_host_;
mojo::Binding<mojom::TracingSessionClient> binding_{this}; mojo::Receiver<mojom::TracingSessionClient> receiver_{this};
std::unique_ptr<ConsumerHost> consumer_host_; std::unique_ptr<ConsumerHost> consumer_host_;
base::RunLoop wait_for_connection_lost_; base::RunLoop wait_for_connection_lost_;
base::RunLoop wait_for_tracing_enabled_; base::RunLoop wait_for_tracing_enabled_;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/tracing/public/cpp/perfetto/perfetto_producer.h" #include "services/tracing/public/cpp/perfetto/perfetto_producer.h"
#include "services/tracing/public/cpp/perfetto/task_runner.h" #include "services/tracing/public/cpp/perfetto/task_runner.h"
#include "services/tracing/public/mojom/perfetto_service.mojom.h" #include "services/tracing/public/mojom/perfetto_service.mojom.h"
...@@ -106,7 +107,7 @@ class COMPONENT_EXPORT(TRACING_CPP) ProducerClient ...@@ -106,7 +107,7 @@ class COMPONENT_EXPORT(TRACING_CPP) ProducerClient
uint32_t data_sources_tracing_ = 0; uint32_t data_sources_tracing_ = 0;
std::unique_ptr<mojo::Receiver<mojom::ProducerClient>> receiver_; std::unique_ptr<mojo::Receiver<mojom::ProducerClient>> receiver_;
mojom::ProducerHostPtr producer_host_; mojo::Remote<mojom::ProducerHost> producer_host_;
std::unique_ptr<MojoSharedMemory> shared_memory_; std::unique_ptr<MojoSharedMemory> shared_memory_;
std::unique_ptr<perfetto::SharedMemoryArbiter> shared_memory_arbiter_; std::unique_ptr<perfetto::SharedMemoryArbiter> shared_memory_arbiter_;
perfetto::SharedMemoryArbiter* in_process_arbiter_ = nullptr; perfetto::SharedMemoryArbiter* in_process_arbiter_ = nullptr;
......
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