| 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 #include "services/service_manager/standalone/tracer.h" | 5 #include "services/service_manager/standalone/tracer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 coordinator_->Start(std::move(data_pipe.producer_handle), categories_); | 57 coordinator_->Start(std::move(data_pipe.producer_handle), categories_); |
| 58 drainer_.reset(new mojo::common::DataPipeDrainer( | 58 drainer_.reset(new mojo::common::DataPipeDrainer( |
| 59 this, std::move(data_pipe.consumer_handle))); | 59 this, std::move(data_pipe.consumer_handle))); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void Tracer::StopAndFlushToFile() { | 62 void Tracer::StopAndFlushToFile() { |
| 63 if (tracing_) | 63 if (tracing_) |
| 64 StopTracingAndFlushToDisk(); | 64 StopTracingAndFlushToDisk(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void Tracer::ConnectToProvider(tracing::mojom::ProviderRequest request) { | |
| 68 provider_.Bind(std::move(request)); | |
| 69 } | |
| 70 | |
| 71 void Tracer::StopTracingAndFlushToDisk() { | 67 void Tracer::StopTracingAndFlushToDisk() { |
| 72 tracing_ = false; | 68 tracing_ = false; |
| 73 trace_file_ = fopen(trace_filename_.c_str(), "w+"); | 69 trace_file_ = fopen(trace_filename_.c_str(), "w+"); |
| 74 PCHECK(trace_file_); | 70 PCHECK(trace_file_); |
| 75 static const char kStart[] = "{\"traceEvents\":["; | 71 static const char kStart[] = "{\"traceEvents\":["; |
| 76 PCHECK(fwrite(kStart, 1, strlen(kStart), trace_file_) == strlen(kStart)); | 72 PCHECK(fwrite(kStart, 1, strlen(kStart), trace_file_) == strlen(kStart)); |
| 77 | 73 |
| 78 // At this point we might be connected to the tracing service, in which case | 74 // At this point we might be connected to the tracing service, in which case |
| 79 // we want to tell it to stop tracing and we will send the data we've | 75 // we want to tell it to stop tracing and we will send the data we've |
| 80 // collected in process to it. | 76 // collected in process to it. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 WriteFooterAndClose(); | 152 WriteFooterAndClose(); |
| 157 } | 153 } |
| 158 | 154 |
| 159 void Tracer::WriteCommaIfNeeded() { | 155 void Tracer::WriteCommaIfNeeded() { |
| 160 if (first_chunk_written_) | 156 if (first_chunk_written_) |
| 161 PCHECK(fwrite(",", 1, 1, trace_file_) == 1); | 157 PCHECK(fwrite(",", 1, 1, trace_file_) == 1); |
| 162 first_chunk_written_ = true; | 158 first_chunk_written_ = true; |
| 163 } | 159 } |
| 164 | 160 |
| 165 } // namespace service_manager | 161 } // namespace service_manager |
| OLD | NEW |