| 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 22 matching lines...) Expand all Loading... |
| 33 tracing_ = true; | 33 tracing_ = true; |
| 34 trace_filename_ = filename; | 34 trace_filename_ = filename; |
| 35 categories_ = categories; | 35 categories_ = categories; |
| 36 base::trace_event::TraceConfig config(categories, | 36 base::trace_event::TraceConfig config(categories, |
| 37 base::trace_event::RECORD_UNTIL_FULL); | 37 base::trace_event::RECORD_UNTIL_FULL); |
| 38 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 38 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 39 config, base::trace_event::TraceLog::RECORDING_MODE); | 39 config, base::trace_event::TraceLog::RECORDING_MODE); |
| 40 | 40 |
| 41 int trace_duration_secs = 5; | 41 int trace_duration_secs = 5; |
| 42 if (!duration_seconds_str.empty()) { | 42 if (!duration_seconds_str.empty()) { |
| 43 CHECK(base::StringToInt(duration_seconds_str, &trace_duration_secs)) | 43 // Could not parse --trace-startup-duration value |duration_seconds_str|. |
| 44 << "Could not parse --trace-startup-duration value " | 44 CHECK(base::StringToInt(duration_seconds_str, &trace_duration_secs)); |
| 45 << duration_seconds_str; | |
| 46 } | 45 } |
| 47 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 46 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 48 FROM_HERE, | 47 FROM_HERE, |
| 49 base::Bind(&Tracer::StopAndFlushToFile, base::Unretained(this)), | 48 base::Bind(&Tracer::StopAndFlushToFile, base::Unretained(this)), |
| 50 base::TimeDelta::FromSeconds(trace_duration_secs)); | 49 base::TimeDelta::FromSeconds(trace_duration_secs)); |
| 51 } | 50 } |
| 52 | 51 |
| 53 void Tracer::StartCollectingFromTracingService( | 52 void Tracer::StartCollectingFromTracingService( |
| 54 tracing::mojom::CollectorPtr coordinator) { | 53 tracing::mojom::CollectorPtr coordinator) { |
| 55 coordinator_ = std::move(coordinator); | 54 coordinator_ = std::move(coordinator); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 WriteFooterAndClose(); | 151 WriteFooterAndClose(); |
| 153 } | 152 } |
| 154 | 153 |
| 155 void Tracer::WriteCommaIfNeeded() { | 154 void Tracer::WriteCommaIfNeeded() { |
| 156 if (first_chunk_written_) | 155 if (first_chunk_written_) |
| 157 PCHECK(fwrite(",", 1, 1, trace_file_) == 1); | 156 PCHECK(fwrite(",", 1, 1, trace_file_) == 1); |
| 158 first_chunk_written_ = true; | 157 first_chunk_written_ = true; |
| 159 } | 158 } |
| 160 | 159 |
| 161 } // namespace service_manager | 160 } // namespace service_manager |
| OLD | NEW |