OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SERVICES_TRACING_TRACING_APP_H_ | 5 #ifndef SERVICES_TRACING_SERVICE_H_ |
6 #define SERVICES_TRACING_TRACING_APP_H_ | 6 #define SERVICES_TRACING_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "mojo/public/cpp/bindings/binding_set.h" | 14 #include "mojo/public/cpp/bindings/binding_set.h" |
15 #include "mojo/public/cpp/bindings/interface_ptr_set.h" | 15 #include "mojo/public/cpp/bindings/interface_ptr_set.h" |
16 #include "mojo/public/cpp/bindings/strong_binding.h" | 16 #include "mojo/public/cpp/bindings/strong_binding.h" |
17 #include "services/shell/public/cpp/interface_factory.h" | 17 #include "services/shell/public/cpp/interface_factory.h" |
18 #include "services/shell/public/cpp/service.h" | 18 #include "services/shell/public/cpp/service.h" |
| 19 #include "services/tracing/data_sink.h" |
19 #include "services/tracing/public/interfaces/tracing.mojom.h" | 20 #include "services/tracing/public/interfaces/tracing.mojom.h" |
20 #include "services/tracing/trace_data_sink.h" | 21 #include "services/tracing/recorder.h" |
21 #include "services/tracing/trace_recorder_impl.h" | |
22 | 22 |
23 namespace tracing { | 23 namespace tracing { |
24 | 24 |
25 class TracingApp | 25 class Service |
26 : public shell::Service, | 26 : public shell::Service, |
27 public shell::InterfaceFactory<TraceCollector>, | 27 public shell::InterfaceFactory<mojom::Factory>, |
28 public TraceCollector, | 28 public shell::InterfaceFactory<mojom::Collector>, |
29 public shell::InterfaceFactory<StartupPerformanceDataCollector>, | 29 public shell::InterfaceFactory<mojom::StartupPerformanceDataCollector>, |
30 public StartupPerformanceDataCollector { | 30 public mojom::Factory, |
| 31 public mojom::Collector, |
| 32 public mojom::StartupPerformanceDataCollector { |
31 public: | 33 public: |
32 TracingApp(); | 34 Service(); |
33 ~TracingApp() override; | 35 ~Service() override; |
34 | 36 |
35 private: | 37 private: |
36 // shell::Service implementation. | 38 // shell::Service implementation. |
37 bool OnConnect(shell::Connection* connection) override; | 39 bool OnConnect(shell::Connection* connection) override; |
38 bool OnStop() override; | 40 bool OnStop() override; |
39 | 41 |
40 // shell::InterfaceFactory<TraceCollector> implementation. | 42 // shell::InterfaceFactory<mojom::Factory>: |
41 void Create(const shell::Identity& remote_identity, | 43 void Create(const shell::Identity& remote_identity, |
42 mojo::InterfaceRequest<TraceCollector> request) override; | 44 mojom::FactoryRequest request) override; |
43 | 45 |
44 // shell::InterfaceFactory<StartupPerformanceDataCollector> implementation. | 46 // shell::InterfaceFactory<mojom::Collector>: |
| 47 void Create(const shell::Identity& remote_identity, |
| 48 mojom::CollectorRequest request) override; |
| 49 |
| 50 // shell::InterfaceFactory<mojom::StartupPerformanceDataCollector>: |
45 void Create( | 51 void Create( |
46 const shell::Identity& remote_identity, | 52 const shell::Identity& remote_identity, |
47 mojo::InterfaceRequest<StartupPerformanceDataCollector> request) override; | 53 mojom::StartupPerformanceDataCollectorRequest request) override; |
48 | 54 |
49 // tracing::TraceCollector implementation. | 55 // mojom::Factory: |
| 56 void CreateRecorder(mojom::ProviderPtr provider) override; |
| 57 |
| 58 // mojom::Collector: |
50 void Start(mojo::ScopedDataPipeProducerHandle stream, | 59 void Start(mojo::ScopedDataPipeProducerHandle stream, |
51 const mojo::String& categories) override; | 60 const std::string& categories) override; |
52 void StopAndFlush() override; | 61 void StopAndFlush() override; |
53 | 62 |
54 // StartupPerformanceDataCollector implementation. | 63 // mojom::StartupPerformanceDataCollector: |
55 void SetShellProcessCreationTime(int64_t time) override; | 64 void SetShellProcessCreationTime(int64_t time) override; |
56 void SetShellMainEntryPointTime(int64_t time) override; | 65 void SetShellMainEntryPointTime(int64_t time) override; |
57 void SetBrowserMessageLoopStartTicks(int64_t ticks) override; | 66 void SetBrowserMessageLoopStartTicks(int64_t ticks) override; |
58 void SetBrowserWindowDisplayTicks(int64_t ticks) override; | 67 void SetBrowserWindowDisplayTicks(int64_t ticks) override; |
59 void SetBrowserOpenTabsTimeDelta(int64_t delta) override; | 68 void SetBrowserOpenTabsTimeDelta(int64_t delta) override; |
60 void SetFirstWebContentsMainFrameLoadTicks(int64_t ticks) override; | 69 void SetFirstWebContentsMainFrameLoadTicks(int64_t ticks) override; |
61 void SetFirstVisuallyNonEmptyLayoutTicks(int64_t ticks) override; | 70 void SetFirstVisuallyNonEmptyLayoutTicks(int64_t ticks) override; |
62 void GetStartupPerformanceTimes( | 71 void GetStartupPerformanceTimes( |
63 const GetStartupPerformanceTimesCallback& callback) override; | 72 const GetStartupPerformanceTimesCallback& callback) override; |
64 | 73 |
65 void AllDataCollected(); | 74 void AllDataCollected(); |
66 | 75 |
67 std::unique_ptr<TraceDataSink> sink_; | 76 mojo::BindingSet<mojom::Factory> bindings_; |
68 ScopedVector<TraceRecorderImpl> recorder_impls_; | 77 std::unique_ptr<DataSink> sink_; |
69 mojo::InterfacePtrSet<TraceProvider> provider_ptrs_; | 78 ScopedVector<Recorder> recorder_impls_; |
70 mojo::Binding<TraceCollector> collector_binding_; | 79 mojo::InterfacePtrSet<mojom::Provider> provider_ptrs_; |
71 mojo::BindingSet<StartupPerformanceDataCollector> | 80 mojo::Binding<mojom::Collector> collector_binding_; |
| 81 mojo::BindingSet<mojom::StartupPerformanceDataCollector> |
72 startup_performance_data_collector_bindings_; | 82 startup_performance_data_collector_bindings_; |
73 StartupPerformanceTimes startup_performance_times_; | 83 mojom::StartupPerformanceTimes startup_performance_times_; |
74 bool tracing_active_; | 84 bool tracing_active_; |
75 mojo::String tracing_categories_; | 85 mojo::String tracing_categories_; |
76 | 86 |
77 DISALLOW_COPY_AND_ASSIGN(TracingApp); | 87 DISALLOW_COPY_AND_ASSIGN(Service); |
78 }; | 88 }; |
79 | 89 |
80 } // namespace tracing | 90 } // namespace tracing |
81 | 91 |
82 #endif // SERVICES_TRACING_TRACING_APP_H_ | 92 #endif // SERVICES_TRACING_SERVICE_H_ |
OLD | NEW |