| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/trace_event/trace_event_impl.h" | 5 #include "base/trace_event/trace_event_impl.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 void TraceLog::StopATrace() { | 121 void TraceLog::StopATrace() { |
| 122 if (g_atrace_fd == -1) | 122 if (g_atrace_fd == -1) |
| 123 return; | 123 return; |
| 124 | 124 |
| 125 close(g_atrace_fd); | 125 close(g_atrace_fd); |
| 126 g_atrace_fd = -1; | 126 g_atrace_fd = -1; |
| 127 | 127 |
| 128 // TraceLog::Flush() requires the current thread to have a message loop, but | 128 // TraceLog::Flush() requires the current thread to have a message loop, but |
| 129 // this thread called from Java may not have one, so flush in another thread. | 129 // this thread called from Java may not have one, so flush in another thread. |
| 130 Thread end_chrome_tracing_thread("end_chrome_tracing"); | 130 Thread end_chrome_tracing_thread("end_chrome_tracing"); |
| 131 WaitableEvent complete_event(false, false); | 131 WaitableEvent complete_event(WaitableEvent::ResetPolicy::AUTOMATIC, |
| 132 WaitableEvent::InitialState::NOT_SIGNALED); |
| 132 end_chrome_tracing_thread.Start(); | 133 end_chrome_tracing_thread.Start(); |
| 133 end_chrome_tracing_thread.task_runner()->PostTask( | 134 end_chrome_tracing_thread.task_runner()->PostTask( |
| 134 FROM_HERE, base::Bind(&EndChromeTracing, Unretained(this), | 135 FROM_HERE, base::Bind(&EndChromeTracing, Unretained(this), |
| 135 Unretained(&complete_event))); | 136 Unretained(&complete_event))); |
| 136 complete_event.Wait(); | 137 complete_event.Wait(); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void TraceEvent::SendToATrace() { | 140 void TraceEvent::SendToATrace() { |
| 140 if (g_atrace_fd == -1) | 141 if (g_atrace_fd == -1) |
| 141 return; | 142 return; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // trace buffer. | 206 // trace buffer. |
| 206 double now_in_seconds = (TimeTicks::Now() - TimeTicks()).InSecondsF(); | 207 double now_in_seconds = (TimeTicks::Now() - TimeTicks()).InSecondsF(); |
| 207 std::string marker = StringPrintf( | 208 std::string marker = StringPrintf( |
| 208 "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); | 209 "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); |
| 209 WriteToATrace(atrace_fd, marker.c_str(), marker.size()); | 210 WriteToATrace(atrace_fd, marker.c_str(), marker.size()); |
| 210 close(atrace_fd); | 211 close(atrace_fd); |
| 211 } | 212 } |
| 212 | 213 |
| 213 } // namespace trace_event | 214 } // namespace trace_event |
| 214 } // namespace base | 215 } // namespace base |
| OLD | NEW |