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 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 return; | 107 return; |
108 | 108 |
109 close(g_atrace_fd); | 109 close(g_atrace_fd); |
110 g_atrace_fd = -1; | 110 g_atrace_fd = -1; |
111 | 111 |
112 // TraceLog::Flush() requires the current thread to have a message loop, but | 112 // TraceLog::Flush() requires the current thread to have a message loop, but |
113 // this thread called from Java may not have one, so flush in another thread. | 113 // this thread called from Java may not have one, so flush in another thread. |
114 Thread end_chrome_tracing_thread("end_chrome_tracing"); | 114 Thread end_chrome_tracing_thread("end_chrome_tracing"); |
115 WaitableEvent complete_event(false, false); | 115 WaitableEvent complete_event(false, false); |
116 end_chrome_tracing_thread.Start(); | 116 end_chrome_tracing_thread.Start(); |
117 end_chrome_tracing_thread.message_loop()->PostTask( | 117 end_chrome_tracing_thread.task_runner()->PostTask( |
118 FROM_HERE, base::Bind(&EndChromeTracing, Unretained(this), | 118 FROM_HERE, base::Bind(&EndChromeTracing, Unretained(this), |
119 Unretained(&complete_event))); | 119 Unretained(&complete_event))); |
120 complete_event.Wait(); | 120 complete_event.Wait(); |
121 } | 121 } |
122 | 122 |
123 void TraceEvent::SendToATrace() { | 123 void TraceEvent::SendToATrace() { |
124 if (g_atrace_fd == -1) | 124 if (g_atrace_fd == -1) |
125 return; | 125 return; |
126 | 126 |
127 const char* category_group = | 127 const char* category_group = |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 double now_in_seconds = now.ToInternalValue() / 1000000.0; | 191 double now_in_seconds = now.ToInternalValue() / 1000000.0; |
192 std::string marker = StringPrintf( | 192 std::string marker = StringPrintf( |
193 "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); | 193 "trace_event_clock_sync: parent_ts=%f\n", now_in_seconds); |
194 if (write(atrace_fd, marker.c_str(), marker.size()) == -1) | 194 if (write(atrace_fd, marker.c_str(), marker.size()) == -1) |
195 PLOG(WARNING) << "Couldn't write to " << kATraceMarkerFile; | 195 PLOG(WARNING) << "Couldn't write to " << kATraceMarkerFile; |
196 close(atrace_fd); | 196 close(atrace_fd); |
197 } | 197 } |
198 | 198 |
199 } // namespace trace_event | 199 } // namespace trace_event |
200 } // namespace base | 200 } // namespace base |
OLD | NEW |