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