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/shell/standalone/tracer.h" | 5 #include "services/shell/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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // collected in process to it. | 79 // collected in process to it. |
80 if (coordinator_) { | 80 if (coordinator_) { |
81 coordinator_->StopAndFlush(); | 81 coordinator_->StopAndFlush(); |
82 } else { | 82 } else { |
83 // Or we might not be connected. If we aren't connected to the tracing | 83 // Or we might not be connected. If we aren't connected to the tracing |
84 // service we want to collect the tracing data gathered ourselves and flush | 84 // service we want to collect the tracing data gathered ourselves and flush |
85 // it to disk. We do this in a blocking fashion (for this thread) so we can | 85 // it to disk. We do this in a blocking fashion (for this thread) so we can |
86 // gather as much data as possible on shutdown. | 86 // gather as much data as possible on shutdown. |
87 base::trace_event::TraceLog::GetInstance()->SetDisabled(); | 87 base::trace_event::TraceLog::GetInstance()->SetDisabled(); |
88 { | 88 { |
89 base::WaitableEvent flush_complete_event(false, false); | 89 base::WaitableEvent flush_complete_event( |
| 90 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 91 base::WaitableEvent::InitialState::NOT_SIGNALED); |
90 // TraceLog::Flush requires a message loop but we've already shut ours | 92 // TraceLog::Flush requires a message loop but we've already shut ours |
91 // down. | 93 // down. |
92 // Spin up a new thread to flush things out. | 94 // Spin up a new thread to flush things out. |
93 base::Thread flush_thread("mojo_runner_trace_event_flush"); | 95 base::Thread flush_thread("mojo_runner_trace_event_flush"); |
94 flush_thread.Start(); | 96 flush_thread.Start(); |
95 flush_thread.message_loop()->PostTask( | 97 flush_thread.message_loop()->PostTask( |
96 FROM_HERE, | 98 FROM_HERE, |
97 base::Bind(&Tracer::EndTraceAndFlush, base::Unretained(this), | 99 base::Bind(&Tracer::EndTraceAndFlush, base::Unretained(this), |
98 trace_filename_, | 100 trace_filename_, |
99 base::Bind(&base::WaitableEvent::Signal, | 101 base::Bind(&base::WaitableEvent::Signal, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 WriteFooterAndClose(); | 155 WriteFooterAndClose(); |
154 } | 156 } |
155 | 157 |
156 void Tracer::WriteCommaIfNeeded() { | 158 void Tracer::WriteCommaIfNeeded() { |
157 if (first_chunk_written_) | 159 if (first_chunk_written_) |
158 PCHECK(fwrite(",", 1, 1, trace_file_) == 1); | 160 PCHECK(fwrite(",", 1, 1, trace_file_) == 1); |
159 first_chunk_written_ = true; | 161 first_chunk_written_ = true; |
160 } | 162 } |
161 | 163 |
162 } // namespace shell | 164 } // namespace shell |
OLD | NEW |