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 MOJO_COMMON_TRACE_PROVIDER_IMPL_H_ | 5 #ifndef MOJO_COMMON_TRACE_PROVIDER_IMPL_H_ |
6 #define MOJO_COMMON_TRACE_PROVIDER_IMPL_H_ | 6 #define MOJO_COMMON_TRACE_PROVIDER_IMPL_H_ |
7 | 7 |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
11 #include "mojo/public/cpp/bindings/interface_request.h" | 11 #include "mojo/public/cpp/bindings/interface_request.h" |
12 #include "mojo/services/tracing/interfaces/tracing.mojom.h" | 12 #include "mojo/services/tracing/interfaces/tracing.mojom.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 | 15 |
16 class TraceProviderImpl : public tracing::TraceProvider { | 16 class TraceProviderImpl : public tracing::TraceProvider { |
17 public: | 17 public: |
18 TraceProviderImpl(); | 18 TraceProviderImpl(); |
19 ~TraceProviderImpl() override; | 19 ~TraceProviderImpl() override; |
20 | 20 |
21 void Bind(InterfaceRequest<tracing::TraceProvider> request); | 21 void Bind(InterfaceRequest<tracing::TraceProvider> request); |
22 | 22 |
23 // Enable tracing without waiting for an inbound connection. It will stop if | 23 // Enable tracing without waiting for an inbound connection. It will stop if |
24 // no TraceRecorder is sent within a set time. | 24 // no TraceRecorder is sent within a set time. |
25 void ForceEnableTracing(); | 25 void ForceEnableTracing(); |
26 | 26 |
27 private: | 27 private: |
28 // tracing::TraceProvider implementation: | 28 // tracing::TraceProvider implementation: |
29 void StartTracing(const String& categories, | 29 void StartTracing( |
30 tracing::TraceRecorderPtr recorder) override; | 30 const String& categories, |
| 31 mojo::InterfaceHandle<tracing::TraceRecorder> recorder) override; |
31 void StopTracing() override; | 32 void StopTracing() override; |
32 | 33 |
33 void SendChunk(const scoped_refptr<base::RefCountedString>& events_str, | 34 void SendChunk(const scoped_refptr<base::RefCountedString>& events_str, |
34 bool has_more_events); | 35 bool has_more_events); |
35 | 36 |
36 void DelayedStop(); | 37 void DelayedStop(); |
37 // Stop the collection of traces if no external connection asked for them yet. | 38 // Stop the collection of traces if no external connection asked for them yet. |
38 void StopIfForced(); | 39 void StopIfForced(); |
39 | 40 |
40 Binding<tracing::TraceProvider> binding_; | 41 Binding<tracing::TraceProvider> binding_; |
41 bool tracing_forced_; | 42 bool tracing_forced_; |
42 tracing::TraceRecorderPtr recorder_; | 43 tracing::TraceRecorderPtr recorder_; |
43 | 44 |
44 base::WeakPtrFactory<TraceProviderImpl> weak_factory_; | 45 base::WeakPtrFactory<TraceProviderImpl> weak_factory_; |
45 DISALLOW_COPY_AND_ASSIGN(TraceProviderImpl); | 46 DISALLOW_COPY_AND_ASSIGN(TraceProviderImpl); |
46 }; | 47 }; |
47 | 48 |
48 } // namespace mojo | 49 } // namespace mojo |
49 | 50 |
50 #endif // MOJO_COMMON_TRACE_PROVIDER_IMPL_H_ | 51 #endif // MOJO_COMMON_TRACE_PROVIDER_IMPL_H_ |
OLD | NEW |