James Robinson | 115caf8 | 2015-04-07 12:52:40 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SERVICES_TRACING_TRACING_APP_H_ |
| 6 | #define SERVICES_TRACING_TRACING_APP_H_ |
| 7 | |
| 8 | #include "base/macros.h" |
| 9 | #include "base/memory/scoped_ptr.h" |
| 10 | #include "base/memory/scoped_vector.h" |
Mitch Rudominer | b543d0f | 2015-07-20 10:14:56 -0700 | [diff] [blame] | 11 | #include "mojo/common/interface_ptr_set.h" |
James Robinson | 115caf8 | 2015-04-07 12:52:40 -0700 | [diff] [blame] | 12 | #include "mojo/public/cpp/application/application_delegate.h" |
| 13 | #include "mojo/public/cpp/application/application_impl.h" |
| 14 | #include "mojo/public/cpp/bindings/strong_binding.h" |
Viet-Trung Luu | 0f4f3ba | 2015-10-10 01:08:40 -0700 | [diff] [blame] | 15 | #include "mojo/services/tracing/interfaces/tracing.mojom.h" |
James Robinson | 115caf8 | 2015-04-07 12:52:40 -0700 | [diff] [blame] | 16 | #include "services/tracing/trace_data_sink.h" |
Przemyslaw Pietrzkiewicz | 4825af9 | 2015-08-13 10:27:45 +0200 | [diff] [blame] | 17 | #include "services/tracing/trace_recorder_impl.h" |
James Robinson | 115caf8 | 2015-04-07 12:52:40 -0700 | [diff] [blame] | 18 | |
| 19 | namespace tracing { |
| 20 | |
| 21 | class TracingApp : public mojo::ApplicationDelegate, |
Przemyslaw Pietrzkiewicz | 4825af9 | 2015-08-13 10:27:45 +0200 | [diff] [blame] | 22 | public mojo::InterfaceFactory<TraceCollector>, |
| 23 | public TraceCollector { |
James Robinson | 115caf8 | 2015-04-07 12:52:40 -0700 | [diff] [blame] | 24 | public: |
| 25 | TracingApp(); |
| 26 | ~TracingApp() override; |
| 27 | |
| 28 | private: |
| 29 | // mojo::ApplicationDelegate implementation. |
| 30 | bool ConfigureIncomingConnection( |
| 31 | mojo::ApplicationConnection* connection) override; |
| 32 | |
Przemyslaw Pietrzkiewicz | 4825af9 | 2015-08-13 10:27:45 +0200 | [diff] [blame] | 33 | // mojo::InterfaceFactory<TraceCollector> implementation. |
James Robinson | 115caf8 | 2015-04-07 12:52:40 -0700 | [diff] [blame] | 34 | void Create(mojo::ApplicationConnection* connection, |
Przemyslaw Pietrzkiewicz | 4825af9 | 2015-08-13 10:27:45 +0200 | [diff] [blame] | 35 | mojo::InterfaceRequest<TraceCollector> request) override; |
James Robinson | 115caf8 | 2015-04-07 12:52:40 -0700 | [diff] [blame] | 36 | |
Przemyslaw Pietrzkiewicz | 4825af9 | 2015-08-13 10:27:45 +0200 | [diff] [blame] | 37 | // tracing::TraceCollector implementation. |
James Robinson | 115caf8 | 2015-04-07 12:52:40 -0700 | [diff] [blame] | 38 | void Start(mojo::ScopedDataPipeProducerHandle stream, |
| 39 | const mojo::String& categories) override; |
| 40 | void StopAndFlush() override; |
| 41 | |
| 42 | void AllDataCollected(); |
| 43 | |
| 44 | scoped_ptr<TraceDataSink> sink_; |
Przemyslaw Pietrzkiewicz | 4825af9 | 2015-08-13 10:27:45 +0200 | [diff] [blame] | 45 | ScopedVector<TraceRecorderImpl> recorder_impls_; |
| 46 | mojo::InterfacePtrSet<TraceProvider> provider_ptrs_; |
| 47 | mojo::Binding<TraceCollector> collector_binding_; |
James Robinson | 115caf8 | 2015-04-07 12:52:40 -0700 | [diff] [blame] | 48 | bool tracing_active_; |
| 49 | mojo::String tracing_categories_; |
| 50 | |
| 51 | DISALLOW_COPY_AND_ASSIGN(TracingApp); |
| 52 | }; |
| 53 | |
| 54 | } // namespace tracing |
| 55 | |
| 56 | #endif // SERVICES_TRACING_TRACING_APP_H_ |