Chromium Code Reviews| Index: shell/tracer.h |
| diff --git a/shell/tracer.h b/shell/tracer.h |
| index 4af166bd2e8a3a419996e429e7b25b7b820ed3d7..13890c963c5a876c33835fe0df3a6befbabc40ba 100644 |
| --- a/shell/tracer.h |
| +++ b/shell/tracer.h |
| @@ -12,6 +12,9 @@ |
| #include "base/callback.h" |
| #include "base/macros.h" |
| #include "base/memory/ref_counted_memory.h" |
| +#include "mojo/common/data_pipe_drainer.h" |
| +#include "mojo/common/trace_controller_impl.h" |
| +#include "services/tracing/tracing.mojom.h" |
| namespace shell { |
| @@ -21,19 +24,27 @@ namespace shell { |
| // initialization that may be interesting to trace has occured and be shut down |
| // as late as possible to capture as much initialization/shutdown code as |
| // possible. |
| -class Tracer { |
| +class Tracer : public mojo::common::DataPipeDrainer::Client { |
| public: |
| Tracer(); |
| - ~Tracer(); |
| + ~Tracer() override; |
| // Starts tracing the current process with the given set of categories. |
| void Start(const std::string& categories); |
| + // Starts collecting data from the tracing service with the given set of |
| + // categories. |
| + void StartCollectingFromTracingService( |
| + tracing::TraceCoordinatorPtr coordinator); |
| + |
| // Stops tracing and flushes all collected trace data to the given filename. |
| // Blocks until the file write is complete. May be called after the message |
| // loop is shut down. |
| void StopAndFlushToFile(const std::string& filename); |
| + void ConnectToController( |
| + mojo::InterfaceRequest<tracing::TraceController> request); |
| + |
| private: |
| void StopTracingAndFlushToDisk(const std::string& filename); |
| @@ -48,14 +59,33 @@ class Tracer { |
| const scoped_refptr<base::RefCountedString>& events_str, |
| bool has_more_events); |
| - // Whether we're currently tracing. Main thread only. |
| + // mojo::common::DataPipeDrainer::Client implementation. |
| + void OnDataAvailable(const void* data, size_t num_bytes) override; |
| + void OnDataComplete() override; |
| + |
| + // Emits a comma if needed. |
| + void WriteCommaIfNeeded(); |
| + |
| + // Writes trace file footer and closes out the file. |
| + void WriteFooterAndClose(); |
| + |
| + // Pointer to the tracing service. |
|
viettrungluu
2015/04/27 17:04:11
I'm confused by this comment (and/or its placement
jamesr
2015/04/27 23:46:57
Took another crack
|
| + scoped_ptr<mojo::common::DataPipeDrainer> drainer_; |
| + tracing::TraceCoordinatorPtr coordinator_; |
| + |
| + // Connection from the tracing service to us when the tracing service is |
| + // active. |
| + scoped_ptr<mojo::TraceControllerImpl> controller_impl_; |
| + |
| + // Whether we're currently tracing. |
| bool tracing_; |
| - // Whether we've written the first chunk. Flush thread only. |
| + // Whether we've written the first chunk. |
| bool first_chunk_written_; |
| - // Trace file, if open. Flush thread only. |
| + // Trace file, if open. |
| FILE* trace_file_; |
| + std::string trace_filename_; |
| DISALLOW_COPY_AND_ASSIGN(Tracer); |
| }; |