| 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 SHELL_TRACER_H_ | 5 #ifndef SHELL_TRACER_H_ |
| 6 #define SHELL_TRACER_H_ | 6 #define SHELL_TRACER_H_ |
| 7 | 7 |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
| 15 #include "mojo/common/trace_provider_impl.h" | 15 #include "mojo/common/trace_provider_impl.h" |
| 16 #include "mojo/data_pipe_utils/data_pipe_drainer.h" | 16 #include "mojo/data_pipe_utils/data_pipe_drainer.h" |
| 17 #include "mojo/public/cpp/bindings/binding.h" |
| 17 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" | 18 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" |
| 18 | 19 |
| 19 namespace shell { | 20 namespace shell { |
| 20 | 21 |
| 21 // Tracer collects tracing data from base/trace_event and from externally | 22 // Tracer collects tracing data from base/trace_event and from externally |
| 22 // configured sources, aggregates it into a single stream, and writes it out to | 23 // configured sources, aggregates it into a single stream, and writes it out to |
| 23 // a file. It should be constructed very early in a process' lifetime before any | 24 // a file. It should be constructed very early in a process' lifetime before any |
| 24 // initialization that may be interesting to trace has occured and be shut down | 25 // initialization that may be interesting to trace has occured and be shut down |
| 25 // as late as possible to capture as much initialization/shutdown code as | 26 // as late as possible to capture as much initialization/shutdown code as |
| 26 // possible. | 27 // possible. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // Emits a comma if needed. | 75 // Emits a comma if needed. |
| 75 void WriteCommaIfNeeded(); | 76 void WriteCommaIfNeeded(); |
| 76 | 77 |
| 77 // Writes trace file footer and closes out the file. | 78 // Writes trace file footer and closes out the file. |
| 78 void WriteFooterAndClose(); | 79 void WriteFooterAndClose(); |
| 79 | 80 |
| 80 // Set when connected to the tracing service. | 81 // Set when connected to the tracing service. |
| 81 tracing::TraceCollectorPtr coordinator_; | 82 tracing::TraceCollectorPtr coordinator_; |
| 82 scoped_ptr<mojo::common::DataPipeDrainer> drainer_; | 83 scoped_ptr<mojo::common::DataPipeDrainer> drainer_; |
| 83 | 84 |
| 85 mojo::TraceProviderImpl trace_provider_impl_; |
| 86 mojo::Binding<tracing::TraceProvider> trace_provider_binding_; |
| 84 // Whether we're currently tracing. | 87 // Whether we're currently tracing. |
| 85 bool tracing_; | 88 bool tracing_; |
| 86 // How long to trace after message loop creation. | 89 // How long to trace after message loop creation. |
| 87 int trace_duration_secs_; | 90 int trace_duration_secs_; |
| 88 // Categories to trace. | 91 // Categories to trace. |
| 89 std::string categories_; | 92 std::string categories_; |
| 90 | 93 |
| 91 // Whether we've written the first chunk. | 94 // Whether we've written the first chunk. |
| 92 bool first_chunk_written_; | 95 bool first_chunk_written_; |
| 93 std::string trace_service_data_; | 96 std::string trace_service_data_; |
| 94 | 97 |
| 95 // Trace file, if open. | 98 // Trace file, if open. |
| 96 FILE* trace_file_; | 99 FILE* trace_file_; |
| 97 std::string trace_filename_; | 100 std::string trace_filename_; |
| 98 | 101 |
| 99 DISALLOW_COPY_AND_ASSIGN(Tracer); | 102 DISALLOW_COPY_AND_ASSIGN(Tracer); |
| 100 }; | 103 }; |
| 101 | 104 |
| 102 } // namespace shell | 105 } // namespace shell |
| 103 | 106 |
| 104 #endif // SHELL_TRACER_H_ | 107 #endif // SHELL_TRACER_H_ |
| OLD | NEW |