| 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_SERVICE_MANAGER_STANDALONE_TRACER_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_STANDALONE_TRACER_H_ |
| 6 #define SERVICES_SERVICE_MANAGER_STANDALONE_TRACER_H_ | 6 #define SERVICES_SERVICE_MANAGER_STANDALONE_TRACER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted_memory.h" | 16 #include "base/memory/ref_counted_memory.h" |
| 17 #include "mojo/common/data_pipe_drainer.h" | 17 #include "mojo/common/data_pipe_drainer.h" |
| 18 #include "services/tracing/public/cpp/provider.h" | |
| 19 #include "services/tracing/public/interfaces/tracing.mojom.h" | 18 #include "services/tracing/public/interfaces/tracing.mojom.h" |
| 20 | 19 |
| 21 namespace service_manager { | 20 namespace service_manager { |
| 22 | 21 |
| 23 // Tracer collects tracing data from base/trace_event and from externally | 22 // Tracer collects tracing data from base/trace_event and from externally |
| 24 // 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 |
| 25 // 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 |
| 26 // 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 |
| 27 // 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 |
| 28 // possible. | 27 // possible. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // Emits a comma if needed. | 70 // Emits a comma if needed. |
| 72 void WriteCommaIfNeeded(); | 71 void WriteCommaIfNeeded(); |
| 73 | 72 |
| 74 // Writes trace file footer and closes out the file. | 73 // Writes trace file footer and closes out the file. |
| 75 void WriteFooterAndClose(); | 74 void WriteFooterAndClose(); |
| 76 | 75 |
| 77 // Set when connected to the tracing service. | 76 // Set when connected to the tracing service. |
| 78 tracing::mojom::CollectorPtr coordinator_; | 77 tracing::mojom::CollectorPtr coordinator_; |
| 79 std::unique_ptr<mojo::common::DataPipeDrainer> drainer_; | 78 std::unique_ptr<mojo::common::DataPipeDrainer> drainer_; |
| 80 | 79 |
| 81 tracing::Provider provider_; | |
| 82 // Whether we're currently tracing. | 80 // Whether we're currently tracing. |
| 83 bool tracing_; | 81 bool tracing_; |
| 84 // Categories to trace. | 82 // Categories to trace. |
| 85 std::string categories_; | 83 std::string categories_; |
| 86 | 84 |
| 87 // Whether we've written the first chunk. | 85 // Whether we've written the first chunk. |
| 88 bool first_chunk_written_; | 86 bool first_chunk_written_; |
| 89 std::string trace_service_data_; | 87 std::string trace_service_data_; |
| 90 | 88 |
| 91 // Trace file, if open. | 89 // Trace file, if open. |
| 92 FILE* trace_file_; | 90 FILE* trace_file_; |
| 93 std::string trace_filename_; | 91 std::string trace_filename_; |
| 94 | 92 |
| 95 DISALLOW_COPY_AND_ASSIGN(Tracer); | 93 DISALLOW_COPY_AND_ASSIGN(Tracer); |
| 96 }; | 94 }; |
| 97 | 95 |
| 98 } // namespace service_manager | 96 } // namespace service_manager |
| 99 | 97 |
| 100 #endif // SERVICES_SERVICE_MANAGER_STANDALONE_TRACER_H_ | 98 #endif // SERVICES_SERVICE_MANAGER_STANDALONE_TRACER_H_ |
| OLD | NEW |